summaryrefslogtreecommitdiffstats
path: root/build_tools/l7/cachepacs
diff options
context:
space:
mode:
Diffstat (limited to 'build_tools/l7/cachepacs')
-rwxr-xr-xbuild_tools/l7/cachepacs140
1 files changed, 140 insertions, 0 deletions
diff --git a/build_tools/l7/cachepacs b/build_tools/l7/cachepacs
new file mode 100755
index 0000000..3e4a1fb
--- /dev/null
+++ b/build_tools/l7/cachepacs
@@ -0,0 +1,140 @@
+#! /bin/bash
+#
+# cachepacs - install pkgs to cache dir, but don't isntall
+#
+# Author: James Meyer (based on inpacs)
+
+
+# Working directory:
+TMPDIR=/tmp/inpacs$$
+# File containing (filtered) list of base packages + added packages
+basepacks=${TMPDIR}/basepacks
+
+APP="$( basename $0 )"
+
+exitfunc () {
+ # Remove temporary files
+ rm -rf ${TMPDIR}
+ exit $1
+}
+
+# Default pacman db path (this is a statement, not a configuration, so
+# do not change it!)
+DBPATH="/var/lib/pacman"
+
+# Default package cache, on the target
+TARGETCACHE="${CACHE}"
+# A host or remote package cache:
+HOSTCACHE=""
+# Absolute /path/to/file containing list of packages for 2nd install phase:
+ADDEDPACKS=""
+# Source file for base package list:
+BASEPACKSFILE=""
+# Source file for list of vetoed base packages:
+VETOFILE=""
+# Source directory for pacman database directories:
+DBDIR=""
+# pacman executable:
+PACMANX="pacman -f"
+# pacman configuration file
+PACMANK="/etc/pacman.conf"
+
+checkfile ()
+{
+ f=$( readlink -m $1 )
+ if ! [ -f "${f}" ]; then
+ echo "ERROR: File doesn't exist: ${f}"
+ exitfunc
+ fi
+}
+
+checkdir ()
+{
+ f=$( readlink -m $1 )
+ if ! [ -d "${f}" ]; then
+ echo "ERROR: Directory doesn't exist: ${f}"
+ exitfunc
+ fi
+}
+
+
+while getopts ":k:a:c:b:x:y:P:" Option
+do
+ case ${Option} in
+ k ) checkfile ${OPTARG}
+ PACMANK=${f} ;;
+ a ) checkfile ${OPTARG}
+ CACHEPACKSFILE=${f} ;;
+ y ) checkdir ${OPTARG}
+ DBDIR=${f} ;;
+ P ) checkfile ${OPTARG}
+ PACMANX=${f} ;;
+ #* ) usage ;;
+ esac
+done
+shift $((${OPTIND} - 1))
+INSTLDIR="$1"
+
+
+# grep the cachedir out of the installed pacman.conf
+PCCACHE=`grep CacheDir $INSTLDIR/etc/pacman.conf|cut -d= -f2|cut -d\/ -f2-`
+CACHEDIR=${INSTLDIR}/$PCCACHE
+
+echo "INSTLDIR=${INSTLDIR}"
+echo "PACMANK=${PACMANK}"
+echo "CACHEDIR=${CACHEDIR}"
+echo "DBDIR=${DBDIR}"
+echo "PACMANX=${PACMANX}"
+echo
+
+
+# test if the script is started by root user. If not, exit
+if [ $UID -ne 0 ]; then
+ echo "Only root can run ${APP}"; exitfunc 1
+fi
+
+echo "//"
+echo "// downloading packages to ${CACHEDIR}"
+
+PACMAN="${PACMANX} --config ${PACMANK} --noconfirm"
+
+rm -rf ${TMPDIR}
+mkdir -p ${TMPDIR}
+
+# Helper function for installing a list of packages
+doInstall() {
+ mkdir -p ${INSTLDIR}/sys
+ mkdir -p ${INSTLDIR}/proc
+ mount --bind /sys ${INSTLDIR}/sys
+ mount --bind /proc ${INSTLDIR}/proc
+ ${PACMAN} -r ${INSTLDIR} -Sw $1
+ RET=$?
+ echo $RET
+ umount ${INSTLDIR}/proc
+ umount ${INSTLDIR}/sys
+ if [ ${RET} -ne 0 ]; then
+ echo "//"
+ echo "// cachepacks package $1 FAILED."
+ echo "//"
+ return 1
+ fi
+}
+
+
+PACMAN="${PACMAN} --cachedir $CACHEDIR"
+
+########## GET LIST OF CACHE PACKAGES
+echo "//"
+echo "// ** Getting cache package list ..."
+if [ -n "${CACHEPACKSFILE}" ]; then
+ echo "// from: ${CACHEPACKSFILE}"
+ CACHEPKGS=$( cat ${CACHEPACKSFILE} | grep -v "#" )
+else
+ echo " no cache package file found"
+ exit 0
+fi
+
+
+doInstall "${CACHEPKGS}"
+if [ $? -ne 0 ]; then exitfunc 1; fi
+exitfunc