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