summaryrefslogtreecommitdiff
path: root/build-cd
diff options
context:
space:
mode:
Diffstat (limited to 'build-cd')
-rwxr-xr-xbuild-cd267
1 files changed, 267 insertions, 0 deletions
diff --git a/build-cd b/build-cd
new file mode 100755
index 0000000..0c76213
--- /dev/null
+++ b/build-cd
@@ -0,0 +1,267 @@
+#!/bin/sh
+
+def_arch=x86_64
+def_kernel=4.6
+declare -r PROGNAME=$(basename $0)
+
+
+warn() {
+ printf '>>> '
+ printf '\033[01;33mWARNING\033[00;39m '
+ printf '>>> '
+ printf '\033[01;33mWARNING\033[00;39m '
+ printf '>>> '
+ printf '\033[01;33mWARNING\033[00;39m '
+ printf '>>> '
+ printf '\033[01;33mWARNING\033[00;39m '
+ printf '>>>\n'
+}
+
+
+fatal() {
+ printf '>>> '
+ printf '\033[01;31mERROR\033[00;39m '
+ printf '>>> '
+ printf '\033[01;31mERROR\033[00;39m '
+ printf '>>> '
+ printf '\033[01;31mERROR\033[00;39m '
+ printf '>>> '
+ printf '\033[01;31mERROR\033[00;39m '
+ printf '>>>\n'
+}
+
+
+ensure_commands() {
+ if ! type apk>/dev/null; then
+ fatal
+ printf 'You must have apk installed. On Gentoo, see sys-devel/apk-tools.\n'
+ exit -1
+ fi
+
+ if ! type cpio>/dev/null; then
+ fatal
+ printf 'You must have cpio installed. On Gentoo, see app-arch/cpio.\n'
+ exit -1
+ fi
+
+ if ! type mksquashfs>/dev/null; then
+ fatal
+ printf 'You must have mksquashfs installed. On Gentoo, see sys-fs/squashfs-tools.\n'
+ exit -1
+ fi
+
+ if ! type mkisofs>/dev/null; then
+ fatal
+ printf 'You must have mkisofs installed. Try cdrtools or cdrkit.\n'
+ exit -1
+ fi
+}
+
+
+usage() {
+ printf 'usage: %s [-a ARCH] [-k KERNEL] [--help]\n\n' $PROGNAME
+ printf 'Create an Adélie Linux CD image (.ISO) using the specified parameters.\n'
+ printf 'Default ARCH: %s\nDefault kernel version: %s\n' $def_arch $def_kernel
+}
+
+
+while [ -n "$1" ]; do
+ case $1 in
+ -a | --arch)
+ shift
+ declare -r MY_ARCH=$1
+ ;;
+ -h | --help)
+ usage
+ exit
+ ;;
+ -k | --kernel)
+ shift
+ declare -r MY_KERNEL=$1
+ ;;
+ *)
+ usage >&2
+ exit -1
+ ;;
+ esac
+ shift
+done
+
+declare -r ARCH=${MY_ARCH:-$def_arch}
+declare -r KERNEL=${MY_KERNEL:-$def_kernel}
+declare -r LDARCH=${LDARCH:-$ARCH}
+
+ensure_commands
+
+warn
+printf 'This will erase all files at the directories %s/cdroot-%s\n' `pwd` $ARCH
+printf '%s/initrd-%s and %s/squashroot-%s.\n\n' `pwd` $ARCH `pwd` $ARCH
+printf 'When you are ready, press RETURN. To cancel, press Ctrl-C.\n'
+read
+
+printf '\033[01;32m * \033[37mAdélie Linux CD Creation Tool\033[00;39m\n\n'
+
+rm -rf cdroot-$ARCH
+rm -rf initrd-$ARCH
+rm -rf squashroot-$ARCH
+mkdir cdroot-$ARCH
+mkdir initrd-$ARCH
+mkdir squashroot-$ARCH
+
+printf '\033[01;32m * \033[37mInstalling base system to squash root...\033[00;39m\n'
+
+apk --arch $ARCH -X "https://distfiles.adelielinux.org/adelie/1.0-alpha/$EXTRA_MIRROR" -U --allow-untrusted --root squashroot-$ARCH --initdb add shadow libffi adelie-base bash openrc openrc-openrc hwids eudev udev-init-scripts-openrc parted lvm2-openrc easy-kernel-modules easy-kernel-firmware dhcpcd net-tools ca-certificates
+mkdir -p squashroot-$ARCH/etc/apk/keys
+mkdir -p squashroot-$ARCH/home/live
+mkdir squashroot-$ARCH/target
+mkdir -p squashroot-$ARCH/media/live
+ln -s /bin/bash squashroot-$ARCH/bin/sh
+
+echo 'hostname="adelie"' > squashroot-$ARCH/etc/conf.d/hostname
+echo 'mtab_is_file=no' > squashroot-$ARCH/etc/conf.d/mtab
+
+cp -RPp squashroot-$ARCH/usr/share/openrc/runlevels squashroot-$ARCH/etc/runlevels
+cp 'packages@adelielinux.org.pub' squashroot-$ARCH/etc/apk/keys/
+ln -s /etc/init.d/udev squashroot-$ARCH/etc/runlevels/sysinit/udev
+ln -s /etc/init.d/udev-trigger squashroot-$ARCH/etc/runlevels/sysinit/udev-trigger
+ln -s /etc/init.d/lvmetad squashroot-$ARCH/etc/runlevels/sysinit/lvmetad
+
+cat >squashroot-$ARCH/etc/fstab <<- FSTAB
+ # Welcome to Adélie Linux.
+ # This fstab(5) is for the live media only. Do not edit or use for your installation.
+
+ tmpfs /tmp tmpfs defaults 0 1
+ tmpfs /var/log tmpfs size=8m 0 1
+ tmpfs /root tmpfs size=16m 0 1
+ tmpfs /home/live tmpfs size=16m 0 1
+ proc /proc proc defaults 0 1
+FSTAB
+
+cat >squashroot-$ARCH/etc/passwd <<- PASSWD
+ root:x:0:0:Charlie Root:/root:/bin/bash
+ man:x:13:15:man-db:/usr/share/man:/sbin/nologin
+ at:x:25:25:at:/var/spool/at/atjobs:/sbin/nologin
+ fcron:x:101:206:fcron:/dev/null:/sbin/nologin
+ postfix:x:207:207:postfix:/var/spool/postfix:/sbin/nologin
+ live:x:1000:1000:Live User:/home/live:/bin/bash
+PASSWD
+
+cat >squashroot-$ARCH/etc/group <<- GROUP
+ root:x:0:
+ tty:x:5:
+ wheel:x:10:live
+ mail:x:12:postfix
+ uucp:x:14:
+ cron:x:16:
+ at:x:25:
+ fcron:x:206:
+ postfix:x:207:
+ postdrop:x:208:
+ live:x:1000:
+GROUP
+
+cat >squashroot-$ARCH/etc/shadow <<- SHADOW
+ root::::::::
+ man::::::::
+ at::::::::
+ fcron::::::::
+ postfix::::::::
+ live::::::::
+SHADOW
+
+cat >squashroot-$ARCH/etc/shells <<- SHELLS
+ /bin/bash
+ /bin/zsh
+SHELLS
+
+cat >squashroot-$ARCH/etc/resolv.conf <<- RESOLVE
+ nameserver 8.8.8.8
+RESOLVE
+
+cat >squashroot-$ARCH/etc/apk/repositories <<-REPOS
+ https://distfiles.adelielinux.org/adelie/1.0-alpha/$EXTRA_MIRROR
+REPOS
+
+cat >squashroot-$ARCH/etc/issue <<-ISSUE
+ Welcome to Adélie Linux!
+ You may log in as 'root' to install, or 'live' to play around.
+
+ Have fun.
+
+ISSUE
+
+chmod 600 squashroot-$ARCH/etc/shadow
+
+printf '\033[01;32m * \033[37mCreating compressed file system image...\033[00;39m\n'
+
+mksquashfs squashroot-$ARCH cdroot-$ARCH/adelie.squashfs
+
+printf '\033[01;32m * \033[37mCreating initrd structure...\033[00;39m\n'
+
+# mount points
+mkdir initrd-$ARCH/dev
+mkdir initrd-$ARCH/media
+mkdir initrd-$ARCH/newroot
+mkdir initrd-$ARCH/proc
+mkdir initrd-$ARCH/sys
+
+# manual /dev nodes for initial udev startup
+mknod -m 600 initrd-$ARCH/dev/console c 5 1
+mknod -m 666 initrd-$ARCH/dev/null c 1 3
+mknod -m 666 initrd-$ARCH/dev/ptmx c 5 2
+mknod -m 666 initrd-$ARCH/dev/random c 1 8
+mknod -m 666 initrd-$ARCH/dev/tty c 5 0
+mknod -m 620 initrd-$ARCH/dev/tty1 c 4 1
+mknod -m 666 initrd-$ARCH/dev/urandom c 1 9
+mknod -m 666 initrd-$ARCH/dev/zero c 1 5
+
+# base
+mkdir initrd-$ARCH/lib
+cp squashroot-$ARCH/usr/lib/libc.so initrd-$ARCH/lib/ld-musl-$LDARCH.so.1
+cp squashroot-$ARCH/lib/libblkid.so.1 initrd-$ARCH/lib/
+cp squashroot-$ARCH/lib/libuuid.so.1 initrd-$ARCH/lib/
+
+# udev
+mkdir -p initrd-$ARCH/etc/udev
+mkdir initrd-$ARCH/run
+mkdir initrd-$ARCH/sbin
+cp squashroot-$ARCH/bin/udevadm initrd-$ARCH/sbin/
+cp squashroot-$ARCH/sbin/udevd initrd-$ARCH/sbin/
+cp squashroot-$ARCH/lib/libkmod.so.2 initrd-$ARCH/lib/
+cp squashroot-$ARCH/lib/libudev.so.1 initrd-$ARCH/lib/
+cp squashroot-$ARCH/etc/udev/hwdb.bin initrd-$ARCH/etc/udev/
+
+# init
+cp cdinit-$ARCH initrd-$ARCH/init
+
+printf '\033[01;32m * \033[37mCompressing initrd...\033[00;39m\n'
+
+pushd initrd-$ARCH
+find . | cpio -H newc -o > ../cdroot-$ARCH/initrd
+popd
+gzip -9 cdroot-$ARCH/initrd
+mv cdroot-$ARCH/initrd.gz cdroot-$ARCH/initrd
+
+printf '\033[01;32m * \033[37mAdding kernel...\033[00;39m\n'
+
+cp bzImage-$ARCH cdroot-$ARCH/bzImage
+
+printf '\033[01;32m * \033[37mInstalling ISOLINUX...\033[00;39m\n'
+
+mkdir cdroot-$ARCH/isolinux
+
+cat >cdroot-$ARCH/isolinux/isolinux.cfg <<BOOTCFG
+prompt 1
+default adelie
+
+label adelie
+ kernel /bzImage
+ append initrd=/initrd
+BOOTCFG
+
+cp /usr/share/syslinux/isolinux-debug.bin cdroot-$ARCH/isolinux/isolinux.bin
+cp /usr/share/syslinux/ldlinux.c32 cdroot-$ARCH/isolinux/
+
+printf '\033[01;32m * \033[37mCreating the CD...\033[00;39m\n'
+
+mkisofs -o adelie-live-$ARCH-1.0-ALPHA-$(date +%Y%m%d).iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -joliet cdroot-$ARCH