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