From c99ed8080224883dc5081f7da8907c5ed916029b Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Tue, 23 Oct 2018 14:14:54 +0200 Subject: [PATCH] prepare-root.sh: add --check-update --- prepare-root.sh | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/prepare-root.sh b/prepare-root.sh index 8b84801..d1fd6f4 100755 --- a/prepare-root.sh +++ b/prepare-root.sh @@ -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 --noscripts Do not rpm scripts --statedir DIR Use DIR to preserve state across builds like uid/gid + --check-update Only check for updates EOF } @@ -44,6 +45,7 @@ TEMP=$( --long statedir: \ --long noupdates \ --long noscripts \ + --long check-update \ -- "$@" ) @@ -120,6 +122,10 @@ while true; do NO_SCRIPTS=1 shift 1; continue ;; + '--check-update') + CHECK_UPDATE=1 + shift 1; continue + ;; '--') shift break @@ -160,8 +166,7 @@ readonly MY_TMPDIR="$(mktemp -p "$TMPDIR/" -d -t ${PROGNAME}.XXXXXX)" # clean up after ourselves no matter how we die. trap ' ret=$?; - mountpoint -q "$sysroot"/var/cache/dnf && umount "$sysroot"/var/cache/dnf - for i in "$sysroot"/{dev,sys/fs/selinux,sys,proc,run}; do + for i in "$sysroot"/{dev,sys/fs/selinux,sys,proc,run,var/lib/rpm,var/cache/dnf}; do [[ -d "$i" ]] && mountpoint -q "$i" && umount "$i" done [[ $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" 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 mkdir "$sysroot"/usr @@ -236,7 +251,7 @@ dnf -v --nogpgcheck \ --setopt=keepcache=True \ --setopt=reposdir="$REPOSD" \ ${NO_SCRIPTS:+ --setopt=tsflags=noscripts} \ - install -y \ + ${DNF_COMMAND} \ dracut \ passwd \ rootfiles \ @@ -283,6 +298,12 @@ dnf -v --nogpgcheck \ dosfstools \ $PKGLIST +RET=$? + +if [[ $CHECK_UPDATE ]]; then + exit $RET +fi + for i in passwd shadow group gshadow subuid subgid; do [[ -e "$sysroot"/etc/${i}.rpmnew ]] || continue while read line || [[ $line ]]; do