Skip to content

Commit

Permalink
Merge tag '5.9' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
Mrfai committed Jan 25, 2020
2 parents 3019bfa + 5dbe4d2 commit d12261f
Show file tree
Hide file tree
Showing 30 changed files with 438 additions and 163 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ LIBDIR = $(DESTDIR)/usr/lib/fai
SHAREDIR = $(DESTDIR)/usr/share/fai
USRSBIN_SCRIPTS = fai-make-nfsroot fai-setup fcopy ftar install_packages fai-chboot fai-monitor fai-cd fai faireboot fai-statoverride setup-storage dhcp-edit fai-new-mac fai-diskimage

USRBIN_SCRIPTS = fai-class fai-do-scripts fai-mirror fai-debconf device2grub policy-rc.d.fai ainsl fai-monitor-gui fai-deps fai-mk-configspace
USRBIN_SCRIPTS = fai-class fai-do-scripts fai-mirror fai-debconf device2grub policy-rc.d.fai ainsl fai-link fai-sed fai-monitor-gui fai-deps fai-mk-configspace

# for syntax checks
BASH_SCRIPTS = bin/fai bin/fai-cd bin/fai-class bin/fai-debconf bin/fai-do-scripts bin/fai-make-nfsroot bin/fai-mirror bin/fai-setup bin/fai-diskimage bin/fai-statoverride bin/faireboot bin/ftar dev-utils/fai-kvm dev-utils/fai-mk-network examples/simple/basefiles/mk-basefile examples/simple/class/*.sh examples/simple/class/[0-9]* examples/simple/files/etc/rc.local/FAISERVER examples/simple/hooks/* examples/simple/scripts/*/* lib/fai-divert lib/fai-mount-disk lib/fai-savelog lib/fetch-basefile lib/get-boot-info lib/get-config-dir* lib/mkramdisk lib/mount2dir lib/prcopyleft lib/subroutines lib/task_* lib/updatebase lib/dracut/*/* bin/fai-mk-configspace lib/check-cross-arch
BASH_SCRIPTS = bin/fai bin/fai-cd bin/fai-class bin/fai-debconf bin/fai-do-scripts bin/fai-make-nfsroot bin/fai-mirror bin/fai-setup bin/fai-diskimage bin/fai-statoverride bin/faireboot bin/ftar bin/fai-link bin/fai-sed dev-utils/fai-kvm dev-utils/fai-mk-network examples/simple/basefiles/mk-basefile examples/simple/class/*.sh examples/simple/class/[0-9]* examples/simple/files/etc/rc.local/FAISERVER examples/simple/hooks/* examples/simple/scripts/*/* lib/fai-divert lib/fai-mount-disk lib/fai-savelog lib/fetch-basefile lib/get-boot-info lib/get-config-dir* lib/mkramdisk lib/mount2dir lib/prcopyleft lib/subroutines lib/task_* lib/updatebase lib/dracut/*/* bin/fai-mk-configspace lib/check-cross-arch
SHELL_SCRIPTS = bin/dhclient-fai-script bin/policy-rc.d.fai lib/check_status lib/create_resolv_conf lib/fai-abort lib/fai-disk-info lib/load_keymap_consolechars utils/mkdebmirror
PERL_SCRIPTS = lib/setup-storage/*.pm bin/ainsl bin/device2grub bin/dhcp-edit bin/fai-chboot bin/fai-deps bin/fai-monitor bin/fai-monitor-gui bin/fai-new-mac bin/fcopy bin/install_packages bin/setup-storage dev-utils/setup-storage_deps-graph.pl examples/simple/tests/Faitest.pm lib/dhclient-perl lib/fai-savelog-ftp

Expand Down
8 changes: 8 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
fai (5.9) unstable; urgency=low

* add UEFI support to fai-cd, fai-kvm
* add disk configs for UEFI
* new scripts fai-sed, fai-link

-- Thomas Lange <lange@debian.org> Thu, 02 Jan 2020 22:23:36 +0100

fai (5.8.7) unstable; urgency=low

* support apt keys in files called package_config/CLASS.gpg
Expand Down
2 changes: 1 addition & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ Thomas Lange

My GPG Key is: 4096R/074BCDE4 B11E E327 3F6B 2DEB 528C 93DA 2BF8 D9FE 074B CDE4
--------------------------------------------------------------------------------
Copyright (c) 1999-2019 Thomas Lange. All rights reserved.
Copyright (c) 1999-2020 Thomas Lange. All rights reserved.
92 changes: 58 additions & 34 deletions bin/fai-cd
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# fai-cd -- make a fai CD, a bootable CD that performs the FAI
#
# This script is part of FAI (Fully Automatic Installation)
# (c) 2004-2019 by Thomas Lange, lange@informatik.uni-koeln.de
# (c) 2004-2020 by Thomas Lange, lange@informatik.uni-koeln.de
# Universitaet zu Koeln
# Support for grub2 added by Sebastian Hetze, s.hetze@linux-ag.de
# with major support from Michael Prokop, prokop@grml-solutions.com
Expand Down Expand Up @@ -34,7 +34,6 @@ set -e

# last die exit code 22

boot_image="boot/grub/eltorito.img"
count=0
space=0
config_space=""
Expand All @@ -61,7 +60,7 @@ hidedirs="/usr/share/locale /usr/share/doc /var/lib/apt /var/lib/aptitude /var/c
usage() {

cat <<-EOF
fai-cd Copyright (C) 2004-2019 Thomas Lange
fai-cd Copyright (C) 2004-2020 Thomas Lange
Usage: fai-cd [OPTIONS] -m MIRRORDIR ISONAME
Usage: fai-cd [OPTIONS] -B ISONAME
Expand Down Expand Up @@ -97,7 +96,8 @@ check_programs() {
local msg
[ $squash_only -eq 0 ] && ! command -v xorriso >&/dev/null && msg+="xorriso not found. Please install package."
command -v mksquashfs >&/dev/null || msg+="\nmksquashfs not found. Please install the package squashfs-tools."
command -v parted >&/dev/null || msg+="\ncommand parted not found. Please install package parted."
command -v mkfs.vfat >&/dev/null || msg+="\nmkfs.vfat not found. Please install the package dosfstools."
command -v mcopy >&/dev/null || msg+="\nmcopy not found. Please install the package mtools."

if [ -n "$msg" ]; then
die 8 "$msg"
Expand Down Expand Up @@ -186,36 +186,47 @@ create_squashfs_image() {
# - - - - - - - - - - - - - - - - - - - - - - - - - -
create_grub2_image() {

mkdir -p $tmp/boot/grub $NFSROOT/boot/grub
if [ -f $NFSROOT/boot/grub/core.img ]; then
:
elif [ -f $NFSROOT/usr/lib/grub/i386-pc/cdboot.img ]; then
chroot $NFSROOT /usr/bin/grub-mkimage -p /boot/grub -d /usr/lib/grub/i386-pc -o /boot/grub/core.img biosdisk iso9660 --format=i386-pc
mkdir -p $tmp/boot

if [ -d $NFSROOT/usr/lib/grub/x86_64-efi ]; then
cp $grub_config $NFSROOT/tmp/grub.cfg
# insert date into grub menu
perl -pi -e "s/_VERSIONSTRING_/ $isoversion /" $NFSROOT/tmp/grub.cfg
if [ -n "$config_space" ] || [ $configset -eq 1 ]; then
perl -pi -e "s|FAI_CONFIG_SRC=(.*?)\S+|FAI_CONFIG_SRC=$config_space|" $NFSROOT/tmp/grub.cfg
fi

chroot $NFSROOT grub-mkstandalone \
--format=x86_64-efi \
--output=/tmp/bootx64.efi \
--locales="" --fonts="" \
"boot/grub/grub.cfg=/tmp/grub.cfg"
mv $NFSROOT/tmp/bootx64.efi $scratch

dd if=/dev/zero of=$scratch/efiboot.img bs=1M count=3 2>/dev/null
mkfs.vfat $scratch/efiboot.img
mmd -i $scratch/efiboot.img efi efi/boot
mcopy -i $scratch/efiboot.img $scratch/bootx64.efi ::efi/boot/
else
die 11 "No grub-pc installation found in NFSROOT. Aborting."
die 11 "No grub-efi-amd64-bin installation found in NFSROOT. Aborting."
fi
cp $NFSROOT/boot/grub/core.img $tmp/boot/grub
cp $NFSROOT/boot/grub/unicode.pf2 $tmp/boot/grub

grubtarget=$tmp/boot/grub/i386-pc
mkdir -p $grubtarget
for a in $NFSROOT/usr/lib/grub/*-pc/{*.mod,efiemu??.o,cdboot.img,boot.img,command.lst,moddep.lst,fs.lst,handler.lst,parttool.lst}; do
[[ -e $a ]] && cp $a $grubtarget
done
cp $grub_config $tmp/boot/grub/grub.cfg
# insert date into grub menu
perl -pi -e "s/_VERSIONSTRING_/ $isoversion /" $tmp/boot/grub/grub.cfg
if [ -n "$config_space" ] || [ $configset -eq 1 ]; then
perl -pi -e "s|FAI_CONFIG_SRC=(.*?)\S+|FAI_CONFIG_SRC=$config_space|" $tmp/boot/grub/grub.cfg
if [ -d $NFSROOT/usr/lib/grub/i386-pc ]; then
chroot $NFSROOT grub-mkstandalone \
--format=i386-pc \
--output=/tmp/core.img \
--locales="" --fonts="" \
--install-modules="linux normal iso9660 biosdisk memdisk search ls echo test chain msdospart part_msdos part_gpt minicmd ext2 keystatus all_video font sleep gfxterm" \
--modules="linux normal iso9660 biosdisk search" \
"boot/grub/grub.cfg=/tmp/grub.cfg"
cat $NFSROOT/usr/lib/grub/i386-pc/cdboot.img $NFSROOT/tmp/core.img > $scratch/bios.img
rm $NFSROOT/tmp/core.img
else
die 11 "No grub-pc installation found in NFSROOT. Aborting."
fi
cp -p $NFSROOT/boot/vmlinuz-$kernelversion $tmp/boot/vmlinuz
cp -p $NFSROOT/boot/initrd.img-$kernelversion $tmp/boot/initrd.img
cp -p $NFSROOT/boot/config-$kernelversion $tmp/boot/
cat $grubtarget/cdboot.img $tmp/boot/grub/core.img > $tmp/boot/grub/eltorito.img
boot_image="boot/grub/eltorito.img"

embed_image="$tmp/boot/grub/embed.img"
cat $grubtarget/boot.img $tmp/boot/grub/core.img > $embed_image
touch $tmp/FAI-CD
}
# - - - - - - - - - - - - - - - - - - - - - - - - - -
calculate_required_size() {
Expand Down Expand Up @@ -305,7 +316,7 @@ cleanup_liveos_mounts() {

mountpoint -q $tmp/$liveos/mounted-ext3fs && umount $tmp/$liveos/mounted-ext3fs
unhide_dirs
rm -rf $tmp
rm -rf $tmp $scratch
if [ $autodiscover -eq 1 ]; then
local initrdfiles=($ONFSROOT/tmp/initrd.img*)
if [[ -e $initrdfiles ]]; then
Expand All @@ -317,11 +328,23 @@ cleanup_liveos_mounts() {
mkiso() {

echo "Writing FAI CD-ROM image to $isoname. This may need some time."
xorriso -report_about HINT -as mkisofs -iso-level 3 -graft-points -b $boot_image \
-V "$vname" -A "$aname" \
-no-emul-boot -boot-info-table --embedded-boot ${embed_image} -partition_offset 16 -no-pad -o $isoname \
-R $tmp --sort-weight 0 / --sort-weight 1 /boot || die 12 "xorriso failed."
parted $isoname set 1 boot on
xorriso -report_about HINT -as mkisofs -iso-level 3 \
-iso_mbr_part_type 00 \
-full-iso9660-filenames \
-volid "$vname" -appid "$aname" \
-eltorito-boot boot/grub/bios.img \
-no-emul-boot -boot-load-size 4 -boot-info-table \
--eltorito-catalog boot/grub/boot.cat \
--grub2-boot-info \
--grub2-mbr $NFSROOT/usr/lib/grub/i386-pc/boot_hybrid.img \
-eltorito-alt-boot -e EFI/efiboot.img -no-emul-boot \
-append_partition 2 0xef $scratch/efiboot.img \
-o $isoname -graft-points \
--sort-weight 0 / --sort-weight 1 /boot \
"$tmp" \
/boot/grub/bios.img=$scratch/bios.img \
/EFI/efiboot.img=$scratch/efiboot.img || die 12 "xorriso failed."

echo -n "ISO image size and filename: "; du -h $isoname

unhide_dirs
Expand Down Expand Up @@ -485,6 +508,7 @@ if [ $bootonly -eq 0 -o $configset -eq 1 ]; then
fi

tmp=$(mktemp -t -d fai-cd.XXXXXX) || exit 13
scratch=$(mktemp -t -d scratch.XXXXXX) || exit 13

trap "cleanup_liveos_mounts" EXIT ERR

Expand Down
48 changes: 48 additions & 0 deletions bin/fai-link
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#! /bin/bash

# create a symlink, idempotent
#
# (c) Thomas Lange 2019, lange@debian.org
#
# if $target is defined, create link relative to $target

mk-link() {


local from=$1
local to=$2
local oldto
local vopt

if [ X$verbose = X1 ]; then
vopt=-v
fi

# todo: check if $from starts with a slash

if [ -n "$target" ]; then
from="$target$from"
fi

if [ ! -e $from -a ! -h $from ]; then
ln -s $vopt $to $from
return
fi

# check if already same link
if [ -h $from ]; then
oldto=$(readlink $from)
if [ $oldto = $to ]; then
if [ X$verbose = X1 ]; then
printf "fai-link: Nothing to do for link $from -> $to\n"
fi
return
fi
fi

# if different create new link
ln -sf $vopt $to $from
}

# make link from to
mk-link $1 $2
5 changes: 3 additions & 2 deletions bin/fai-make-nfsroot
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# fai-make-nfsroot -- create nfsroot directory and add additional packages
#
# This script is part of FAI (Fully Automatic Installation)
# (c) 2000-2019 by Thomas Lange, lange@informatik.uni-koeln.de
# (c) 2000-2020 by Thomas Lange, lange@informatik.uni-koeln.de
# Universitaet zu Koeln
# (c) 2004 by Henning Glawe, glaweh@physik.fu-berlin.de
# Freie Universitaet Berlin
Expand All @@ -32,7 +32,7 @@
usage() {

cat <<-EOF
Copyright (C) 1999-2019 Thomas Lange
Copyright (C) 1999-2020 Thomas Lange
Usage: fai-make-nfsroot [OPTIONS]
Create an NFSROOT for FAI.
Expand Down Expand Up @@ -667,6 +667,7 @@ if [ -d $NFSROOT/proc ]; then
[ -L $NFSROOT/proc/self ] && die 1 "/proc is still mounted inside the nfsroot."
umount $NFSROOT/$MNTPOINT 2>/dev/null || true # it's safer to try to umount
# remove old nfsroot using a background process
rm -rf $deldir/../.will-now-be-deleted
mv $deldir $deldir/../.will-now-be-deleted
if [ $? -eq 1 ]; then
rm -rf $deldir
Expand Down
71 changes: 71 additions & 0 deletions bin/fai-sed
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#! /bin/bash

# fai-sed, call sed with diff before writing
#
# (c) Thomas Lange 2019, lange@debian.org
#

# idempotent sed. Execute sed command on a file
# but do not overwrite file if nothing has changed

dryrun=0

cmd=$1
shift
filename=$1
shift

if [ -z "$cmd" -o -z "$filename" ]; then
printf "Please add filename and sed command\n"
exit 3
fi

# do not allow more than one file
if [ -n "$1" ]; then
printf "Aborting. Too many arguments.\n"
exit 9
fi

if [ -n "$target" ]; then
filename="$target$filename"
fi

if [ ! -f $filename ]; then
printf "WARNING: $filename does not exists. Skipping\n"
exit 0
fi

tmp=$(mktemp)
trap "rm $tmp" EXIT

printf "sed -e $cmd $filename: "
# cp file so we can use sed -i, otherwise the new file created by sed has different chmod, owner
cp -p $filename $tmp
sed -i -e "$cmd" $tmp
res=$?
if [ $res -ne 0 ]; then
printf "sed error $res\n"
exit $res
fi

cmp -s $filename $tmp
res=$?
if [ $res -eq 2 ]; then
printf " diff error $res. No changes made to $filename\n"
exit 2
elif [ $res -eq 0 ]; then
printf " No changes.\n"
if [ $dryrun -eq 1 ]; then
exit 0
fi
else
if [ $dryrun -eq 1 ]; then
printf " Dry-run. Changes not applied.\n"
exit 0
else
mv $tmp $filename
printf " File changed.\n"
trap '' EXIT
exit 1
fi
fi
7 changes: 5 additions & 2 deletions bin/install_packages
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# (c) 2003-2004, Henning Glawe, glaweh@physik.fu-berlin.de
# (c) 2004 , Jonas Hoffmann, jhoffman@physik.fu-berlin.de
# PRELOAD feature from Thomas Gebhardt <gebhardt@hrz.uni-marburg.de>
# (c) 2019 , TUXEDO Computers GmbH, tux@tuxedocomputers.com
#
#*********************************************************************
# This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -71,7 +72,7 @@ $| = 1;


# @commands is the order of the commands that are executed
our @commands = qw/y2i y2r zypper zypper-rm yast rpmr urpmi urpme yumgroup yumi yumr dnfgroup dnfi dnfr smarti smartr hold taskrm taskinst clean-internal cupt cupt-r install install-norec aptitude aptitude-r unpack remove dselect-upgrade/;
our @commands = qw/y2i y2r zypper zypper-pattern zypper-product zypper-rm yast rpmr urpmi urpme yumgroup yumi yumr dnfgroup dnfi dnfr smarti smartr hold taskrm taskinst clean-internal cupt cupt-r install install-norec aptitude aptitude-r unpack remove dselect-upgrade/;
%command = (
"install" => "apt-get $aptopt --fix-missing install",
"install-norec" => "apt-get $aptopt --fix-missing install --no-install-recommends",
Expand Down Expand Up @@ -101,7 +102,9 @@ our @commands = qw/y2i y2r zypper zypper-rm yast rpmr urpmi urpme yumgroup yumi
"y2i" => "y2pmsh isc",
"y2r" => "y2pmsh remove",
"yast" => "yast -i",
"zypper" => "zypper -n install",
"zypper" => "zypper -n install -l",
"zypper-pattern" => "zypper -n install -l -t pattern",
"zypper-product" => "zypper -n install -l -t product",
"zypper-rm" => "zypper -n remove",
"rpmr" => "rpm -e",
"smarti" => "smart install -y",
Expand Down

0 comments on commit d12261f

Please sign in to comment.