From e7826e4107dc5b7e01b3b1337eaff4939d5229b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Walter=20H=C3=BCttenmeyer?= Date: Sun, 4 Aug 2019 12:38:45 +0200 Subject: [PATCH 1/3] add new portage paths added /var/db/repos/gentoo and /var/cache/distfiles to hard-coded list of excludes. Portage has moved (when?) according to https://wiki.gentoo.org/wiki//usr/portage --- mkstage4.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mkstage4.sh b/mkstage4.sh index d695c76..81fda1a 100755 --- a/mkstage4.sh +++ b/mkstage4.sh @@ -147,7 +147,9 @@ EXCLUDES="\ --exclude=${TARGET}var/lock/* \ --exclude=${TARGET}var/log/* \ --exclude=${TARGET}var/run/* \ ---exclude=${TARGET}var/lib/docker/*" +--exclude=${TARGET}var/lib/docker/* \ +--exclude=${TARGET}var/db/repos/gentoo/* \ +--exclude=${TARGET}var/cache/distfiles/*" EXCLUDES+=$USER_EXCL From ac688d0b970e28c9584cef8d72c678eeb5fff965 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Walter=20H=C3=BCttenmeyer?= Date: Sun, 4 Aug 2019 22:28:22 +0200 Subject: [PATCH 2/3] Added portageq logic Added portageq logic to detect where portage stores its tree and distfiles. If this fails, fall back to a default list declared in EXCLUDES_DEFAULT_PORTAGE --- mkstage4.sh | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/mkstage4.sh b/mkstage4.sh index 81fda1a..8c34f9e 100755 --- a/mkstage4.sh +++ b/mkstage4.sh @@ -16,6 +16,13 @@ USER_EXCL="" S_KERNEL=0 x86_64=0 PARALLEL=0 +HAS_PORTAGEQ=0 + +if [ `which portageq` ] +then + HAS_PORTAGEQ=1 +fi + if [ `getconf LONG_BIT` = "64" ] then x86_64=1 @@ -143,20 +150,30 @@ EXCLUDES="\ --exclude=${TARGET}run/* \ --exclude=${TARGET}sys/* \ --exclude=${TARGET}tmp/* \ ---exclude=${TARGET}usr/portage/* \ --exclude=${TARGET}var/lock/* \ --exclude=${TARGET}var/log/* \ --exclude=${TARGET}var/run/* \ ---exclude=${TARGET}var/lib/docker/* \ ---exclude=${TARGET}var/db/repos/gentoo/* \ ---exclude=${TARGET}var/cache/distfiles/*" +--exclude=${TARGET}var/lib/docker/* " +EXCLUDES_DEFAULT_PORTAGE="\ + --exclude=${TARGET}var/db/repos/gentoo/* \ + --exclude=${TARGET}var/cache/distfiles/* \ + --exclude=${TARGET}usr/portage/*" EXCLUDES+=$USER_EXCL if [ "$TARGET" == "/" ] then EXCLUDES+=" --exclude=${STAGE4_FILENAME#/}" + if [ ${HAS_PORTAGEQ} == 1 ] + then + EXCLUDES+=" --exclude=$(portageq get_repo_path / gentoo)/*" + EXCLUDES+=" --exclude=$(portageq distdir)/*" + else + EXCLUDES+="${EXCLUDES_DEFAULT_PORTAGE}" + fi +else + EXCLUDES+="${EXCLUDES_DEFAULT_PORTAGE}" fi if [ ${EXCLUDE_CONNMAN} -eq 1 ] From 447e108ef09d8743d955554f4ffc7c1a55366fc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Walter=20H=C3=BCttenmeyer?= Date: Thu, 22 Aug 2019 20:11:16 +0200 Subject: [PATCH 3/3] loop through excludes added a loop to create the '--exclude foo' options from an array list. This way it's less copy-paste to add a new static exclude; it _would_ also be possible to check if the 'object-to-exclude' actually exists and only generate the exclude parameter in this case. --- mkstage4.sh | 75 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 44 insertions(+), 31 deletions(-) diff --git a/mkstage4.sh b/mkstage4.sh index 8c34f9e..a54a25d 100755 --- a/mkstage4.sh +++ b/mkstage4.sh @@ -129,66 +129,73 @@ shift;OPTIONS="$@" if [ ${S_KERNEL} -eq 1 ] then - USER_EXCL+=" --exclude=${TARGET}usr/src/* " + EXCLUDES_LIST+=" usr/src/*" if [ ${x86_64} -eq 1 ] then - USER_EXCL+=" --exclude=${TARGET}lib64/modules/* " + EXCLUDES_LIST+=" lib64/modules/*" else - USER_EXCL+=" --exclude=${TARGET}lib/modules/* " + EXCLUDES_LIST+=" lib/modules/*" fi fi -# Excludes: -EXCLUDES="\ ---exclude=${TARGET}home/*/.bash_history \ ---exclude=${TARGET}dev/* \ ---exclude=${TARGET}var/tmp/* \ ---exclude=${TARGET}media/* \ ---exclude=${TARGET}mnt/*/* \ ---exclude=${TARGET}proc/* \ ---exclude=${TARGET}run/* \ ---exclude=${TARGET}sys/* \ ---exclude=${TARGET}tmp/* \ ---exclude=${TARGET}var/lock/* \ ---exclude=${TARGET}var/log/* \ ---exclude=${TARGET}var/run/* \ ---exclude=${TARGET}var/lib/docker/* " +# Excludes - whitespace delimited list of things to leave out +EXCLUDES_LIST=" + home/*/.bash_history\ + dev\ + var/tmp\ + media\ + mnt\ + proc\ + run\ + sys\ + tmp\ + var/lock\ + var/log\ + var/run\ + var/lib/docker" -EXCLUDES_DEFAULT_PORTAGE="\ - --exclude=${TARGET}var/db/repos/gentoo/* \ - --exclude=${TARGET}var/cache/distfiles/* \ - --exclude=${TARGET}usr/portage/*" +EXCLUDES_DEFAULT_PORTAGE=" + var/db/repos/gentoo/*\ + usr/portage*\ + var/cache/distfiles/*" + +# Excludes function - create tar --exclude=foo options +exclude() +{ + ADDEXCLUDE=$(echo "$1" | sed 's/^\///') + EXCLUDES+=" --exclude=${TARGET}${ADDEXCLUDE}" +} EXCLUDES+=$USER_EXCL if [ "$TARGET" == "/" ] then - EXCLUDES+=" --exclude=${STAGE4_FILENAME#/}" + EXCLUDES_LIST+=" ${STAGE4_FILENAME#/}" if [ ${HAS_PORTAGEQ} == 1 ] then - EXCLUDES+=" --exclude=$(portageq get_repo_path / gentoo)/*" - EXCLUDES+=" --exclude=$(portageq distdir)/*" + EXCLUDES_LIST+=" $(portageq get_repo_path / gentoo)" + EXCLUDES_LIST+=" $(portageq distdir)" else - EXCLUDES+="${EXCLUDES_DEFAULT_PORTAGE}" - fi + EXCLUDES_LIST+="${EXCLUDES_DEFAULT_PORTAGE}" + fi else - EXCLUDES+="${EXCLUDES_DEFAULT_PORTAGE}" + EXCLUDES_LIST+="${EXCLUDES_DEFAULT_PORTAGE}" fi if [ ${EXCLUDE_CONNMAN} -eq 1 ] then - EXCLUDES+=" --exclude=${TARGET}var/lib/connman/*" + EXCLUDES_LIST+=" var/lib/connman/*" fi if [ ${EXCLUDE_BOOT} -eq 1 ] then - EXCLUDES+=" --exclude=${TARGET}boot/*" + EXCLUDES_LIST+=" boot/*" fi if [ ${EXCLUDE_LOST} -eq 1 ] then - EXCLUDES+=" --exclude=lost+found" + EXCLUDES_LIST+=" lost+found" fi # Generic tar options: @@ -206,6 +213,12 @@ else TAR_OPTIONS+=" -j" fi +# Loop through the final excludes list, before starting +for i in ${EXCLUDES_LIST[@]} +do + exclude "$i" +done + # if not in quiet mode, this message will be displayed: if [ "$AGREE" != "yes" ] then