Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loop through excludes #21

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 44 additions & 31 deletions mkstage4.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Copy link
Contributor

@lucianposton lucianposton Feb 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will break excludes that don't intend to match the entire path below TARGET e.g. lost+found or -e '*.iso

}

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:
Expand All @@ -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
Expand Down