puke: Run build on install

This commit is contained in:
Dylan Araps 2019-05-30 10:07:40 +03:00
parent f2ad2228a2
commit d58110e0da
2 changed files with 54 additions and 2 deletions

52
alpine_chroot Executable file
View File

@ -0,0 +1,52 @@
#!/bin/sh -e
#
# Setup an alpine chroot.
chroot_dir=~/alpine-chroot
mirror=http://dl-cdn.alpinelinux.org/alpine/
file=apk-tools-static-2.10.3-r1.apk
clean() {
umount "$chroot_dir/dev" ||:
umount "$chroot_dir/proc" ||:
umount "$chroot_dir/sys" ||:
rm -rf "$chroot_dir" "/tmp/${file:-null}"
}
main() {
[ "$(id -u)" != 0 ] && {
echo "Run this script with sudo." >&2
exit 1
}
clean
mkdir -p "/tmp/$file"
cd "/tmp/$file"
wget "$mirror/latest-stable/main/x86_64/$file"
tar xzf "$file"
./sbin/apk.static \
-X "$mirror/latest-stable/main" \
-U \
--allow-untrusted \
--root "$chroot_dir" \
--initdb add alpine-base alpine-sdk ||:
cp -f /etc/resolv.conf "$chroot_dir/etc"
mkdir -p "$chroot_dir/etc/apk"
echo "$mirror/edge/main" > "$chroot_dir/etc/apk/repositories"
mount -o bind /dev "$chroot_dir/dev"
mount -t proc proc "$chroot_dir/proc"
mount -t sysfs sys "$chroot_dir/sys"
trap clean EXIT INT
chroot "$chroot_dir" /bin/sh
}
main

4
puke
View File

@ -94,7 +94,7 @@ pkg_tar() {
}
pkg_install() {
[ -f "$bin_dir/$pkg" ] || die "Package must be built first."
[ -f "$bin_dir/$pkg" ] || args b "$name"
pkg_remove "$name"
tar pxvf "$bin_dir/$pkg" -k -C "$sys_dir/" 2>/dev/null
@ -162,7 +162,7 @@ args() {
*) log "$0 [b|c|i|l|r|u] [pkg]" \
"build: Build a package." \
"checksum: Generate checksums." \
"install: Install a package." \
"install: Install a package (Runs build when needed)." \
"list: List packages." \
"remove: Remove a package." \
"update: Check for updates."