Hi List,

The attached patch fixes a TODO in lib-pacman of aif.
Instead of hardcoding that `core' is always available locally and falling back to net for others, it now checks /src/ for repos.

It assumes repos are stored at /src/$repo/pkg/. All these repos are added as cache dirs.

While preparing pacman, a number of repo names are provided to be prepared.

All those repos which were requested are added as actual repo. If this repo is available locally, the url points to disk. Otherwise it falls back to the mirrorlist.

Please let me know what you think.

Greetings/Groetjes

Mark Pustjens

--
Currently there's five machines permanently networked here. They *all*
contain the serious core stuff. A couple of the machines are pensioned off
486s, with little other value now. Plus there's two Jaz drives in the
building and the portable also carries a fair amount of stuff. Plus every
Friday a man comes around and carves all the new stuff onto stone slabs and
buries them in the garden... I think I'm okay.
  (alt.fan.pratchett)
diff -u -Naur aif-2009.08.07/src/core/libs/lib-pacman.sh 
aif-2009.08.07-new/src/core/libs/lib-pacman.sh
--- aif-2009.08.07/src/core/libs/lib-pacman.sh  2009-08-07 21:25:04.000000000 
+0200
+++ aif-2009.08.07-new/src/core/libs/lib-pacman.sh      2010-02-19 
22:12:33.000000000 +0100
@@ -62,25 +62,34 @@
        [ "$var_PKG_SOURCE_TYPE" = "cd" ] && local serverurl="${var_FILE_URL}"
        [ "$var_PKG_SOURCE_TYPE" = "net" ] && local serverurl="${var_SYNC_URL}"
 
-       [ -z "$1" ] && repos=core
-       [ -n "$1" ] && repos="$@"
-       # Setup a pacman.conf in /tmp
-       cat << EOF > /tmp/pacman.conf
-[options]
-CacheDir = ${var_TARGET_DIR}/var/cache/pacman/pkg
-CacheDir = /src/core/pkg
-EOF
-
-for repo in $repos
-do
-       #TODO: this is a VERY, VERY dirty hack.  we fall back to net for any 
non-core repo because we only have core on the CD. also user maybe didn't pick 
a mirror yet
-       if [ "$repo" != core ]
-       then
-               add_pacman_repo target ${repo} "Include = $var_MIRRORLIST"
+       if [ -z "$1" ]; then
+               repos="core"
        else
-               add_pacman_repo target ${repo} "Server = 
${serverurl/\$repo/$repo}" # replace literal '$repo' in the serverurl string by 
"$repo" where $repo is our variable.
+               repos="$@"
        fi
-done
+
+       # We make the assumption that /src/ contains a number of directories, 
each
+       # of which contains a package repository under subdir `pkg'.
+       # Eg: /src/core/pkg is a package repository.
+       local_repos=`ls /src/`
+
+       # Setup a pacman.conf in /tmp
+       echo "[options]" > /tmp/pacman.conf
+       echo "CacheDir = ${var_TARGET_DIR}/var/cache/pacman/pkg" >> 
/tmp/pacman.conf
+       for repo in ${local_repos}; do
+               echo "CacheDir = /src/${repo}/pkg" >> /tmp/pacman.conf
+       done
+
+       # Add each repo to the config file
+       # If the repo is available locally, add a local url, otherwise refer to 
the mirrorlist.
+       for repo in ${repos}; do
+               if echo "${local_repos}" | grep "^${repo}$" >/dev/null ;then
+                       add_pacman_repo target ${repo} "Server = 
file:///src/${repo}/pkg"
+               else
+                       add_pacman_repo target ${repo} "Include = 
${var_MIRRORLIST}"
+               fi
+       done
+
        # Set up the necessary directories for pacman use
        [ ! -d "${var_TARGET_DIR}/var/cache/pacman/pkg" ] && mkdir -m 755 -p 
"${var_TARGET_DIR}/var/cache/pacman/pkg"
        [ ! -d "${var_TARGET_DIR}/var/lib/pacman" ] && mkdir -m 755 -p 
"${var_TARGET_DIR}/var/lib/pacman"

Reply via email to