Skip to content
This repository has been archived by the owner on Oct 2, 2021. It is now read-only.

Commit

Permalink
Version bump
Browse files Browse the repository at this point in the history
Version to 0.1.4

pkginst: Use tar to re-archive modified package contents and extract over root
pkgup: Reload init if there has been a glibc or SysVinit upgrade.
  • Loading branch information
pghvlaans authored Jun 7, 2021
1 parent 191cd19 commit 9111868
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 45 deletions.
78 changes: 33 additions & 45 deletions src/sbin/pkginst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#
# Installing a package from a source tarball

main () {
main (){
HEAD=/var/yalpack
TMP=/tmp
STAGING=$HEAD/packages
Expand All @@ -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"
Expand Down Expand Up @@ -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/}"
Expand All @@ -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
Expand All @@ -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:
Expand All @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions src/sbin/pkgremove
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions src/sbin/pkgup
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
Expand Down

0 comments on commit 9111868

Please sign in to comment.