diff options
Diffstat (limited to 'base/pkg-get/pkg-get.awk')
-rwxr-xr-x | base/pkg-get/pkg-get.awk | 148 |
1 files changed, 102 insertions, 46 deletions
diff --git a/base/pkg-get/pkg-get.awk b/base/pkg-get/pkg-get.awk index d8e526a80..1d0d4bb38 100755 --- a/base/pkg-get/pkg-get.awk +++ b/base/pkg-get/pkg-get.awk @@ -13,8 +13,8 @@ function configs( a, i, k, n, old_FS) { n=split(ENVIRON["_"],a,"/") NPKG = a[n] - VERSION = "0.3.2" - DATE = "2011-03-11" + VERSION = "0.3.3" + DATE = "2011-04-03" # defauts CONF = "/etc/pkg-get.conf" @@ -96,6 +96,22 @@ function configs( a, i, k, n, old_FS) # i18n TEXTDOMAIN = "pkg-get" bindtextdomain("/usr/share/locale") + + # msg + RED=31 + GREEN=32 + YELLOW=33 +# BLUE=34 +# MAGENTA=35 + CYAN=36 +# WHITE=37 + + tbColor["OK"] = GREEN + tbColor["ERR"] = RED + tbColor["INFO"] = CYAN + +# COL = system("exit $(stty size | cut -d' ' -f2)") - 6 + COL = 24 } @@ -221,19 +237,21 @@ function download(pak, a, WEBREPO, fnPak, cmd, rc, pakw) if ((getline < fnPak) <=0) { pakw = pak sub("#", "%23", pakw) - cmd="wget --no-directories --tries=3 --waitretry=3 -nv --directory-prefix="tb_PKGDIR[a[1]] " " WEBREPO pakw + cmd="wget --no-directories --tries=3 --waitretry=3 -nv --directory-prefix="tb_PKGDIR[a[1]] " " WEBREPO pakw " >/dev/null 2>&1" if ("--dry" in tb_OPT) { - print "\033[1;34m" cmd "\033[1;0m" + print " " cmd + return 8 } else { rc=system(cmd) if (rc>0) { - print "ERREUR", rc - exit 1 + return 1 } if (!("-im" in tb_OPT)) verif_md5sum(tb_PKGDIR[a[1]], pak) + return 0 } - } + } else + return 9 } @@ -345,48 +363,71 @@ function install( i) } -function install2_update2(Pkg, Oper, cmd, i, pak) +function install2_update2(Pkg, Oper, cmd, i, pak, rc, st) { + printPkg(Pkg"#"tb_REPO[Pkg]) + if (!(Pkg in tb_REPO)) { print "\033[1;31m" _"Paquet" " " Pkg " " _"indisponible" "\033[1;0m" return } if (tb_REPO[Pkg] != "" ) { pak=Pkg"#"tb_REPO[Pkg] ".pkg.tar.xz" - download(pak) + printOper("Téléchargement") + rc = download(pak) + if (!("--dry" in tb_OPT)) { + if (rc==0) st="OK" + else if (rc==1) st="ERR" + else if (rc==9) st="OLD" + else st="" + printStatus(st) + } } if ("-do" in tb_OPT) return - print _"Installation de" " " Pkg - if (PRE=="y" && tb_PRE[Pkg]=="yes") { # pre-install - cmd = "/bin/bash " tb_PKGDIR[Pkg] "/PKGINST " Pkg "_pre_install" + + if (PRE=="y" && tb_PRE[Pkg]=="yes") { + printOper("Pré-installation") + cmd = "/bin/bash " tb_PKGDIR[Pkg] "PKGINST " Pkg "_pre_install" if ("--dry" in tb_OPT) { - print "\033[1;33m" cmd "\033[1;0m" + print " " cmd } else { - while ((cmd | getline) >0) - print - close(cmd) + rc = system(cmd) +# while ((cmd | getline) >0) +# print +# close(cmd) + st = (rc==0) ? "OK" : "ERR" + printStatus(st) } } + + printOper("Installation") cmd = "pkgadd " AARGS " " Oper " " tb_PKGDIR[Pkg] pak # Oper==" " : insert ; Oper=="-u" : update if ("--dry" in tb_OPT) { - print "\033[1;37m" cmd "\033[1;0m" + print " " cmd } else { - while ((cmd | getline) >0) - print - close(cmd) + rc = system(cmd) +# while ((cmd | getline) >0) +# print +# close(cmd) + st = (rc==0) ? "OK" : "ERR" + printStatus(st) } tb_DB[Pkg]=tb_REPO[Pkg] - if (POST=="y" && tb_POST[Pkg]=="yes") { # post-install - cmd = "/bin/bash " tb_PKGDIR[Pkg] "/PKGINST " Pkg "_post_install" + if (POST=="y" && tb_POST[Pkg]=="yes") { + printOper("Post-installation") + cmd = "/bin/bash " tb_PKGDIR[Pkg] "PKGINST " Pkg "_post_install" if ("--dry" in tb_OPT) { - print "\033[1;33m" cmd "\033[1;0m" + print " " cmd } else { - while ((cmd | getline) >0) - print - close(cmd) + rc = system(cmd) +# while ((cmd | getline) >0) +# print +# close(cmd) + st = (rc==0) ? "OK" : "ERR" + printStatus(st) } } } @@ -559,13 +600,28 @@ function printff() } +function printOper(texte) { + printf " %-" COL-4 "s%s", texte, "..." +} + + +function printPkg(pkg) { + printf "\033[1;%dm%s\033[0m\n", YELLOW, pkg +} + + +function printStatus(status) { + printf "\033[%dG\033[1;%dm%-4s\033[0m\n", COL, tbColor[status], status +} + + function quickdep() { - load_DB() - load_DEPS() - load_REPO() - quickdep2(PKG) - printf ("%s\n",PKG) + load_DB() + load_DEPS() + load_REPO() + quickdep2(PKG) + printf ("%s\n",PKG) } @@ -607,21 +663,21 @@ function quickdiff(Dest, a, i, n, pak) function quickhelp() { - print "\033[1;33m" _"Usage" "\033[1;0m: " NPKG " command <package1> [package2 ... packageN] [options]" - print "\033[1;33m" _"Quelques commandes" "\033[1;0m:" - print " sync " _"synchronise avec le dépôt" - print " depinst " _"installe package(s) et ses(leurs) dépendances" - print " info " _"informations concernant le package" - print " sysup " _"met à jour les paquets obsolètes" - print " diff " _"affiche la liste des paquets obsolètes" - print "\033[1;33m" _"Quelques options:" "\033[1;0m" - print " -do " _"télécharge seulement" - print " --install-scripts " _"utilise les scripts install" - print " -r <root> " _"utilise" " <root> " _"pour" " pkgadd" - print "\033[1;33m" _"Examples" "\033[1;0m:" - print " " NPKG " install sqlite pysqlite" - print " " NPKG " help" - print _"Pour d'autres commandes et examples, voir la page de manuel" + print "\033[1;33m" _"Usage" "\033[1;0m: " NPKG " command <package1> [package2 ... packageN] [options]" + print "\033[1;33m" _"Quelques commandes" "\033[1;0m:" + print " sync " _"synchronise avec le dépôt" + print " depinst " _"installe package(s) et ses(leurs) dépendances" + print " info " _"informations concernant le package" + print " sysup " _"met à jour les paquets obsolètes" + print " diff " _"affiche la liste des paquets obsolètes" + print "\033[1;33m" _"Quelques options:" "\033[1;0m" + print " -do " _"télécharge seulement" + print " --install-scripts " _"utilise les scripts install" + print " -r <root> " _"utilise" " <root> " _"pour" " pkgadd" + print "\033[1;33m" _"Examples" "\033[1;0m:" + print " " NPKG " install sqlite pysqlite" + print " " NPKG " help" + print _"Pour d'autres commandes et examples, voir la page de manuel" } |