cleanup the debian/devuan build script

This commit is contained in:
Nico Schottelius 2020-06-02 18:31:06 +02:00
parent 2a624e8442
commit 2cfcca5679

View file

@ -2,7 +2,8 @@
# Nico Schottelius, 2019-12-09 # Nico Schottelius, 2019-12-09
# the ugly code is llnu # the ugly code is llnu
#this can only run in the ungleich-tools directory because of the cat magiccommand........ set -e
set -x
if [ $# -ne 2 ]; then if [ $# -ne 2 ]; then
echo $0 suite out-directory echo $0 suite out-directory
@ -15,41 +16,45 @@ suite=$1; shift
outdir=$1; shift outdir=$1; shift
date=$(date +%F) date=$(date +%F)
mkdir -p ${outdir}
basename=${suite}-${date} basename=${suite}-${date}
dir=${outdir}/${basename} abs_outdir=$(cd ${outdir} && pwd -P)
kernel=${outdir}/kernel-${basename}
initramfs=${outdir}/initramfs-${basename} chroot_dir=${abs_outdir}/${basename}
kernel=${abs_outdir}/kernel-${basename}
initramfs=${abs_outdir}/initramfs-${basename}
keyurl=https://code.ungleich.ch/ungleich-public/__ungleich_staff_ssh_access/raw/master/files keyurl=https://code.ungleich.ch/ungleich-public/__ungleich_staff_ssh_access/raw/master/files
debootstrap "${suite}" "${dir}" debootstrap "${suite}" "${chroot_dir}"
# need non-free for firmware-bnx2 # need non-free for firmware-bnx2
echo "deb http://pkgmaster.devuan.org/merged ${suite} main contrib non-free" > ${dir}/etc/apt/sources.list echo "deb http://pkgmaster.devuan.org/merged ${suite} main contrib non-free" > ${chroot_dir}/etc/apt/sources.list
chroot ${dir} apt update chroot ${chroot_dir} apt update
chroot ${dir} apt install -y openssh-server rdnssd linux-image-amd64 firmware-bnx2 chroot ${chroot_dir} apt install -y openssh-server rdnssd linux-image-amd64 firmware-bnx2 inetutils-ping
echo "unconfigured-host" > ${dir}/etc/hostname echo "unconfigured-host" > ${chroot_dir}/etc/hostname
cp ${dir}/boot/vmlinuz-* ${kernel} cp ${chroot_dir}/boot/vmlinuz-* ${kernel}
echo '* * * * * root ip -o -6 addr show | grep -E -v " lo |one" > /etc/issue' > ${dir}/etc/cron.d/ipv6addr echo '* * * * * root ip -o -6 addr show | grep -E -v " lo |one" > /etc/issue' > ${chroot_dir}/etc/cron.d/ipv6addr
mkdir -p ${dir}/root/.ssh mkdir -p ${chroot_dir}/root/.ssh
for key in balazs dominique jinguk nico; do for key in balazs dominique jinguk nico; do
curl -s ${keyurl}/${key}.pub >> ${dir}/root/.ssh/authorized_keys curl -s ${keyurl}/${key}.pub >> ${chroot_dir}/root/.ssh/authorized_keys
done done
# Fix possible permission issue from above # Fix possible permission issue from above
chown -R root:root ${dir}/root/ chown -R root:root ${chroot_dir}/root/
################################################################################ ################################################################################
# networking # networking
# always lo # always lo
cat > ${dir}/etc/network/interfaces << EOF cat > ${chroot_dir}/etc/network/interfaces << EOF
auto lo auto lo
iface lo inet loopback iface lo inet loopback
@ -57,7 +62,7 @@ source-directory /etc/network/interfaces.d
EOF EOF
# find the boot interfaces at boot # find the boot interfaces at boot
cat > ${dir}/etc/rc.local <<EOF cat > ${chroot_dir}/etc/rc.local <<EOF
mac=\$(cat /proc/cmdline | tr ' ' '\n' | awk -F= '/bootdev/ { print \$2 }') mac=\$(cat /proc/cmdline | tr ' ' '\n' | awk -F= '/bootdev/ { print \$2 }')
dev=\$(ip -o link | awk -F: "/\$mac/ { print \\\$2 }" | sed 's/ *//g') dev=\$(ip -o link | awk -F: "/\$mac/ { print \\\$2 }" | sed 's/ *//g')
@ -71,12 +76,12 @@ ifup "\${dev}"
exit 0 exit 0
EOF EOF
chmod a+rx "${dir}/etc/rc.local" chmod a+rx "${chroot_dir}/etc/rc.local"
# ensure there is /init in the initramfs -> otherwise there is a kernel panic # ensure there is /init in the initramfs -> otherwise there is a kernel panic
# reason: initramfs is designed to be PRE regular os, so /init usually hands over to /sbin/init # reason: initramfs is designed to be PRE regular os, so /init usually hands over to /sbin/init
# in our case, they are just the same # in our case, they are just the same
ln -fs /sbin/init ${dir}/init ln -fs /sbin/init ${chroot_dir}/init
# Finally building the initramfs # Finally building the initramfs
( cd ${dir} ; find . | cpio -H newc -o | gzip -9 > ${initramfs} ) ( cd ${chroot_dir} ; find . | cpio -H newc -o | gzip -9 > ${initramfs} )