Verified Commit 8dabe837 authored by A. Wilcox's avatar A. Wilcox 🦊
Browse files

adelie-build-txz: Overhaul, similar to adelie-build-cd

parent f6be8b0e
#!/bin/sh
set -e
def_arch=$(uname -m)
def_ver="1.0-beta4"
declare -r PROGNAME=$(basename $0)
def_ver="1.0-rc1"
readonly PROGNAME=$(basename $0)
[ -z $ZSH_VERSION ] || set -y
warn() {
......@@ -32,22 +36,22 @@ fatal() {
ensure_commands() {
if ! type apk>/dev/null 2>/dev/null; then
if ! command -v apk>/dev/null 2>/dev/null; then
fatal
printf 'You must have apk installed. On Gentoo, see sys-devel/apk-tools.\n'
exit -1
exit 127
fi
if ! type tar>/dev/null 2>/dev/null; then
if ! command -pv tar>/dev/null 2>/dev/null; then
fatal
printf 'You must have tar installed.\n'
exit -1
exit 127
fi
}
usage() {
printf 'usage: %s [-a ARCH] [--mini] [-s] [-v VERSION] [--help]\n\n' $PROGNAME
printf 'usage: %s [-a ARCH] [--mini] [-v VERSION] [--help]\n\n' $PROGNAME
printf 'Create an Adélie Linux root FS tarball (.TXZ) using the specified parameters.\n\n'
printf 'Default ARCH: %s\n' $def_arch
printf 'Default VERSION: %s\n' $def_ver
......@@ -58,36 +62,34 @@ while [ -n "$1" ]; do
case $1 in
-a | --arch)
shift
declare -r MY_ARCH=$1
readonly MY_ARCH=$1
;;
-h | --help)
usage
exit
;;
--mini)
declare -r MINI=yes
readonly MINI=yes
;;
-s | --sign)
declare -r SIGN=yes
;;
-v | --version)
shift
declare -r MY_VER=$1
readonly MY_VER=$1
;;
*)
usage >&2
exit -1
exit 127
;;
esac
shift
done
set -a
declare -r ARCH=${MY_ARCH:-$def_arch}
declare -r LDARCH=${LDARCH:-$ARCH}
declare -r PHASE=${MY_PHASE:-all}
declare -r VERSION=${MY_VER:-$def_ver}
declare -r URL=${MY_URL:-https://distfiles.adelielinux.org/adelie/$VERSION/}
readonly ARCH=${MY_ARCH:-$def_arch}
readonly LDARCH=${LDARCH:-$ARCH}
readonly PHASE=${MY_PHASE:-all}
readonly VERSION=${MY_VER:-$def_ver}
readonly APKVER=${MY_APKVER:-$VERSION}
readonly URL=${MY_URL:-https://distfiles.adelielinux.org/adelie/$VERSION/}
set +a
ensure_commands
......@@ -103,7 +105,7 @@ clean_dirs() {
warn
printf 'This will erase all files at the directories %s/rootfs-%s.\n\n' `pwd` $ARCH
printf 'When you are ready, press RETURN. To cancel, press Ctrl-C.\n'
read
read dontcare
rm -rf rootfs-$ARCH
mkdir rootfs-$ARCH
......@@ -114,16 +116,18 @@ install_pkgs() {
header "Installing base system to tar root..."
if test -n "${MINI+mini}"; then
declare -r PACKAGES="adelie-core dash-binsh"
declare -r ARCH_PKGS=""
readonly PACKAGES="adelie-core dash-binsh"
readonly ARCH_PKGS=""
else
declare -r PACKAGES=$(cat packages 2>/dev/null || fatal 'No core packages specified')
declare -r ARCH_PKGS=$(cat packages-$ARCH 2>/dev/null || echo '')
readonly PACKAGES="$(cat packages/base 2>/dev/null | tr '\n' ' ' || fatal 'No core packages specified')"
readonly ARCH_PKGS="$(cat packages/arch/$ARCH 2>/dev/null | tr '\n' ' ' || echo '')"
fi
mkdir -p rootfs-$ARCH/etc/apk/keys
cp 'packages@adelielinux.org.pub' rootfs-$ARCH/etc/apk/keys/
# XXX: Handle pre-install scripts.
mkdir -p rootfs-$ARCH/etc/apk
cp -r keys rootfs-$ARCH/etc/apk/
# Disable grub trigger.
mkdir -p rootfs-$ARCH/etc/default
printf "ADELIE_MANUAL_CONFIG=1\n" >> rootfs-$ARCH/etc/default/grub
mkdir -p rootfs-$ARCH/dev
mknod rootfs-$ARCH/dev/urandom c 1 9
mkdir -p rootfs-$ARCH/usr/sbin
......@@ -139,7 +143,9 @@ make_structure() {
else
echo 'adelie-root' > rootfs-$ARCH/etc/hostname
mkdir -p rootfs-$ARCH/etc/runlevels/{sysinit,boot,default,shutdown}
for _runlevel in sysinit boot default shutdown; do
mkdir -p rootfs-$ARCH/etc/runlevels/$_runlevel
done
echo 'mtab_is_file=no' > rootfs-$ARCH/etc/conf.d/mtab
......@@ -148,17 +154,24 @@ make_structure() {
rootfs-$ARCH/etc/runlevels/sysinit/$siservice
done
for bootservice in root binfmt bootmisc fsck hostname hwclock keymaps \
localmount loopback modules mtab procfs sysctl sysfsconf termencoding \
tmpfiles.setup urandom; do
for bootservice in root binfmt bootmisc fsck hostname hwclock \
keymaps localmount loopback modules mtab procfs sysctl \
sysfsconf termencoding tmpfiles.setup urandom; do
ln -s /etc/init.d/$bootservice \
rootfs-$ARCH/etc/runlevels/boot/$bootservice
done
readonly BASE_SERVICES="$(cat services/base 2>/dev/null | tr '\n' ' ' || echo '')"
[ -z BASE_SERVICES ] || for base_service in $BASE_SERVICES; do
ln -s /etc/init.d/$base_service \
rootfs-$ARCH/etc/runlevels/default/$base_service
done
cp AdelieTux.icns rootfs-$ARCH/.VolumeIcon.icns
# Put a copy of the kernel(s) in the kernels-$ARCH/ directory, so that
# users may download them for netbooting or such.
# Put a copy of the kernel(s) in the kernels/$ARCH/ directory,
# so users may download them for netbooting or such.
mkdir -p out/kernels/$ARCH
cp -r rootfs-$ARCH/boot/* out/kernels/$ARCH/
fi
......@@ -178,8 +191,8 @@ make_structure() {
RESOLVE
cat >rootfs-$ARCH/etc/apk/repositories <<-REPOS
https://distfiles.adelielinux.org/adelie/$VERSION/system/$EXTRA_MIRROR
https://distfiles.adelielinux.org/adelie/$VERSION/user/$EXTRA_MIRROR
https://distfiles.adelielinux.org/adelie/$APKVER/system/$EXTRA_MIRROR
https://distfiles.adelielinux.org/adelie/$APKVER/user/$EXTRA_MIRROR
REPOS
}
......@@ -187,7 +200,7 @@ tar_it() {
header 'Creating file system archive...'
cd rootfs-$ARCH
tar -cJf ../out/adelie-rootfs-${MINI+mini-}$ARCH-$VERSION-$(date +%Y%m%d).txz .
tar -cf - . | xz -v > ../out/adelie-rootfs-${MINI+mini-}$ARCH-$VERSION-$(date +%Y%m%d).txz
}
# in case we want to add phase support like adelie-build-cd has later
......@@ -202,14 +215,14 @@ case $PHASE in
tar)
tar_it
;;
*)
all)
clean_dirs
install_pkgs
make_structure
tar_it
;;
# *)
# fatal
# printf 'Unknown phase %s. Stop.\n' $PHASE
# ;;
*)
fatal
printf 'Unknown phase %s. Stop.\n' $PHASE
;;
esac
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment