From 5e2a1dc9fa7573a30d2b2b14cfd82f8e67b1a6d2 Mon Sep 17 00:00:00 2001 From: guy Date: Sat, 19 Feb 2011 18:58:22 +0100 Subject: pkg-get-awk, check md5sum et corrections diverses --- base/pkg-get-awk/Pkgfile | 4 +- base/pkg-get-awk/pkg-get.awk | 139 ++++++++++++++++++++++++++++--------------- base/pkg-get-awk/pkg-get.po | 15 +++++ 3 files changed, 107 insertions(+), 51 deletions(-) diff --git a/base/pkg-get-awk/Pkgfile b/base/pkg-get-awk/Pkgfile index 25cacd217..166c20f61 100644 --- a/base/pkg-get-awk/Pkgfile +++ b/base/pkg-get-awk/Pkgfile @@ -5,8 +5,8 @@ # Depends on: gawk name=pkg-get-awk -version=0.3.1 -release=4 +version=0.3.2 +release=1 source=(syn pkg-get.awk pkg-get-awk.conf pkg-get.po) PKGMK_KEEP_LOCALES=yes diff --git a/base/pkg-get-awk/pkg-get.awk b/base/pkg-get-awk/pkg-get.awk index f7574c0b2..f2ec5cc48 100755 --- a/base/pkg-get-awk/pkg-get.awk +++ b/base/pkg-get-awk/pkg-get.awk @@ -13,17 +13,20 @@ function configs( a, i, k, n, old_FS) { n=split(ENVIRON["_"],a,"/") NPKG = a[n] - VERSION = "0.3.1" - DATE = "20110108" + VERSION = "0.3.2" + DATE = "2011-02-19" # defauts CONF = "/etc/pkg-get.conf" + VERSFILE = "/var/lib/pkg/nutyx-version" DB = "/var/lib/pkg/db" LOCKER = "/var/lib/pkg/pkg-get.locker" PRE = "n" POST = "n" PKGDIR[0] = "/srv/NuTyX/release/" - WEBDIR[0] = "http://nutyx.meticul.eu/pakxe/x86_64/release/" + load_NUTYX_VERSION() + "uname -p " | getline ENV; close("uname -p") + WEBDIR[0] = "http://nutyx.meticul.eu/" NUTYX_VERSION "/" ENV "/release/" # arguments OPER=(ARGC>1) ? ARGV[1] : "" @@ -78,11 +81,6 @@ function configs( a, i, k, n, old_FS) } FS=old_FS -# for (i=0; i0) + while ((cmd | getline) > 0) print + close(cmd) + if (!("-im" in tb_OPT)) + verif_md5sum(tb_PKGDIR[a[1]], pak) } } } @@ -333,37 +335,34 @@ function install( i) load_DB() load_REPO() for (i=1; i<=nPKG; i++) { - if (tb_PKG[i] in tb_DB) { - print _"Le paquet" " " tb_PKG[i] " " _"est déjà installé" - - } - else install2(tb_PKG[i], " ") + if (tb_PKG[i] in tb_DB) + print _"Le paquet" " " tb_PKG[i] " " _"est déjà installé" + else + install2_update2(tb_PKG[i], " ") } } -function install2(Pkg, Oper, cmd, i, pak) +function install2_update2(Pkg, Oper, cmd, i, pak) { - if (tb_REPO[Pkg] != "" ){ - pak=Pkg"#"tb_REPO[Pkg] ".pkg.tar.xz" - download(pak) - } + if (tb_REPO[Pkg] != "" ) { + pak=Pkg"#"tb_REPO[Pkg] ".pkg.tar.xz" + download(pak) + } if ("-do" in tb_OPT) return - load_DB() - if (Pkg in tb_DB) { - return - } - else { - print _"Installation de" " " Pkg - if (PRE=="y" && tb_PRE[Pkg]=="yes") { # pre-install - cmd = "/bin/bash " tb_PKGDIR[Pkg] "/PKGINST " Pkg "_pre_install" - if ("--dry" in tb_OPT) { - print "\033[1;33m" cmd "\033[1;0m" - } else { - while ((cmd | getline) >0) - print - close(cmd) +## load_DB() +## if (Pkg in tb_DB) +## 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 ("--dry" in tb_OPT) { + print "\033[1;33m" cmd "\033[1;0m" + } else { + while ((cmd | getline) >0) + print + close(cmd) } } cmd = "pkgadd " AARGS " " Oper " " tb_PKGDIR[Pkg] pak # Oper==" " : insert ; Oper=="-u" : update @@ -384,7 +383,6 @@ function install2(Pkg, Oper, cmd, i, pak) close(cmd) } } - } } @@ -496,6 +494,18 @@ function load_LOCKER() } +function load_NUTYX_VERSION( old_FS) +{ + old_FS = FS + FS = "-" + getline < VERSFILE + if ($1=="2010") NUTYX_VERSION = "attapu" + else if ($1=="2011") NUTYX_VERSION = "pakxe" + close(VERSFILE) + FS = old_FS +} + + function load_RDEPS( a, FILE, i, j, n) { for (j=0; j0) { n=split($3, a, ",") for (i=1; i<=n; i++) { - tb_RDEPS[a[i]] = (a[i] in tb_RDEPS) ? tb_RDEPS[a[i]] "," $1 : $1 +# tb_RDEPS[a[i]] = (a[i] in tb_RDEPS) ? tb_RDEPS[a[i]] "," $1 : $1 + if (a[i] in tb_RDEPS) { + if (!index(tb_RDEPS[a[i]],$1)) + tb_RDEPS[a[i]] = tb_RDEPS[a[i]] "," $1 + } else { + tb_RDEPS[a[i]] = $1 + } } } close(FILE) @@ -521,6 +537,7 @@ function load_REPO( FILE, j, old_FS) if (!($1 in tb_REPO)) { sub(".pkg.tar.xz","",$2) tb_REPO[$1] = $2 + tb_MD5[$1] = $4 tb_PRE[$1] = $6 tb_POST[$1] = $7 tb_READ[$1] = $8 @@ -717,10 +734,11 @@ function update( i) verif_if_root() load_LOCKER() load_REPO() + load_DB() ## for (i=1; i<=nPKG; i++) { if (!(tb_PKG[i] in tb_LOCK)) { print _"paquet à mettre à jour:" " " tb_PKG[i] - install2(tb_PKG[i], "-u") + install2_update2(tb_PKG[i], "-u") } } } @@ -740,6 +758,29 @@ function verif_if_root( cmd) } +function verif_md5sum(dir, pk, cmd, md5, a) +{ + cmd="md5sum " dir pk + cmd | getline + split($0,md5," ") + close(cmd) + split(pak,a,"#") + if (md5[1]!=tb_MD5[a[1]]) { + print "=======> " _"ERREUR" ": " _"md5sum erroné pour " a[1] + print _"requis" ": " tb_MD5[a[1]] + print _"trouvé" ": " md5[1] + if ((getline < fnPak) >= 0) { + cmd = "rm " fnPak + while ((cmd | getline) > 0) + print + close(cmd) + } + close(fnPak) + exit 1 + } +} + + function version() { print NPKG " " VERSION " (" DATE ")" diff --git a/base/pkg-get-awk/pkg-get.po b/base/pkg-get-awk/pkg-get.po index 76cf12173..6b1f82006 100644 --- a/base/pkg-get-awk/pkg-get.po +++ b/base/pkg-get-awk/pkg-get.po @@ -112,6 +112,9 @@ msgstr "The package" msgid "est install\303\251" msgstr "is installed" +msgid "est déjà install\303\251" +msgstr "is already installed" + msgid "n'est pas install\303\251" msgstr "isn't installed" @@ -177,3 +180,15 @@ msgstr "use" msgid "pour" msgstr "for" + +msgid "ERREUR" +msgstr "ERROR" + +msgid "md5sum erron\303\251 pour " +msgstr "md5sum mismatching for " + +msgid "requis" +msgstr "required" + +msgid "trouv\303\251" +msgstr "found" -- cgit v1.2.3-70-g09d2