contrib: Fix portability issues
This commit is contained in:
parent
dff30f569c
commit
e43dd77469
|
@ -14,6 +14,24 @@ die() {
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sh256() {
|
||||||
|
# There's no standard utility to generate sha256 checksums.
|
||||||
|
# This is a simple wrapper around sha256sum, sha256, shasum
|
||||||
|
# and openssl which will use whatever is available.
|
||||||
|
#
|
||||||
|
# All utilities must match 'sha256sum' output.
|
||||||
|
#
|
||||||
|
# Example: '<checksum> <file>'
|
||||||
|
[ -e "$1" ] || return 0
|
||||||
|
|
||||||
|
hash=$(sha256sum "$1" ||
|
||||||
|
sha256 -r "$1" ||
|
||||||
|
openssl dgst -sha256 -r "$1" ||
|
||||||
|
shasum -a 256 "$1")
|
||||||
|
|
||||||
|
printf '%s %s\n' "${hash%% *}" "$1"
|
||||||
|
} 2>/dev/null
|
||||||
|
|
||||||
cd "${cac_dir:=$KISS_ROOT${XDG_CACHE_HOME:-$HOME/.cache}/kiss}"
|
cd "${cac_dir:=$KISS_ROOT${XDG_CACHE_HOME:-$HOME/.cache}/kiss}"
|
||||||
url=https://github.com/kisslinux/repo/releases/download/1.10.0/
|
url=https://github.com/kisslinux/repo/releases/download/1.10.0/
|
||||||
|
|
||||||
|
@ -30,7 +48,7 @@ url=https://github.com/kisslinux/repo/releases/download/1.10.0/
|
||||||
}
|
}
|
||||||
|
|
||||||
log "Verifying checksums"
|
log "Verifying checksums"
|
||||||
sha256sum -c < kiss-chroot.tar.xz.sha256 ||
|
sh256 kiss-chroot.tar.xz | diff - kiss-chroot.tar.xz.sha256 ||
|
||||||
die "Checksum verification failed."
|
die "Checksum verification failed."
|
||||||
|
|
||||||
[ -d kiss-chroot ] || {
|
[ -d kiss-chroot ] || {
|
||||||
|
|
|
@ -24,6 +24,20 @@ clean() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mounted() {
|
||||||
|
# This is a pure shell mountpoint implementation. We're dealing
|
||||||
|
# with basic (and fixed/known) input so this doesn't need to
|
||||||
|
# handle more complex cases.
|
||||||
|
[ -e "$1" ] || return 1
|
||||||
|
[ -e /proc/mounts ] || return 1
|
||||||
|
|
||||||
|
while read -r _ target _; do
|
||||||
|
[ "$target" = "$1" ] && return 0
|
||||||
|
done < /proc/mounts
|
||||||
|
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
[ -z "$1" ] && die Need a path to the chroot
|
[ -z "$1" ] && die Need a path to the chroot
|
||||||
[ -d "$1" ] || die Given path does not exist
|
[ -d "$1" ] || die Given path does not exist
|
||||||
[ "$(id -u)" = 0 ] || die Script needs to be run as root
|
[ "$(id -u)" = 0 ] || die Script needs to be run as root
|
||||||
|
@ -31,11 +45,11 @@ clean() {
|
||||||
trap 'clean "$1"' EXIT INT
|
trap 'clean "$1"' EXIT INT
|
||||||
|
|
||||||
log Mounting /dev, /proc and /sys from host; {
|
log Mounting /dev, /proc and /sys from host; {
|
||||||
mountpoint -q "$1/dev" || mount -o bind /dev "$1/dev"
|
mounted "$1/dev" || mount -o bind /dev "$1/dev"
|
||||||
mountpoint -q "$1/proc" || mount -t proc proc "$1/proc"
|
mounted "$1/proc" || mount -t proc proc "$1/proc"
|
||||||
mountpoint -q "$1/sys" || mount -t sysfs sys "$1/sys"
|
mounted "$1/sys" || mount -t sysfs sys "$1/sys"
|
||||||
|
|
||||||
mountpoint -q "$1/sys/firmware/efi/efivars" ||
|
mounted "$1/sys/firmware/efi/efivars" ||
|
||||||
mount -t efivarfs efivarfs "$1/sys/firmware/efi/efivars" 2>/dev/null ||:
|
mount -t efivarfs efivarfs "$1/sys/firmware/efi/efivars" 2>/dev/null ||:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
read -r ver rel 2>/dev/null < "$KISS_ROOT/var/db/kiss/installed/$1/version"
|
read -r ver rel 2>/dev/null < "$KISS_ROOT/var/db/kiss/installed/$1/version"
|
||||||
|
|
||||||
# Reset the argument list.
|
# Reset the argument list.
|
||||||
pkg=$1
|
pkg=$1 pwd=$PWD
|
||||||
set --
|
set --
|
||||||
|
|
||||||
# Construct the argument list using each file.
|
# Construct the argument list using each file.
|
||||||
|
@ -20,12 +20,16 @@ while read -r file; do
|
||||||
[ -d "$KISS_ROOT/$file" ] || set -- "$@" ".$file"
|
[ -d "$KISS_ROOT/$file" ] || set -- "$@" ".$file"
|
||||||
done < "$KISS_ROOT/var/db/kiss/installed/$pkg/manifest"
|
done < "$KISS_ROOT/var/db/kiss/installed/$pkg/manifest"
|
||||||
|
|
||||||
# Turn the list of files back into a package.
|
cd "$KISS_ROOT/"
|
||||||
tar cf - -C / -- "$@" | case ${KISS_COMPRESS:-gz} in
|
|
||||||
bz2) bzip2 -z ;;
|
|
||||||
gz) gzip -6 ;;
|
|
||||||
xz) xz -zT 0 ;;
|
|
||||||
zst) zstd -z ;;
|
|
||||||
esac > "$pkg#$ver-$rel.tar.${KISS_COMPRESS:-gz}"
|
|
||||||
|
|
||||||
printf 'tarball created in %s\n' "$PWD/$pkg#$ver-$rel.tar.${KISS_COMPRESS:-gz}"
|
# Turn the list of files back into a package.
|
||||||
|
tar cf - "$@" | case ${KISS_COMPRESS:-gz} in
|
||||||
|
bz2) bzip2 -z ;;
|
||||||
|
gz) gzip -6 ;;
|
||||||
|
lzma) lzma -z ;;
|
||||||
|
lz) lzip -z ;;
|
||||||
|
xz) xz -zT 0 ;;
|
||||||
|
zst) zstd -z ;;
|
||||||
|
esac > "$pwd/$pkg#$ver-$rel.tar.${KISS_COMPRESS:-gz}"
|
||||||
|
|
||||||
|
printf 'tarball created in %s\n' "$pwd/$pkg#$ver-$rel.tar.${KISS_COMPRESS:-gz}"
|
||||||
|
|
Loading…
Reference in New Issue