prepare-root.sh: add --check-update

This commit is contained in:
Harald Hoyer 2018-10-23 14:14:54 +02:00
parent 4c175b78b0
commit c99ed80802

View file

@ -20,6 +20,7 @@ Creates a directory with a readonly root on squashfs, a dm_verity file and an EF
--noupdate Do not install from Fedora Updates --noupdate Do not install from Fedora Updates
--noscripts Do not rpm scripts --noscripts Do not rpm scripts
--statedir DIR Use DIR to preserve state across builds like uid/gid --statedir DIR Use DIR to preserve state across builds like uid/gid
--check-update Only check for updates
EOF EOF
} }
@ -44,6 +45,7 @@ TEMP=$(
--long statedir: \ --long statedir: \
--long noupdates \ --long noupdates \
--long noscripts \ --long noscripts \
--long check-update \
-- "$@" -- "$@"
) )
@ -120,6 +122,10 @@ while true; do
NO_SCRIPTS=1 NO_SCRIPTS=1
shift 1; continue shift 1; continue
;; ;;
'--check-update')
CHECK_UPDATE=1
shift 1; continue
;;
'--') '--')
shift shift
break break
@ -160,8 +166,7 @@ readonly MY_TMPDIR="$(mktemp -p "$TMPDIR/" -d -t ${PROGNAME}.XXXXXX)"
# clean up after ourselves no matter how we die. # clean up after ourselves no matter how we die.
trap ' trap '
ret=$?; ret=$?;
mountpoint -q "$sysroot"/var/cache/dnf && umount "$sysroot"/var/cache/dnf for i in "$sysroot"/{dev,sys/fs/selinux,sys,proc,run,var/lib/rpm,var/cache/dnf}; do
for i in "$sysroot"/{dev,sys/fs/selinux,sys,proc,run}; do
[[ -d "$i" ]] && mountpoint -q "$i" && umount "$i" [[ -d "$i" ]] && mountpoint -q "$i" && umount "$i"
done done
[[ $MY_TMPDIR ]] && rm -rf --one-file-system -- "$MY_TMPDIR" [[ $MY_TMPDIR ]] && rm -rf --one-file-system -- "$MY_TMPDIR"
@ -200,7 +205,17 @@ mount -o bind /sys "$sysroot/sys"
mount -t devtmpfs devtmpfs "$sysroot/dev" mount -t devtmpfs devtmpfs "$sysroot/dev"
mkdir -p "$sysroot"/var/cache/dnf mkdir -p "$sysroot"/var/cache/dnf
mount -o bind /var/cache/dnf "$sysroot"/var/cache/dnf mkdir -p "$STATEDIR"/dnf
mount -o bind "$STATEDIR"/dnf "$sysroot"/var/cache/dnf
if [[ $CHECK_UPDATE ]]; then
mkdir -p "$STATEDIR"/rpm
mkdir -p "$sysroot"/var/lib/rpm
mount -o bind "$STATEDIR"/rpm "$sysroot"/var/lib/rpm
DNF_COMMAND="check-update"
else
DNF_COMMAND="install -y"
fi
if [[ $NO_SCRIPTS ]]; then if [[ $NO_SCRIPTS ]]; then
mkdir "$sysroot"/usr mkdir "$sysroot"/usr
@ -236,7 +251,7 @@ dnf -v --nogpgcheck \
--setopt=keepcache=True \ --setopt=keepcache=True \
--setopt=reposdir="$REPOSD" \ --setopt=reposdir="$REPOSD" \
${NO_SCRIPTS:+ --setopt=tsflags=noscripts} \ ${NO_SCRIPTS:+ --setopt=tsflags=noscripts} \
install -y \ ${DNF_COMMAND} \
dracut \ dracut \
passwd \ passwd \
rootfiles \ rootfiles \
@ -283,6 +298,12 @@ dnf -v --nogpgcheck \
dosfstools \ dosfstools \
$PKGLIST $PKGLIST
RET=$?
if [[ $CHECK_UPDATE ]]; then
exit $RET
fi
for i in passwd shadow group gshadow subuid subgid; do for i in passwd shadow group gshadow subuid subgid; do
[[ -e "$sysroot"/etc/${i}.rpmnew ]] || continue [[ -e "$sysroot"/etc/${i}.rpmnew ]] || continue
while read line || [[ $line ]]; do while read line || [[ $line ]]; do