diff --git a/src/sbin/pkginst b/src/sbin/pkginst index 2570c8c..7cb702d 100644 --- a/src/sbin/pkginst +++ b/src/sbin/pkginst @@ -24,7 +24,7 @@ # # Installing a package from a source tarball -main () { +main (){ HEAD=/var/yalpack TMP=/tmp STAGING=$HEAD/packages @@ -45,9 +45,11 @@ cd $STAGING tar -xf "$PACK".tar.xz NAME=$(cat "$PKGDIR"/NAME) +# Exit code not necessary because pkgup already checks for TREE. [ ! -d "$PKGDEST" ] && echo Warning! "$PKGDEST" was not found. Exiting. && exit + cd "$PKGDEST" -# Pat Volkerding says non-755 root is dangerous, so it can't hurt. +# Patrick Volkerding says non-755 root is dangerous, so it can't hurt (for safety when extracting the package to root). chmod 755 "$PKGDEST" # If --root-own was passed in, change ownership to root:root. Ownership is preserved at the actual install stage. [ "$3" = "CHOWN" ] && chown -R root:root "$PKGDEST" @@ -89,29 +91,8 @@ done echo Done evaluating the .new files, if any. echo -# Copying over -find "$PKGDEST"/ -type f,d | while read -r f; -do - i="${f##$PKGDEST/}" - j="$(basename "$i")" - j="${i%$j}" - if [ -n "$i" ]; then - echo /"$i" - # Change ownership and mode only of directories that didn't previously exist - [ ! -d "/$i" ] && CHANGE=yes - if [ -d "$i" ]; then - mkdir -vp /"$i" - # Change ownership and mode only of directories that didn't previously exist - [ "$CHANGE" = yes ] && chown "$(stat -c "%U:%G" "$i")" "/$i" - [ "$CHANGE" = yes ] && chmod "$(stat -c "%a" "$i")" "/$i" - else - install -m "$(stat -c "%a" "$f")" -o "$(stat -c "%U" "$f")" -g "$(stat -c "%G" "$f")" "$f" "/$j" - fi - unset CHANGE - fi -done - -# Handling any symlinks +# Preparing and reporting on symlinks; absolute symlinks can have been pointed at either the ultimate +# destination or a file/directory in the build directory. find "$PKGDEST"/ -type l | while read -r f; do i="${f##$PKGDEST/}" @@ -121,14 +102,26 @@ do # Pointing at BUILDDEST from time of building. k="${j##$BUILDDEST/}" echo /"$i" to /"$k" >> "$PKGDIR"/SYMLINKS - ln -sfv /"$k" /"$i" + ln -sfv /"$k" "$f" + echo # If the symlink is relative else echo /"$i" to "$j" >> "$PKGDIR"/SYMLINKS - ln -sfv "$j" /"$i" fi done +# Now that changes have been made to dest, make a new tarball for extraction... +tar -czf "$STAGING"/INPACKAGE.tar.xz ./* +# And extract over root. +cd / +tar -xvf "$STAGING"/INPACKAGE.tar.xz --no-overwrite-dir +cd "$PKGDIR" +echo + +# Running ldconfig in case of new libraries +echo Now running ldconfig... +/sbin/ldconfig || true +echo Done running ldconfig. echo # Populate the TREE entry for future updating @@ -145,27 +138,11 @@ if [ -f "$PKGDIR/install.sh" ]; then echo fi -# Running ldconfig in case of new libraries -echo Now running ldconfig... -/sbin/ldconfig || true -echo Done running ldconfig. -echo - # For the installer's edification and to update library use info echo -# pkgcheck should use its own error handling instead. pkgup handles pkgcheck for upgrades. -set +e +# pkgup handles pkgcheck for upgrades. [ "${UPGRADE:-no}" != yes ] && CHECK=no /sbin/pkgcheck "$NAME" -set -e -# Clean up afterwards -cd "$STAGING" -rm -rf "${PKGDIR:?}" -if [ "$2" != "KEEP" ]; then - rm -vf $STAGING/"$PACK".tar.xz - echo The package tarball has been removed. See $PKGTREES/"$NAME" - echo for a list of installed files. - echo -fi + # Inform about any symlinks if [ -f "$PKGDIR"/SYMLINKS ]; then echo The following symlinks were created by the build process: @@ -185,6 +162,17 @@ if [ -f "$PKGDIR"/NEWFILES ]; then echo fi +# Clean up afterwards (INPACKAGE is never retained) +cd "$STAGING" +rm -f "$STAGING"/INPACKAGE.tar.xz +rm -rf "${PKGDIR:?}" +if [ "$2" != "KEEP" ]; then + rm -vf $STAGING/"$PACK".tar.xz + echo The package tarball has been removed. See $PKGTREES/"$NAME" + echo for a list of installed files. + echo +fi + echo Installation of "$PACK" complete. echo } diff --git a/src/sbin/pkgremove b/src/sbin/pkgremove index d9c1f3e..20a462e 100644 --- a/src/sbin/pkgremove +++ b/src/sbin/pkgremove @@ -62,6 +62,7 @@ if [ -f "$OLDVER" ]; then mv "$OLDVER" "$RMTEMP"/VER fi +# No exit code necessary because pkgup already checks for this. [ -z "$(find "$OLDTREE")" ] && echo Requested package not found. Check for the package name with pkglist. Exiting now. && exit # Removing any previous RMDOC diff --git a/src/sbin/pkgup b/src/sbin/pkgup index e97355a..6715198 100644 --- a/src/sbin/pkgup +++ b/src/sbin/pkgup @@ -44,6 +44,10 @@ else fi echo +# If init is upgraded, or in case of a glibc upgrade, it will need to reload before a halt or reboot +# is attempted. +INITVER="$(/sbin/init --version | cut -d' ' -f4-)" + set -e cd $STAGING [ ! -d "$NEWDIR" ] && tar -xf $STAGING/"$2".tar.xz @@ -67,6 +71,12 @@ UPGRADE=yes /sbin/pkgremove -y "$1" CHECK=no /sbin/pkgcheck "$NAME" set -e +# Checking for a new version of init +NEWINITVER="$(/sbin/init --version | cut -d' ' -f4-)" + +# Reload init if new glibc or new sysvinit +[ -n "$(grep /lib/libc.so.6 "$PKGTREES"/"$NAME")" ] || [ "$INITVER" != "$NEWINITVER" ] && /sbin/telinit U && echo init has been reloaded. && echo + echo The upgrade of "$1" to "$2" is complete. echo }