#
# Thomas Lange, Uni Koeln, 2011-2017
# based on the Makefile implementation of Michael Goetze
+#
+# Usage example: mk-basefile -J STRETCH64
+# This will create a STRETCH64.tar.xz basefile.
# Supported distributions (each i386/amd64):
# Debian GNU/Linux
# Define your local mirros here
# For the first stage, set the CentOS/SLC mirror in /etc/rinse/rinse.conf
-MIRROR_DEBIAN=http://httpredir.debian.org/debian/
+MIRROR_DEBIAN=http://deb.debian.org/debian/
MIRROR_UBUNTU=http://mirror.netcologne.de/ubuntu/
MIRROR_CENTOS=http://mirror.netcologne.de/
EXCLUDE_SQUEEZE=isc-dhcp-client,isc-dhcp-common,info,tasksel,tasksel-data
EXCLUDE_WHEEZY=info,tasksel,tasksel-data
-EXCLUDE_JESSIE=tasksel,tasksel-data
-EXCLUDE_STRETCH=tasksel,tasksel-data
+EXCLUDE_JESSIE=info,tasksel,tasksel-data
+EXCLUDE_STRETCH=info,tasksel,tasksel-data
+EXCLUDE_BUSTER=tasksel,tasksel-data
EXCLUDE_TRUSTY=dhcp3-client,dhcp3-common,info
-EXCLUDE_XENIAL=tasksel,tasksel-data
+EXCLUDE_XENIAL=udhcpc,dibbler-client,info,tasksel,tasksel-data
+# we need aptitude in the base file, since users may want to use it for installing packages
INCLUDE_DEBIAN=aptitude
mkpost-centos() {
+ # set local mirror for rinse post script
[ -z "$MIRROR_CENTOS" ] && return
cat <<EOM > $xtmp/post
#! /bin/sh
mkpost-slc() {
+ # set local mirror for rinse post script
ver=$1
[ -z "$MIRROR_SLC" ] && return
cat <<EOM > $xtmp/post
cleanup-deb() {
- chroot $xtmp aptitude clean
- rm -f $xtmp/etc/hostname $xtmp/etc/resolv.conf $xtmp/etc/machine-id
- rm $xtmp/var/lib/apt/lists/*_*
- rm -f $xtmp/etc/udev/rules.d/70-persistent-net.rules
+ chroot $xtmp apt-get clean
+ rm -f $xtmp/etc/hostname $xtmp/etc/resolv.conf \
+ $xtmp/var/lib/apt/lists/*_* $xtmp/usr/bin/qemu-*-static \
+ $xtmp/etc/udev/rules.d/70-persistent-net.rules
+ > $xtmp/etc/machine-id
}
local DIST=$1
shift
local mirror=$1
+ shift
+ local arch=$1
- if [[ $DIST =~ 64 ]]; then
- arch=amd64
- else
- arch=i386
- fi
-
- DIST=${DIST%%??}
- dist=${DIST,,}
+ dist=${DIST%%[0-9][0-9]}
+ local exc="EXCLUDE_$dist"
+ dist=${dist,,}
- local exc="EXCLUDE_$DIST"
check
- debootstrap --arch $arch --exclude=${!exc} --include=${INCLUDE_DEBIAN} $dist $xtmp $mirror
+ if [ -n "$arch" ]; then
+ qemu-debootstrap --arch $arch --exclude=${!exc} --include=${INCLUDE_DEBIAN} $dist $xtmp $mirror
+ target="${target}_${arch^^}"
+ else
+ if [[ $DIST =~ 64 ]]; then
+ arch=amd64
+ else
+ arch=i386
+ fi
+ debootstrap --arch $arch --exclude=${!exc} --include=${INCLUDE_DEBIAN} $dist $xtmp $mirror
+ fi
cleanup-deb
tarit
}
WHEEZY32 WHEEZY64
JESSIE32 JESSIE64
STRETCH32 STRETCH64
+ BUSTER32 BUSTER64
"
}
cat <<EOF
mk-basefile, create minimal base files for a Linux distritubtion
- Copyright (C) 2011-2016 by Thomas Lange
+ Copyright (C) 2011-2017 by Thomas Lange
Usage: mk-basefile [OPTION] ... DISTRIBUTION
-s Show list of supported linux distributions
-a Add xtattrs, acl and selinux properties to the tar file.
+ -f ARCH Build for foreign architecture ARCH.
-d DIR Use DIR for creating the temporary subtree structure.
-z Use gzip for compressing the tar file.
-J Use xz for compressing the tar file.
attributes=
cleanup=1
-while getopts ashzJd:k opt ; do
+while getopts ashzJd:kf: opt ; do
case "$opt" in
a) attributes="--xattrs --selinux --acl" ;;
d) export TMPDIR=$OPTARG ;;
+ f) export ARCH=$OPTARG ;;
z) zip="gzip -9"; ext=tar.gz ;;
J) zip="xz -8" ext=tar.xz ;;
k) cleanup=0 ;;
target=$1 # also the name of the output file
+[ -z "$target" ] && usage
case "$target" in
CENTOS5_32) centos i386 5 ;;
CENTOS5_64) centos amd64 5 ;;
SLC7_64) slc amd64 7 ;;
TRUSTY*|XENIAL*)
debgeneric $target $MIRROR_UBUNTU ;;
- SQUEEZE*|WHEEZY*|JESSIE*|STRETCH*)
- debgeneric $target $MIRROR_DEBIAN ;;
+ SQUEEZE*|WHEEZY*|JESSIE*|STRETCH*|BUSTER*)
+ debgeneric $target $MIRROR_DEBIAN $ARCH;;
*) echo "Unknown distribution. Aborting."
prtdists
exit 99 ;;
[ "$cmdlineclasses" ] || exit 0
-# define the classes given on the cmdline (suing -c) very early
+# define the classes given on the cmdline (using -c) very early
echo $cmdlineclasses
exit 0
-
#! /bin/bash
# parse *.profile and build a curses menu, so the user can select a profile
# if you want to use the faiserver as APT proxy
#APTPROXY=http://faiserver:3142
+
+apt_cdn=http://deb.debian.org
disk_config disk1 disklabel:msdos bootable:1 fstabkey:uuid align-at:1M
-primary / 300- ext4 rw,nobarrier,noatime,errors=remount-ro tuneopts="-c 0 -i 0"
+primary / 300- ext4 rw,barrier=0,noatime,errors=remount-ro tuneopts="-c 0 -i 0"
--- /dev/null
+# example of new config file for setup-storage
+#
+# <type> <mountpoint> <size> <fs type> <mount options> <misc options>
+
+# this is a copy of FAIBASE, but with metadata_csum disabled.
+# Ubuntu XENIAL does not yet suport this option
+
+disk_config disk1 disklabel:msdos bootable:1 fstabkey:uuid
+
+primary / 2G-15G ext4 rw,noatime,errors=remount-ro createopts="-O ^metadata_csum"
+logical swap 200-1G swap sw
+logical /tmp 100-1G ext4 rw,noatime,nosuid,nodev createopts="-L tmp -m 0 -O ^metadata_csum" tuneopts="-c 0 -i 0"
+logical /home 100-50% ext4 rw,noatime,nosuid,nodev createopts="-L home -m 1 -O ^metadata_csum" tuneopts="-c 0 -i 0"
-deb http://httpredir.debian.org/debian {release} main contrib non-free
-deb http://httpredir.debian.org/debian {release}-backports main
-deb http://security.debian.org/debian-security {release}/updates main contrib non-free
+deb {apt_cdn}/debian {release} main contrib non-free
+deb {apt_cdn}/debian {release}-backports main
+deb {apt_cdn}/debian-security {release}/updates main contrib non-free
deb http://packages.cloud.google.com/apt cloud-sdk-{release} main
deb http://packages.cloud.google.com/apt google-cloud-packages-archive-keyring-{release} main
-deb http://httpredir.debian.org/debian stretch main contrib non-free
-deb http://httpredir.debian.org/debian-security stretch/updates main contrib non-free
+deb {apt_cdn}/debian stretch main contrib non-free
+deb {apt_cdn}/debian-security stretch/updates main contrib non-free
#! /bin/bash
# replace {release} in a sources.list template with the value of $release
-
+# replace {apt_cdn} with the value of $apt_cdn
# $1 is the class name used
# $2 is the path to the file copied
if [ -z "$release" ]; then
echo "\$release is undefined. No substitution performed in $2."
- exit 0
+else
+ sed -i -e "s/{release}/$release/g" $2
+fi
+
+if [ -z "$apt_cdn" ]; then
+ echo "\$apt_cdn not defined. not substituting in $2."
+else
+ sed -i -e "s#{apt_cdn}#$apt_cdn#g" $2
fi
-sed -i -e "s/{release}/$release/g" $2
--- /dev/null
+# Disable systemd's network interface name management.
+# References:
+# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=863385
+# https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/
+
+GRUB_CMDLINE_LINUX_DEFAULT="$GRUB_CMDLINE_LINUX_DEFAULT net.ifnames=0"
-deb http://httpredir.debian.org/debian stretch main contrib non-free
-deb http://security.debian.org/debian-security stretch/updates main contrib non-free
+deb http://deb.debian.org/debian stretch main contrib non-free
+deb http://deb.debian.org/debian-security stretch/updates main contrib non-free
# repository that may contain newer fai packages for stretch
deb [trusted=yes] http://fai-project.org/download stretch koeln
# For a detailed description see nfsroot.conf(5)
# "<suite> <mirror>" for debootstrap
-FAI_DEBOOTSTRAP="stretch http://httpredir.debian.org/debian"
+FAI_DEBOOTSTRAP="stretch http://deb.debian.org/debian"
FAI_ROOTPW='$1$kBnWcO.E$djxB128U7dMkrltJHPf6d1'
NFSROOT=/srv/fai/nfsroot
#! /bin/bash
# regenerate ssh_host keys
-ls /etc/ssh/ssh_host_* > /dev/null
+ls /etc/ssh/ssh_host_* >/dev/null 2>&1
if [ $? -ne 0 ]; then
dpkg-reconfigure -fnoninteractive openssh-server
fi
set -o pipefail
# setup network
-nic=$(grep iface /etc/network/interfaces| awk '{print $2}'|egrep -v ^lo)
+nic=$(awk '/iface/ {print $2}' /etc/network/interfaces |egrep -v ^lo)
ifup $nic
# regenerate ssh_host keys
ls /etc/ssh/ssh_host_* > /dev/null
dpkg-reconfigure -fnoninteractive openssh-server
fi
sleep 8
-[ -x /etc/init.d/nscd ] && /etc/init.d/nscd restart
+[ -x /etc/init.d/nscd ] && invoke-rc.d nscd restart
echo "================================="
echo "Setting up the FAI install server"
However, I can not read the target:
Warning: The partition table looks like it was made
task_error=0
+task_local_error=0
^info: Trying to set
warning: /usr/lib/X11/fonts
can't read /etc/udev/rules.d/z25_persistent-net.rules
can't initialize ip6tables table
Authentication warning overridden
41-warning.sh
+Download is performed unsandboxed as root as file
update-alternatives: warning: skip creation of
loop: module verification failed: signature
Warning: apt-key output should not be parsed
if [ -n $FAI_ALLOW_UNSIGNED ] ; then
globalignorepatterns="$globalignorepatterns
WARNING: untrusted versions
+WARNING: The following packages cannot be authenticated
Ignoring these trust violations"
fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+PACKAGES install
+# you may want these non-free kernel drivers
+#firmware-bnx2 firmware-bnx2x firmware-realtek
+#firmware-linux
+
PACKAGES install I386
linux-image-686-pae initramfs-tools
memtest86+
linux-image-amd64 initramfs-tools
memtest86+
+PACKAGES install ARM64
+grub-efi-arm64
+linux-image-arm64
+
PACKAGES install DHCPC
isc-dhcp-client
PACKAGES install CLOUD
locales-all
+unattended-upgrades
PACKAGES install-norec DEBIAN
+apt-transport-https
fai-client
debconf-utils
file
locales
console-setup kbd
pciutils usbutils
+unattended-upgrades
PACKAGES install
google-cloud-packages-archive-keyring
cloud-initramfs-growroot
-cloud-utils/$release-backports
+cloud-utils
google-cloud-sdk
google-compute-engine-$release
google-compute-engine-init-$release
google-config-$release
-python-crcmod/$release-backports
+python-crcmod
screen
vim
PACKAGES install-norec
-iceweasel
-#icedove
+firefox-esr
+#thunderbird
menu gdm3
gnome-core
gconf-editor
xfce4 # base system
xfce4-goodies # additional tools
lightdm
-iceweasel
+firefox-esr
xscreensaver-gl
xterm
desktop-base
-
-# add free and non-free firmware
-#firmware-linux
--- /dev/null
+#!/bin/bash
+
+error=0; trap 'error=$(($?>$error?$?:$error))' ERR # save maximum error code
+
+# Disable systemd's network interface name management.
+# References:
+# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=863385
+# https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/
+
+fcopy -M /etc/default/grub.d/10_cloud_disable_net.ifnames.cfg
+$ROOTCMD update-grub
ainsl -a /etc/modprobe.d/blacklist.conf 'blacklist pcspkr'
ainsl -a /etc/modprobe.d/blacklist.conf 'blacklist floppy'
-rm -f $target/etc/resolv.conf $target/etc/udev/rules.d/70-persistent-net.rules $target/lib/udev/write_net_rules
+rm -f $target/etc/resolv.conf \
+ $target/etc/udev/rules.d/70-persistent-net.rules \
+ $target/lib/udev/write_net_rules \
+ $target/etc/mailname \
+ $target/var/lib/dbus/machine-id
+
+> $target/etc/machine-id
+
shred --remove $target/etc/ssh/ssh_host_*
# FIXME: DHCP RFC3442 is used incorrect in Azure
sed -i -e 's#sbin/agetty --noclear#sbin/agetty -f /etc/issue.linuxlogo --noclear#' $target/lib/systemd/system/getty@.service
fi
-if [ ! -f $target/etc/machine-id -a -f $target/bin/systemd-machine-id-setup ]; then
+# make sure a machine-id exists
+if [ ! -f $target/etc/machine-id ]; then
+ > $target/etc/machine-id
+fi
+# recreate machine-id if the file is empty
+if [ X"$(stat -c '%s' $target/etc/machine-id 2>/dev/null)" = X0 -a -f /bin/systemd-machine-id-setup ]; then
$ROOTCMD systemd-machine-id-setup
fi
exit $error
fi
-$ROOTCMD grub-mkdevicemap --no-floppy
GROOT=$($ROOTCMD grub-probe -tdrive -d $BOOT_DEVICE)
done
elif [[ $GROOT =~ 'hostdisk' ]]; then
- cat > $target/boot/grub/device.map <<EOF
-(hd0) $BOOT_DEVICE
-EOF
$ROOTCMD grub-install --no-floppy --force-extra-removable --modules=part_gpt --no-nvram $BOOT_DEVICE
if [ $? -eq 0 ]; then
echo "Grub installed on hostdisk $BOOT_DEVICE"
fi
- rm $target/boot/grub/device.map
else
$ROOTCMD grub-install --no-floppy --modules=part_gpt "$GROOT"
exit $error
fi
-$ROOTCMD grub-mkdevicemap --no-floppy
GROOT=$($ROOTCMD grub-probe -tdrive -d $BOOT_DEVICE)
done
elif [[ $GROOT =~ 'hostdisk' ]]; then
- cat > $target/boot/grub/device.map <<EOF
-(hd0) $BOOT_DEVICE
-EOF
$ROOTCMD grub-install --no-floppy --modules=part_msdos $BOOT_DEVICE
if [ $? -eq 0 ]; then
echo "Grub installed on hostdisk $BOOT_DEVICE"
fi
- rm $target/boot/grub/device.map
else
$ROOTCMD grub-install --no-floppy "$GROOT"
# Make sure everything is configured properly
if ifclass DEBIAN ; then
- echo "Running \"apt-get -f install\" for the last time."
$ROOTCMD apt-get -f install
fi
if [ $FAI_ACTION = "install" ]; then
lskernels=$(echo $target/boot/vmlinu*)
- [ -f ${lskernels%% *} ] || echo "ERROR: No kernel was installed. Have a look at shell.log" >&2
+ if [ ! -f ${lskernels%% *} ]; then
+ echo "ERROR: No kernel was installed. Have a look at shell.log" >&2
+ error=1
+ fi
fi
# copy sources.list
break
fi
done
- echo "\$release set to $release"
}
# if installation was done from CD, replace useless sources.list
setrel
if [ -f $target/etc/apt/sources.list -a -n "$release" ]; then
grep -q 'file generated by fai-cd' $target/etc/apt/sources.list && cat <<EOF > $target/etc/apt/sources.list
-deb http://httpredir.debian.org/debian $release main contrib non-free
-deb http://httpredir.debian.org/debian-security $release/updates main contrib non-free
+deb $apt_cdn/debian $release main contrib non-free
+deb $apt_cdn/debian-security $release/updates main contrib non-free
deb [trusted=yes] http://fai-project.org/download $release koeln
EOF
fi
+# for ARM architecture, we may need the kernel and initrd to boot or flash the device
+if ifclass ARM64; then
+ cp -pv $target/boot/vmlinuz* $target/boot/initrd* $LOGDIR
+fi
+
exit $error