From 49346f3cd4efcb1a9ffca4f6fd4eb33fe52fb493 Mon Sep 17 00:00:00 2001 From: Eric Hameleers Date: Sun, 14 Feb 2016 18:00:10 +0100 Subject: Download packages from rsync mirror if local repository is empty. This is for package lists in "pkglist/" subdirectory where a 3rd party repository is the package source. If the pkglists/*.conf file defines a rsync mirror URL in variable SL_REPO_URL, then instead of aborting with an error when the local repository directory (SL_REPO) is empty or non-existing, the packages will be downloaded from that mirror before continuing. --- make_slackware_live.sh | 27 ++++++++++++++++++++++++--- pkglists/alien.conf | 4 ++++ pkglists/mate.conf | 5 ++++- pkglists/plasma5.conf | 6 +++++- 4 files changed, 37 insertions(+), 5 deletions(-) diff --git a/make_slackware_live.sh b/make_slackware_live.sh index 5f4b30a..c76e31d 100755 --- a/make_slackware_live.sh +++ b/make_slackware_live.sh @@ -127,11 +127,14 @@ fi # You can define custom repository location (must be in local filesystem) # for any module in the file ./pkglists/.conf: SL_REPO=${SL_REPO:-"/mnt/auto/sox/ftp/pub/Linux/Slackware"} +DEF_SL_REPO=${SL_REPO} # Package root directory: SL_PKGROOT=${SL_REPO}/slackware${DIRSUFFIX}-${SL_VERSION}/slackware${DIRSUFFIX} +DEF_SL_PKGROOT=${SL_PKGROOT} # Patches root directory: SL_PATCHROOT=${SL_REPO}/slackware${DIRSUFFIX}-${SL_VERSION}/patches/packages +DEF_SL_PATCHROOT=${SL_PATCHROOT} # List of Slackware package series - each will become a squashfs module: SEQ_SLACKWARE="tagfile:a,ap,d,e,f,k,kde,kdei,l,n,t,tcl,x,xap,xfce,y pkglist:slackextra" @@ -227,6 +230,11 @@ function install_pkgs() { exit 1 fi + # Define the default Slackware repository, can be overridden here: + SL_REPO="${DEF_SL_REPO}" + SL_PKGROOT="${DEF_SL_PKGROOT}" + SL_PATCHROOT="${DEF_SL_PATCHROOT}" + if [ "$3" = "local" -a -d ${LIVE_TOOLDIR}/local${DIRSUFFIX}/$1 ]; then echo "-- Installing local packages from subdir 'local${DIRSUFFIX}/$1'." installpkg --terse --root "$2" "local${DIRSUFFIX}/$1/*.t?z" @@ -252,9 +260,22 @@ function install_pkgs() { exit 1 fi - if [ ! -d ${SL_REPO} ]; then - echo "-- Slackware repository root '${SL_REPO}' does not exist! Exiting." - exit 1 + if [ ! -d ${SL_REPO} -o -z "$(find ${SL_REPO} -maxdepth 1 -type f)" ]; then + # Oops... empty local repository. Let's see if we can rsync from remote: + RRES=1 + if [ -n "${SL_REPO_URL}" ]; then + mkdir -p ${SL_REPO} + # Must be a rsync URL! + echo "-- Rsync-ing repository content from '${SL_REPO_URL}' to local directory '${SL_REPO}'..." + echo "-- This can be time-consuming. Please wait." + rsync -rlptD --no-motd ${SL_REPO_URL}/ ${SL_REPO}/ + RRES=$? + echo "-- Done rsync-ing from '${SL_REPO_URL}'." + fi + if [ $RRES -ne 0 ]; then + echo "** Slackware repository root '${SL_REPO}' does not exist or is empty! Exiting." + exit 1 + fi fi for PKG in $(cat ${PKGFILE} |grep -v -E '^ *#|^$' |cut -d: -f1); do diff --git a/pkglists/alien.conf b/pkglists/alien.conf index df43eb3..4b527b2 100644 --- a/pkglists/alien.conf +++ b/pkglists/alien.conf @@ -1,3 +1,7 @@ +# If 'SL_REPO_URL' is a rsync:// URL and 'SL_REPO' points to a non-existent +# or empty directory, then the content of 'SL_REPO_URL' will be rsync-ed +# to the local directory 'SL_REPO'. +SL_REPO_URL="rsync://slackware.uk/people/alien/sbrepos/${SL_VERSION}/${SL_ARCH}" SL_REPO="/mnt/auto/sox/sbrepos/${SL_VERSION}/${SL_ARCH}" # Package root directory: diff --git a/pkglists/mate.conf b/pkglists/mate.conf index 24ca26c..dd21769 100644 --- a/pkglists/mate.conf +++ b/pkglists/mate.conf @@ -1,4 +1,7 @@ -# Repository: http://slackware.uk/msb/testing/1.12/x86_64/ +# If 'SL_REPO_URL' is a rsync:// URL and 'SL_REPO' points to a non-existent +# or empty directory, then the content of 'SL_REPO_URL' will be rsync-ed +# to the local directory 'SL_REPO'. +SL_REPO_URL="rsync://slackware.uk/msb/testing/1.12/${SL_ARCH}/" SL_REPO="/mnt/auto/sox/ftp/pub/Linux/Slackware/msb/testing/1.12/${SL_ARCH}" # Package root directory: diff --git a/pkglists/plasma5.conf b/pkglists/plasma5.conf index 05904a9..49e51ef 100644 --- a/pkglists/plasma5.conf +++ b/pkglists/plasma5.conf @@ -1,4 +1,8 @@ -SL_REPO="/mnt/auto/sox/data/slackware/ktown/${SL_VERSION}/testing/${SL_ARCH}" +# If 'SL_REPO_URL' is a rsync:// URL and 'SL_REPO' points to a non-existent +# or empty directory, then the content of 'SL_REPO_URL' will be rsync-ed +# to the local directory 'SL_REPO'. +SL_REPO_URL="rsync://slackware.uk/people/alien-kde/${SL_VERSION}/5/${SL_ARCH}" +SL_REPO="/mnt/auto/sox/data/slackware/ktown/${SL_VERSION}/5/${SL_ARCH}" # Package root directory: SL_PKGROOT=${SL_REPO} -- cgit v1.2.3