From c97518523b910ca7412f69de3803739affe2c583 Mon Sep 17 00:00:00 2001 From: EUcancER Date: Wed, 16 Nov 2011 18:35:13 +0100 Subject: //punani: tightnani-web is now able to handle fallback(super-) package manager --- punani/tightnani/tightnani-web.py | 7 ++++++- punani/tightnani/tightnani_db | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/punani/tightnani/tightnani-web.py b/punani/tightnani/tightnani-web.py index 52f5004f..4386bbae 100755 --- a/punani/tightnani/tightnani-web.py +++ b/punani/tightnani/tightnani-web.py @@ -18,7 +18,7 @@ pdb= json.load(open(PDB_FILE)) class Index: def GET(self): ret = """Welcome to the Tightnani API
-Retrieve a package name for your distribution with: /ARCH/PKG""" +Retrieve a package name for your distribution with: /PACKER/PKG""" return ret class Reload: @@ -36,13 +36,18 @@ class ArchFinder: if not packer or not package: web.BadRequest() else: packer = pdb['packer-symlinks'].get(packer,packer) #try to resolve similar packers + super_packer = pdb['super-packer'].get(packer,'') ret = pdb.get(package,{}).get(packer,False) + ret = ret if ret else pdb.get(package,{}).get(super_packer,False) + if not ret: web.NotFound() else: return ret if __name__ == "__main__": + import sys + sys.argv.append("9111") app = web.application(urls,globals()) app.internalerror = web.debugerror app.run() diff --git a/punani/tightnani/tightnani_db b/punani/tightnani/tightnani_db index d15a9ad4..4c2d4843 100644 --- a/punani/tightnani/tightnani_db +++ b/punani/tightnani/tightnani_db @@ -4,6 +4,9 @@ "aptitude" : "apt-get", "bauerbill" : "yaourt" }, + "super-packer" : { + "yaourt" : "pacman" + }, "vim" : { "apt-get" : "vim", "pacman" : "vim", -- cgit v1.2.3 From f5c086a61ed2cf493d2e6edb0edf0f32230bb615 Mon Sep 17 00:00:00 2001 From: makefu Date: Wed, 16 Nov 2011 19:29:44 +0100 Subject: //punani/tightnani_client: initial commit the tigtnani client finds your package manager and the required parameters to handle the manager. currently it is able to remove and install : pacman (and derivates), apt (and derivates), yum and brew. Nothing is tested so be aware --- punani/tightnani/tightnani_client | 59 +++++++++++++++++++++++++++++++++++++++ punani/tightnani/tightnani_db | 6 +++- 2 files changed, 64 insertions(+), 1 deletion(-) create mode 100755 punani/tightnani/tightnani_client diff --git a/punani/tightnani/tightnani_client b/punani/tightnani/tightnani_client new file mode 100755 index 00000000..d2a598d3 --- /dev/null +++ b/punani/tightnani/tightnani_client @@ -0,0 +1,59 @@ +#!/bin/bash +set -xeuf + +if [ $# -ne 2 ];then + echo "usage: `basename $0` (install|remove) PACKAGE" + exit 23 +fi + +PACKERS="yum!-y install remove +brew install remove +pacman!--noconfirm -S!--needed -Rcs +bauerbill!--noconfirm -S!--needed -Rcs +yaourt!--noconfirm -S!--needed -Rcs +packer!--noconfirm -S!--needed -Rcs +apt-get!--yes install remove +aptitude!--yes install remove" + +OIFS=$IFS +PACKER= +IFS=' +' + +TIGHTNANI_HOST="http://euer.krebsco.de:9111" +# Find suitable packer +for PACKER_LINE in $PACKERS; do + TRY_PACKER_CMD="$(echo "$PACKER_LINE" | cut -d ' ' -f 1)" + TRY_PACKER="$(echo "$TRY_PACKER_CMD" | cut -d '!' -f 1)" + if which $TRY_PACKER &>/dev/null; then + PACKER=$TRY_PACKER + PACKER_CMD="$(echo "$TRY_PACKER_CMD" | tr "!" " ")" + echo "you got $PACKER" + INSTALL_PARAM="$(echo "$PACKER_LINE" | cut -d ' ' -f 2 | tr "!" " ")" + REMOVE_PARAM="$(echo "$PACKER_LINE" | cut -d ' ' -f 3 | tr "!" " ")" + fi +done +IFS=$OIFS +if [ ! "$PACKER" ];then + echo "Could not find a supported packer for you, bailing out!" + exit 23 +fi + + +# find the package name +PKG="$2" +RESOLVED=`wget -O- $TIGHTNANI_HOST/$PACKER/$PKG` +if [ ! "$RESOLVED" ];then + echo "Could not resolve your requested package, bailing out!" + exit 23 +fi +case "$1" in + install) + exec $PACKER_CMD $INSTALL_PARAM $RESOLVED + ;; + remove) + exec $PACKER_CMD $REMOVE_PARAM $RESOLVED + ;; + *) + echo "usage: `basename $0` (install|remove) PACKAGE" +esac diff --git a/punani/tightnani/tightnani_db b/punani/tightnani/tightnani_db index d15a9ad4..322e28f8 100644 --- a/punani/tightnani/tightnani_db +++ b/punani/tightnani/tightnani_db @@ -21,5 +21,9 @@ "python3" : { "apt-get" : "python3", "pacman" : "python" - } + }, + "tinc" : { + "apt-get" : "tinc", + "yaourt" : "tinc" + } } -- cgit v1.2.3 From 655db45a3ef4ca58f9e9fe42bba015d1fd1eccb6 Mon Sep 17 00:00:00 2001 From: makefu Date: Wed, 16 Nov 2011 19:34:09 +0100 Subject: //punani: tightnani is now less verbose --- punani/tightnani/tightnani_client | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/punani/tightnani/tightnani_client b/punani/tightnani/tightnani_client index d2a598d3..8caf669e 100755 --- a/punani/tightnani/tightnani_client +++ b/punani/tightnani/tightnani_client @@ -1,5 +1,5 @@ #!/bin/bash -set -xeuf +set -euf if [ $# -ne 2 ];then echo "usage: `basename $0` (install|remove) PACKAGE" @@ -42,7 +42,7 @@ fi # find the package name PKG="$2" -RESOLVED=`wget -O- $TIGHTNANI_HOST/$PACKER/$PKG` +RESOLVED=`wget -O- $TIGHTNANI_HOST/$PACKER/$PKG 2>/dev/null` if [ ! "$RESOLVED" ];then echo "Could not resolve your requested package, bailing out!" exit 23 -- cgit v1.2.3 From 8575b9856aca6809bce214fd8a199c990cb6561c Mon Sep 17 00:00:00 2001 From: EUcancER Date: Wed, 16 Nov 2011 22:27:12 +0100 Subject: //punani: tightnani_client -> tinani, add packages --- punani/tightnani/tightnani_client | 59 --------------------------------------- punani/tightnani/tightnani_db | 26 ++++++++++++++++- punani/tightnani/tinani | 59 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 84 insertions(+), 60 deletions(-) delete mode 100755 punani/tightnani/tightnani_client create mode 100755 punani/tightnani/tinani diff --git a/punani/tightnani/tightnani_client b/punani/tightnani/tightnani_client deleted file mode 100755 index 8caf669e..00000000 --- a/punani/tightnani/tightnani_client +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/bash -set -euf - -if [ $# -ne 2 ];then - echo "usage: `basename $0` (install|remove) PACKAGE" - exit 23 -fi - -PACKERS="yum!-y install remove -brew install remove -pacman!--noconfirm -S!--needed -Rcs -bauerbill!--noconfirm -S!--needed -Rcs -yaourt!--noconfirm -S!--needed -Rcs -packer!--noconfirm -S!--needed -Rcs -apt-get!--yes install remove -aptitude!--yes install remove" - -OIFS=$IFS -PACKER= -IFS=' -' - -TIGHTNANI_HOST="http://euer.krebsco.de:9111" -# Find suitable packer -for PACKER_LINE in $PACKERS; do - TRY_PACKER_CMD="$(echo "$PACKER_LINE" | cut -d ' ' -f 1)" - TRY_PACKER="$(echo "$TRY_PACKER_CMD" | cut -d '!' -f 1)" - if which $TRY_PACKER &>/dev/null; then - PACKER=$TRY_PACKER - PACKER_CMD="$(echo "$TRY_PACKER_CMD" | tr "!" " ")" - echo "you got $PACKER" - INSTALL_PARAM="$(echo "$PACKER_LINE" | cut -d ' ' -f 2 | tr "!" " ")" - REMOVE_PARAM="$(echo "$PACKER_LINE" | cut -d ' ' -f 3 | tr "!" " ")" - fi -done -IFS=$OIFS -if [ ! "$PACKER" ];then - echo "Could not find a supported packer for you, bailing out!" - exit 23 -fi - - -# find the package name -PKG="$2" -RESOLVED=`wget -O- $TIGHTNANI_HOST/$PACKER/$PKG 2>/dev/null` -if [ ! "$RESOLVED" ];then - echo "Could not resolve your requested package, bailing out!" - exit 23 -fi -case "$1" in - install) - exec $PACKER_CMD $INSTALL_PARAM $RESOLVED - ;; - remove) - exec $PACKER_CMD $REMOVE_PARAM $RESOLVED - ;; - *) - echo "usage: `basename $0` (install|remove) PACKAGE" -esac diff --git a/punani/tightnani/tightnani_db b/punani/tightnani/tightnani_db index 6ae8098c..3641350d 100644 --- a/punani/tightnani/tightnani_db +++ b/punani/tightnani/tightnani_db @@ -28,5 +28,29 @@ "tinc" : { "apt-get" : "tinc", "yaourt" : "tinc" - } + }, + "python-notify" : { + "pacman" : "python-notify", + "apt-get" : "python-notify" + }, + "python-dbus" : { + "pacman" : "dbus-python", + "apt-get" : "python-dbus" + }, + "w3m" : { + "pacman" : "w3m", + "apt-get" : "w3m" + }, + "make" : { + "pacman" : "make", + "apt-get" : "make" + }, + "perl-xml-simple" : { + "apt-get" : "libxml-simple-perl", + "pacman" : "perl-xml-simple" + }, + "hostname" : { + "pacman" : "inetutils", + "apt-get" : "hostname" + } } diff --git a/punani/tightnani/tinani b/punani/tightnani/tinani new file mode 100755 index 00000000..8caf669e --- /dev/null +++ b/punani/tightnani/tinani @@ -0,0 +1,59 @@ +#!/bin/bash +set -euf + +if [ $# -ne 2 ];then + echo "usage: `basename $0` (install|remove) PACKAGE" + exit 23 +fi + +PACKERS="yum!-y install remove +brew install remove +pacman!--noconfirm -S!--needed -Rcs +bauerbill!--noconfirm -S!--needed -Rcs +yaourt!--noconfirm -S!--needed -Rcs +packer!--noconfirm -S!--needed -Rcs +apt-get!--yes install remove +aptitude!--yes install remove" + +OIFS=$IFS +PACKER= +IFS=' +' + +TIGHTNANI_HOST="http://euer.krebsco.de:9111" +# Find suitable packer +for PACKER_LINE in $PACKERS; do + TRY_PACKER_CMD="$(echo "$PACKER_LINE" | cut -d ' ' -f 1)" + TRY_PACKER="$(echo "$TRY_PACKER_CMD" | cut -d '!' -f 1)" + if which $TRY_PACKER &>/dev/null; then + PACKER=$TRY_PACKER + PACKER_CMD="$(echo "$TRY_PACKER_CMD" | tr "!" " ")" + echo "you got $PACKER" + INSTALL_PARAM="$(echo "$PACKER_LINE" | cut -d ' ' -f 2 | tr "!" " ")" + REMOVE_PARAM="$(echo "$PACKER_LINE" | cut -d ' ' -f 3 | tr "!" " ")" + fi +done +IFS=$OIFS +if [ ! "$PACKER" ];then + echo "Could not find a supported packer for you, bailing out!" + exit 23 +fi + + +# find the package name +PKG="$2" +RESOLVED=`wget -O- $TIGHTNANI_HOST/$PACKER/$PKG 2>/dev/null` +if [ ! "$RESOLVED" ];then + echo "Could not resolve your requested package, bailing out!" + exit 23 +fi +case "$1" in + install) + exec $PACKER_CMD $INSTALL_PARAM $RESOLVED + ;; + remove) + exec $PACKER_CMD $REMOVE_PARAM $RESOLVED + ;; + *) + echo "usage: `basename $0` (install|remove) PACKAGE" +esac -- cgit v1.2.3 From 1b0c87879d80fd7e70edb10a93b6010a014bbd15 Mon Sep 17 00:00:00 2001 From: EUcancER Date: Wed, 16 Nov 2011 22:54:27 +0100 Subject: //punani: db - add pip package manager --- punani/tightnani/tightnani_db | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/punani/tightnani/tightnani_db b/punani/tightnani/tightnani_db index 3641350d..318f0e27 100644 --- a/punani/tightnani/tightnani_db +++ b/punani/tightnani/tightnani_db @@ -52,5 +52,9 @@ "hostname" : { "pacman" : "inetutils", "apt-get" : "hostname" - } + }, + "pip" : { + "pacman" : "python-pip", + "apt-get" : "python-pip" + } } -- cgit v1.2.3 From 4e8fa61ec02b6f05134e8b95239d1821a46de57c Mon Sep 17 00:00:00 2001 From: EUcancER Date: Wed, 16 Nov 2011 22:56:47 +0100 Subject: //tightnani-web: add error message: --- punani/tightnani/tightnani-web.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/punani/tightnani/tightnani-web.py b/punani/tightnani/tightnani-web.py index 4386bbae..4e6a64a4 100755 --- a/punani/tightnani/tightnani-web.py +++ b/punani/tightnani/tightnani-web.py @@ -12,8 +12,9 @@ urls = ( PDB_FILE="tightnani_db" - -pdb= json.load(open(PDB_FILE)) +f = open(PDB_FILE) +pdb= json.load(f) +f.close() class Index: def GET(self): @@ -23,7 +24,9 @@ Retrieve a package name for your distribution with: /PACKER/PKG""" class Reload: def GET(self): - pdb= json.load(open(PDB_FILE)) + f = open(PDB_FILE) + pdb= json.load(f) + f.close() return "DB reloaded" @@ -40,7 +43,9 @@ class ArchFinder: ret = pdb.get(package,{}).get(packer,False) ret = ret if ret else pdb.get(package,{}).get(super_packer,False) - if not ret: web.NotFound() + if not ret: + web.NotFound() + return "not found. i'm so sorry :(" else: return ret -- cgit v1.2.3 From 3877e5d8221d42811d376ddb560552684d34f5cc Mon Sep 17 00:00:00 2001 From: EUcancER Date: Thu, 17 Nov 2011 11:16:48 +0100 Subject: //punani: rm old punani, tightnani->punani --- punani/bin/punani | 323 +++++++------------------------------- punani/db/punani | 60 +++++++ punani/index.py | 58 +++++++ punani/tightnani/tightnani-web.py | 58 ------- punani/tightnani/tightnani_db | 60 ------- punani/tightnani/tinani | 59 ------- 6 files changed, 171 insertions(+), 447 deletions(-) create mode 100644 punani/db/punani create mode 100755 punani/index.py delete mode 100755 punani/tightnani/tightnani-web.py delete mode 100644 punani/tightnani/tightnani_db delete mode 100755 punani/tightnani/tinani diff --git a/punani/bin/punani b/punani/bin/punani index 058331f1..8caf669e 100755 --- a/punani/bin/punani +++ b/punani/bin/punani @@ -1,276 +1,59 @@ -#! /bin/sh -# -# punani - filesystem scienteer -# -# Engineering Operations -# -E -i spec insert a package to the target filesystem -# -E -r spec remove a package -# +#!/bin/bash set -euf -godmode() { - if test "${nosudo-false}" != true -a `id -u` != 0; then - echo "!! we require god mode..." >&2 - exec sudo "$0" "$@" - exit 23 # go to hell - fi -} -# return the 'system' variable -# currently be: -# arch-like -# debian-like -guess_system() -{ - if [ -f "/etc/arch-release" ] ;then - system="${system+$system, }arch-like" - fi - if [ -f "/etc/lsb-release" -o -f "/etc/debian_version" ] ;then - system="${system+$system, }debian-like" +if [ $# -ne 2 ];then + echo "usage: `basename $0` (install|remove) PACKAGE" + exit 23 +fi + +PACKERS="yum!-y install remove +brew install remove +pacman!--noconfirm -S!--needed -Rcs +bauerbill!--noconfirm -S!--needed -Rcs +yaourt!--noconfirm -S!--needed -Rcs +packer!--noconfirm -S!--needed -Rcs +apt-get!--yes install remove +aptitude!--yes install remove" + +OIFS=$IFS +PACKER= +IFS=' +' + +TIGHTNANI_HOST="http://euer.krebsco.de:9111" +# Find suitable packer +for PACKER_LINE in $PACKERS; do + TRY_PACKER_CMD="$(echo "$PACKER_LINE" | cut -d ' ' -f 1)" + TRY_PACKER="$(echo "$TRY_PACKER_CMD" | cut -d '!' -f 1)" + if which $TRY_PACKER &>/dev/null; then + PACKER=$TRY_PACKER + PACKER_CMD="$(echo "$TRY_PACKER_CMD" | tr "!" " ")" + echo "you got $PACKER" + INSTALL_PARAM="$(echo "$PACKER_LINE" | cut -d ' ' -f 2 | tr "!" " ")" + REMOVE_PARAM="$(echo "$PACKER_LINE" | cut -d ' ' -f 3 | tr "!" " ")" fi - -} - -arch_aur_helper() -{ - # pacman is the last fallback helper - manager="yaourt clyde packer bauerbill tupac pacaur paktahn pbfetch aurget aurora cower powaur pacman" - for i in $manager;do - mgr=`which $i` - if [ "$mgr" ] ;then - echo $mgr - return 0 - fi - done - echo "!! no helper found, this should never happen(tm)." - return 1 -} - -handle_system () { - case "$system" in - (*arch-like*) - # dryrun - # TODO dryrun not dry enough for aur helper - if [ "${dryrun-}" ];then - pacman () { echo "pacman $@" ; } - pkgfile () { echo "pkgfile $@"; } - yaourt () { echo "yaourt $@" ; } - fi - - # get dependencies : - # we need pkgfile - if ! [ `which pkgfile` ] ; then - pacman -S --needed --noconfirm pkgtools - pkgfile -u - fi - punani_Scientist_update() { - pacman -Sy - pkgtool -u - } - punani_Scientist_search() { - pkgfile -s -b $1 - if [ "${hard-}" ] ; then - mgr=`arch_aur_helper` - $mgr -Ss $1 - fi - - } - - punani_Engineer_insert() { - # punani under archlinux first tries to load the packages with the given file name - # it needs pkgfile for that - # - # when trying harder it tries to load the package with the given name directly via yaourt - echo "** trying to find package with given file" - pkgs=$(pkgfile -s -b -r $1 | tr "\n" "|" ) - if [ "$pkgs" ];then - echo "** found one or more packages matching, skip the ones you do not need!" - OLDIFS=$IFS - IFS='|' - for to_install in $pkgs;do - if pacman -S --needed "$to_install"; then - echo "++ finished" - fi - done - IFS=$OLDIFS - else - echo "!! nothing found in base repos" - if [ "${hard-}" ] ; then - echo "** trying harder" - echo "** trying yaourt directly with given package" - mgr=`arch_aur_helper` - if $mgr -S $1 ;then - echo "++ finished" - return 0 - else - echo "!! giving up...i am sorry" - return 1 - fi - echo - else - echo "?? When in doubt try $0 -h -Ei $1 " - fi - fi - } - punani_Engineer_remove() { - pacman -Rcs "`pacman -Ql | grep $1$ | awk '{print $1}'`" - if [ "${hard-}" ] ; then - echo "** trying harder" - echo "** directly delete given package name" - pacman -Rcs "$1" - fi - } +done +IFS=$OIFS +if [ ! "$PACKER" ];then + echo "Could not find a supported packer for you, bailing out!" + exit 23 +fi + + +# find the package name +PKG="$2" +RESOLVED=`wget -O- $TIGHTNANI_HOST/$PACKER/$PKG 2>/dev/null` +if [ ! "$RESOLVED" ];then + echo "Could not resolve your requested package, bailing out!" + exit 23 +fi +case "$1" in + install) + exec $PACKER_CMD $INSTALL_PARAM $RESOLVED ;; - (*debian-like*) - #if [ "${dryrun-}" ]; then - # apt-file () { echo $@; } - # apt-get () { echo $@; } - #fi - if ! which apt-file; then - echo "** installing dependencies: apt-file" - apt-get install --yes apt-file - echo "** update the apt-file tool" - apt-file update - fi - punani_Scientist_update() { - apt-get update - apt-file update - } - - punani_Scientist_search() { - apt-file search -l -x $1\$ && exit 0 - if [ "${hard-}" ] ; then - apt-cache search $1 - fi - } - punani_Engineer_insert() { - echo "trying to install $1" - pkgs=$(apt-file search -l -x $1\$ | tr "\n" "|" ) - if [ "$pkgs" ];then - echo "** found one or more packages matching, skip the ones you do not need!" - OLDIFS=$IFS - IFS='|' - for to_install in $pkgs;do - if apt-get install $to_install;then - echo "++ finished" - fi - done - IFS=$OLDIFS - else - if [ "${hard-}" ] ; then - echo "** trying harder" - apt-get install $1 - fi - fi - } - punani_Engineer_remove() { - apt-get remove --purge "`apt-file search -l -x /$1\$`" - if [ "${hard-}" ] ; then - echo "** trying harder" - echo "** directly delete given package name" - apt-get remove --purge "$1" - fi - } + remove) + exec $PACKER_CMD $REMOVE_PARAM $RESOLVED ;; - (*) - email='krebs@syntax-fehler.de' - irc_host='irc.freenode.org' - irc_channel='#tincspasm' - cat >&2 <&2 - exit 23;; - esac;; - (Scientist) - case $OPT in - (s) command="${ns}_${role}_search";; - (y) command="${ns}_${role}_update";; - (*) - echo 'Error 1: You are made of stupid!' >&2 - exit 23;; - esac ;; - (undefined) - case $OPT in - (E) role=Engineer;; - (S) role=Scientist;; - (*) - exit 23;; - esac - ;; - (*) - echo 'Error 1: You are made of stupid!' >&2 - exit 23 - ;; - esac - done -} -punani $@ - -case $role in - (Engineer) godmode $@;; - (Scientist) - case $command in - (*_update) godmode $@;; - esac;; + *) + echo "usage: `basename $0` (install|remove) PACKAGE" esac - -shift `echo $OPTIND-1 | bc` - -guess_system -handle_system - -for name in "$@"; do - "$command" "$name" || echo "!! could not install $name" -done diff --git a/punani/db/punani b/punani/db/punani new file mode 100644 index 00000000..318f0e27 --- /dev/null +++ b/punani/db/punani @@ -0,0 +1,60 @@ +{ + "packer-symlinks" : { + "packer" : "yaourt", + "aptitude" : "apt-get", + "bauerbill" : "yaourt" + }, + "super-packer" : { + "yaourt" : "pacman" + }, + "vim" : { + "apt-get" : "vim", + "pacman" : "vim", + "brew" : "vim", + "yum" : "vim" + }, + "python" : { + "apt-get" : "python", + "pacman" : "python2" + }, + "python2" : { + "apt-get" : "python", + "pacman" : "python2" + }, + "python3" : { + "apt-get" : "python3", + "pacman" : "python" + }, + "tinc" : { + "apt-get" : "tinc", + "yaourt" : "tinc" + }, + "python-notify" : { + "pacman" : "python-notify", + "apt-get" : "python-notify" + }, + "python-dbus" : { + "pacman" : "dbus-python", + "apt-get" : "python-dbus" + }, + "w3m" : { + "pacman" : "w3m", + "apt-get" : "w3m" + }, + "make" : { + "pacman" : "make", + "apt-get" : "make" + }, + "perl-xml-simple" : { + "apt-get" : "libxml-simple-perl", + "pacman" : "perl-xml-simple" + }, + "hostname" : { + "pacman" : "inetutils", + "apt-get" : "hostname" + }, + "pip" : { + "pacman" : "python-pip", + "apt-get" : "python-pip" + } +} diff --git a/punani/index.py b/punani/index.py new file mode 100755 index 00000000..4e6a64a4 --- /dev/null +++ b/punani/index.py @@ -0,0 +1,58 @@ +#!/usr/bin/python + +import web +import json + +urls = ( + '/', 'Index', + '/dump','Dump', + '/reload','Reload', + '/(.+)/(.+)', 'ArchFinder', +) + + +PDB_FILE="tightnani_db" +f = open(PDB_FILE) +pdb= json.load(f) +f.close() + +class Index: + def GET(self): + ret = """Welcome to the Tightnani API
+Retrieve a package name for your distribution with: /PACKER/PKG""" + return ret + +class Reload: + def GET(self): + f = open(PDB_FILE) + pdb= json.load(f) + f.close() + return "DB reloaded" + + +class Dump: + def GET(self): + return json.dumps(pdb,sort_keys=True,indent=4) + +class ArchFinder: + def GET(self,packer,package): + if not packer or not package: web.BadRequest() + else: + packer = pdb['packer-symlinks'].get(packer,packer) #try to resolve similar packers + super_packer = pdb['super-packer'].get(packer,'') + ret = pdb.get(package,{}).get(packer,False) + ret = ret if ret else pdb.get(package,{}).get(super_packer,False) + + if not ret: + web.NotFound() + return "not found. i'm so sorry :(" + else: return ret + + + +if __name__ == "__main__": + import sys + sys.argv.append("9111") + app = web.application(urls,globals()) + app.internalerror = web.debugerror + app.run() diff --git a/punani/tightnani/tightnani-web.py b/punani/tightnani/tightnani-web.py deleted file mode 100755 index 4e6a64a4..00000000 --- a/punani/tightnani/tightnani-web.py +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/python - -import web -import json - -urls = ( - '/', 'Index', - '/dump','Dump', - '/reload','Reload', - '/(.+)/(.+)', 'ArchFinder', -) - - -PDB_FILE="tightnani_db" -f = open(PDB_FILE) -pdb= json.load(f) -f.close() - -class Index: - def GET(self): - ret = """Welcome to the Tightnani API
-Retrieve a package name for your distribution with: /PACKER/PKG""" - return ret - -class Reload: - def GET(self): - f = open(PDB_FILE) - pdb= json.load(f) - f.close() - return "DB reloaded" - - -class Dump: - def GET(self): - return json.dumps(pdb,sort_keys=True,indent=4) - -class ArchFinder: - def GET(self,packer,package): - if not packer or not package: web.BadRequest() - else: - packer = pdb['packer-symlinks'].get(packer,packer) #try to resolve similar packers - super_packer = pdb['super-packer'].get(packer,'') - ret = pdb.get(package,{}).get(packer,False) - ret = ret if ret else pdb.get(package,{}).get(super_packer,False) - - if not ret: - web.NotFound() - return "not found. i'm so sorry :(" - else: return ret - - - -if __name__ == "__main__": - import sys - sys.argv.append("9111") - app = web.application(urls,globals()) - app.internalerror = web.debugerror - app.run() diff --git a/punani/tightnani/tightnani_db b/punani/tightnani/tightnani_db deleted file mode 100644 index 318f0e27..00000000 --- a/punani/tightnani/tightnani_db +++ /dev/null @@ -1,60 +0,0 @@ -{ - "packer-symlinks" : { - "packer" : "yaourt", - "aptitude" : "apt-get", - "bauerbill" : "yaourt" - }, - "super-packer" : { - "yaourt" : "pacman" - }, - "vim" : { - "apt-get" : "vim", - "pacman" : "vim", - "brew" : "vim", - "yum" : "vim" - }, - "python" : { - "apt-get" : "python", - "pacman" : "python2" - }, - "python2" : { - "apt-get" : "python", - "pacman" : "python2" - }, - "python3" : { - "apt-get" : "python3", - "pacman" : "python" - }, - "tinc" : { - "apt-get" : "tinc", - "yaourt" : "tinc" - }, - "python-notify" : { - "pacman" : "python-notify", - "apt-get" : "python-notify" - }, - "python-dbus" : { - "pacman" : "dbus-python", - "apt-get" : "python-dbus" - }, - "w3m" : { - "pacman" : "w3m", - "apt-get" : "w3m" - }, - "make" : { - "pacman" : "make", - "apt-get" : "make" - }, - "perl-xml-simple" : { - "apt-get" : "libxml-simple-perl", - "pacman" : "perl-xml-simple" - }, - "hostname" : { - "pacman" : "inetutils", - "apt-get" : "hostname" - }, - "pip" : { - "pacman" : "python-pip", - "apt-get" : "python-pip" - } -} diff --git a/punani/tightnani/tinani b/punani/tightnani/tinani deleted file mode 100755 index 8caf669e..00000000 --- a/punani/tightnani/tinani +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/bash -set -euf - -if [ $# -ne 2 ];then - echo "usage: `basename $0` (install|remove) PACKAGE" - exit 23 -fi - -PACKERS="yum!-y install remove -brew install remove -pacman!--noconfirm -S!--needed -Rcs -bauerbill!--noconfirm -S!--needed -Rcs -yaourt!--noconfirm -S!--needed -Rcs -packer!--noconfirm -S!--needed -Rcs -apt-get!--yes install remove -aptitude!--yes install remove" - -OIFS=$IFS -PACKER= -IFS=' -' - -TIGHTNANI_HOST="http://euer.krebsco.de:9111" -# Find suitable packer -for PACKER_LINE in $PACKERS; do - TRY_PACKER_CMD="$(echo "$PACKER_LINE" | cut -d ' ' -f 1)" - TRY_PACKER="$(echo "$TRY_PACKER_CMD" | cut -d '!' -f 1)" - if which $TRY_PACKER &>/dev/null; then - PACKER=$TRY_PACKER - PACKER_CMD="$(echo "$TRY_PACKER_CMD" | tr "!" " ")" - echo "you got $PACKER" - INSTALL_PARAM="$(echo "$PACKER_LINE" | cut -d ' ' -f 2 | tr "!" " ")" - REMOVE_PARAM="$(echo "$PACKER_LINE" | cut -d ' ' -f 3 | tr "!" " ")" - fi -done -IFS=$OIFS -if [ ! "$PACKER" ];then - echo "Could not find a supported packer for you, bailing out!" - exit 23 -fi - - -# find the package name -PKG="$2" -RESOLVED=`wget -O- $TIGHTNANI_HOST/$PACKER/$PKG 2>/dev/null` -if [ ! "$RESOLVED" ];then - echo "Could not resolve your requested package, bailing out!" - exit 23 -fi -case "$1" in - install) - exec $PACKER_CMD $INSTALL_PARAM $RESOLVED - ;; - remove) - exec $PACKER_CMD $REMOVE_PARAM $RESOLVED - ;; - *) - echo "usage: `basename $0` (install|remove) PACKAGE" -esac -- cgit v1.2.3 From d5c9e86506c4a62d75f958a1c82e943b1b33ad81 Mon Sep 17 00:00:00 2001 From: EUcancER Date: Thu, 17 Nov 2011 11:19:21 +0100 Subject: //punani: add README describing the current functionality --- punani/README.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 punani/README.md diff --git a/punani/README.md b/punani/README.md new file mode 100644 index 00000000..1b70eab7 --- /dev/null +++ b/punani/README.md @@ -0,0 +1,30 @@ +Overview +======= +Punani is a meta packagemanager comprising a server which resolves package +requests and a client containing the logic to find the best suitable packer +on the host system. Packagenames in Punani are binaries in the PATH. All +library packages are named in the Principle of Least Surprise[1]. Different +package names can resolve into the same package. + +If you want to install the `hostname` tool, the query is + punani install hostname +on an archlinux this will result in the call : + pacman --noconfirm -Sy --needed inetutils + +[1] http://de.wikipedia.org/wiki/Principle_of_Least_Surprise + +Punani Client +============ +The punani client will determine which packer are available on the system +and then send a request to the punani server to find out how the given +package is called with the given packer. In addition to that, the client +will add flags to the packers call in order to install packages only when +needed and disable user interaction. + +Punani Server +============ + +The punani server is a web-service which resolves request in the following +manner: + localhost/$packer/$package +The result is the package-name with the given packer or 404 if not found. -- cgit v1.2.3