# HG changeset patch # User Francisco J Ballesteros # Date 1316536663 -7200 # Node ID 065abf1e0379f8ab69174dce3fe469f3504cf47d # Parent 235e2af0b8d426fee0c51322f430f130afed8241 pm: multiple servers and sources in /sys/src This is a first attempt at having packages keep their source at /sys/src. To symplify, I left a root.tgz for devel/indent at lsub.org, so that if you list that server before, you'd get a package with the tar using /sys/src/cmd/... Now the changes... lib/ndb/local has entries that describe a list of servers for packages (tried in order). pm/pull has changed to try that list. Still defaults to the default, and honors the variable (which can now be alist) if set. pm/list has a new flag -l that lists the files for packages installed. To be used like pm/list -il devel/indent (or just pmlist -il). pm/install changed because it now says nothing regarding the source of the packages (either the caller or pull fixes that). the mkfile for sys/src/cmd includes in the list of std. dirs only those that have a file named "mkfile" in them. I think it's reasonable to assume that such packages obey the std. rules (i.e., have the std targets). If that's not the case, we could simply remove any mkfile to mkfile.checkme or whatever. I think that was all. It would be great if you could try before any submit. As I said, edit the ndb entry so that the first server listed is just "lsub.org" (but you can only retrieve devel/indent from there). R=john, nemo CC=nix-dev http://codereview.appspot.com/5040043 diff -r 235e2af0b8d4 -r 065abf1e0379 lib/ndb/local --- a/lib/ndb/local Tue Sep 20 22:01:24 2011 +0000 +++ b/lib/ndb/local Tue Sep 20 18:37:43 2011 +0200 @@ -12,3 +12,11 @@ # because the public demands the name localsource # ip=127.0.0.1 sys=localhost dom=localhost + +# +# pm(1) servers, tried in this order +# +pm=srvlist + srv=jfloren.net + srv=addonehere.com + srv=addanother.net diff -r 235e2af0b8d4 -r 065abf1e0379 rc/bin/pm/install --- a/rc/bin/pm/install Tue Sep 20 22:01:24 2011 +0000 +++ b/rc/bin/pm/install Tue Sep 20 18:37:43 2011 +0200 @@ -10,10 +10,6 @@ ROOT=/ } -if (~ $#PKGSERVER 0) { - PKGSERVER=jfloren.net -} - USAGE='usage: install [-v] [-f] package' flagfmt='v,f' diff -r 235e2af0b8d4 -r 065abf1e0379 rc/bin/pm/list --- a/rc/bin/pm/list Tue Sep 20 22:01:24 2011 +0000 +++ b/rc/bin/pm/list Tue Sep 20 18:37:43 2011 +0200 @@ -20,9 +20,10 @@ ' # set ifs in case it is munged in user's environment VERBOSE=0 +LISTING=0 -USAGE='usage: list [-v] [-i] [category]' -flagfmt='v,i' +USAGE='usage: list [-v] [-i] [-l] [category]' +flagfmt='v,i,l' if(! ifs=() eval `{aux/getflags $*}) { echo $USAGE @@ -31,14 +32,23 @@ if (! ~ $#flagv 0) VERBOSE=1 if (! ~ $#flagi 0) INSTALLED=1 +if (! ~ $#flagl 0) LISTING=1 fn doprint { if (~ $VERBOSE 1) echo -n '• ' - echo $1 + if( ~ $LISTING 1) + echo $1: + if not + echo $1 if (~ $VERBOSE 1) { cat $1^/README echo '======================' } + if (~ $LISTING 1){ + sed -e 's,^root,,' $ROOT/contrib/packages/$1/root.lst | + grep -v '/$' + echo + } } if (! test -e $ROOT^/contrib/packages/installed) { @@ -61,7 +71,7 @@ } } } - exit + exit '' } if not { if (~ $#* 0) { @@ -81,6 +91,7 @@ } } } - exit + exit '' } } +exit '' diff -r 235e2af0b8d4 -r 065abf1e0379 rc/bin/pm/pull --- a/rc/bin/pm/pull Tue Sep 20 22:01:24 2011 +0000 +++ b/rc/bin/pm/pull Tue Sep 20 18:37:43 2011 +0200 @@ -11,7 +11,9 @@ } if (~ $#PKGSERVER 0) { - PKGSERVER=jfloren.net + PKGSERVER=`{ndb/query -a pm srvlist srv} + if(~ $#PKGSERVER 0 ) + PKGSERVER=jfloren.net } fn fail { @@ -23,7 +25,7 @@ fail Need at least one package name } -cd $PKGROOT^/contrib/packages || exit 'dir not found' +cd $PKGROOT^/contrib/packages || fail 'dir not found' names=() for(name in $*) { if(~ $name */*){ @@ -36,11 +38,18 @@ for (PKGNAME in $names) { @{ # Go to the directory if it exists - cd $PKGROOT^/contrib/packages/^$PKGNAME || fail $PKGNAME: No such package in $PKGROOT^/contrib/packages - - echo -n Fetching root.tgz... - hget -o root.tgz http://^$PKGSERVER^/contrib/packages/^$PKGNAME^/root.tgz || fail hget failed - echo Done. + if(! cd $PKGROOT^/contrib/packages/^$PKGNAME) + fail $PKGNAME: No such package in $PKGROOT^/contrib/packages + + { + for(p in $PKGSERVER){ + echo '{' echo $PKGNAME: retrieving from $p... + echo hget -o root.tgz \ + http://$p/contrib/packages/$PKGNAME/root.tgz ' }||' + } + echo exit no + } | rc || fail $PKGNAME: cannot download from known servers + echo $PKGNAME: retrieved } } exit ''