Skip to content

Commit

Permalink
Merge tag '5.5' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Lange committed Nov 8, 2017
2 parents ecff9b4 + 0de9ef3 commit b869f0e
Show file tree
Hide file tree
Showing 68 changed files with 520 additions and 457 deletions.
10 changes: 10 additions & 0 deletions debian/NEWS → NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
fai (5.5) unstable; urgency=low

* New option -S in fcopy for variable substitution, which may replace
your preinst scripts
* Get rid of the need to have aptitude installed
* Change order of package commands in install_packages, aptitude is now
called after apt-get

-- Thomas Lange <lange@debian.org> Thu, 19 Oct 2017 22:47:20 +0200

fai (5.4) unstable; urgency=low

* FAI can now build cross-architecture disk images and chroot
Expand Down
2 changes: 1 addition & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The home page for FAI is

https://fai-project.org/

This release of FAI is tested with the Debian 8 release.
This release of FAI is tested with the Debian 9 release.

FAI is free software, distributed under the terms of the GNU General
Public License, version 2. For more information, see the file
Expand Down
8 changes: 6 additions & 2 deletions bin/fai
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,13 @@ if [ $do_init_tasks -eq 1 ]; then
read hname < /proc/sys/kernel/hostname
if [ -z "$HOSTNAME" -o $HOSTNAME = '(none)' -o -z "$hname" ]; then
myip=$(ip ad show up | grep -w inet | cut -d t -f 2 | cut -d ' ' -f 2 | cut -d / -f 1 | grep -v 127.0.0.1| tr '.' '-')
export HOSTNAME="ip-$myip"
if [ -n "$myip" ]; then
export HOSTNAME="ip-$myip"
else
export HOSTNAME=debian
fi
echo $HOSTNAME > /proc/sys/kernel/hostname
echo "Using IP for setting the host name: $HOSTNAME"
echo "Setting the host name: $HOSTNAME"
fi
unset hname myip

Expand Down
62 changes: 27 additions & 35 deletions bin/fai-cd
Original file line number Diff line number Diff line change
Expand Up @@ -176,40 +176,20 @@ create_grub2_image() {

mkdir -p $tmp/boot/grub $NFSROOT/boot/grub
if [ -f $NFSROOT/boot/grub/core.img ]; then
cp $NFSROOT/boot/grub/core.img $tmp/boot/grub
MODULEBASE=$NFSROOT/usr/lib/grub
:
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
cp $NFSROOT/boot/grub/core.img $tmp/boot/grub
MODULEBASE=$NFSROOT/usr/lib/grub
else
echo "no grub2 installation found in NFSROOT, using downloaded $grubPackage"
apt-get -y -d install --reinstall grub-pc >/dev/null
grubPackage=`ls -rt /var/cache/apt/archives/grub-pc*|tail -1`
if [ -z "$grubPackage" ]; then
die 22 "Downloading grub2 failed."
fi
GRUBDIR=$tmp/grubPackage
mkdir -p $GRUBDIR
dpkg -x $grubPackage $GRUBDIR
cd $GRUBDIR
./usr/bin/grub-mkimage -p /boot/grub -d usr/lib/grub/*-pc -o $tmp/boot/grub/core.img biosdisk iso9660 --format=i386-pc
MODULEBASE=$GRUBDIR/usr/lib/grub
fi

# check for jessie path
if strings $NFSROOT/usr/lib/grub/i386-pc/kernel.img | grep -q i386-pc/%s.mod; then
grubtarget=$tmp/boot/grub/i386-pc
else
# wheezy
grubtarget=$tmp/boot/grub
die 11 "No grub-pc 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 $MODULEBASE/*-pc/{*.mod,efiemu??.o,cdboot.img,boot.img,command.lst,moddep.lst,fs.lst,handler.lst,parttool.lst}; do
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
rm -rf $GRUBDIR
cp $grub_config $tmp/boot/grub/grub.cfg
# insert date into grub menu
perl -pi -e "s/_VERSIONSTRING_/ $isoversion /" $tmp/boot/grub/grub.cfg
Expand Down Expand Up @@ -249,11 +229,9 @@ provide_memtest_boot_option() {

if [ -f $NFSROOT/boot/memtest86+.bin ]; then
cp $NFSROOT/boot/memtest86+.bin $tmp/boot
elif [ -f /boot/memtest86+.bin ]; then
cp /boot/memtest86+.bin $tmp/boot
echo "Adding memtest86+ to grub menu"
else
echo "no memtest86+.bin found, omit memtest boot option"
return
return 0
fi

cat >> $tmp/boot/grub/grub.cfg <<EOF
Expand Down Expand Up @@ -339,7 +317,7 @@ addmirror() {

mkdir $tmp/$liveos/mounted-ext3fs/media/mirror

echo "Copying mirror to CD image"
echo "Copying the mirror to CD image"
cp -Pr $mirrordir/{dists,pool} $tmp/$liveos/mounted-ext3fs/media/mirror 2>/dev/null || die $? "Not enough space left on device for the mirror"

# create the sources.list for the CD
Expand All @@ -354,7 +332,7 @@ EOF
for i in $dists ; do
comp=$(find $mirrordir/dists/$i -maxdepth 2 -type d -name "binary-*" | \
sed -e "s#$mirrordir/*dists/$i/##" -e 's#/binary-.*##' | uniq | tr '\n' " ")
echo "deb file:/media/mirror $i $comp" >> $tmp/squashfs-root/LiveOS/mounted-ext3fs/etc/apt/sources.list
echo "deb [allow-insecure=yes] file:/media/mirror $i $comp" >> $tmp/squashfs-root/LiveOS/mounted-ext3fs/etc/apt/sources.list
done

}
Expand All @@ -367,9 +345,10 @@ burniso() {
# main program

# Parse commandline options
while getopts "AenkfhHg:Jbs:SBMm:C:d:" opt ; do
while getopts "AekfhHg:Jbs:SBMn:m:c:C:d:" opt ; do
case "$opt" in
A) autodiscover=1 ;;
c) csdir="$OPTARG" ;;
C) cdir="$OPTARG" ; arguments+=" -C $cdir";;
e) hidevartmp=1 ;;
f) forceremoval=1 ;;
Expand All @@ -379,6 +358,7 @@ while getopts "AenkfhHg:Jbs:SBMm:C:d:" opt ; do
J) sqopt="-comp xz" ; arguments+=" -J";;
M) nomirror=1 ;;
m) mirrordir="$OPTARG" ;;
n) setnfsroot="$OPTARG" ;;
b) burn=1 ; arguments+=" -b";;
s) space="$OPTARG" ;;
S) squash_only=1 ;;
Expand All @@ -395,10 +375,15 @@ if [ $autodiscover -eq 1 ]; then
nomirror=1
bootonly=1
hidedirs="
net/ceph
net/wireless
sound
net/ceph
fs/ceph
fs/ocfs2
fs/btrfs
fs/xfs
drivers/net/wireless
drivers/block/drbd
drivers/hwmon
drivers/staging/lustre
drivers/scsi
drivers/ata
Expand Down Expand Up @@ -446,6 +431,13 @@ fi
. $cfdir/fai.conf
. $cfdir/nfsroot.conf
: ${FAI:=/var/lib/fai/config} # default value

if [ -n "$setnfsroot" ]; then
NFSROOT=$setnfsroot # override by -n
fi
if [ -n "$csdir" ]; then
FAI_CONFIGDIR=$csdir # override by -c
fi
ONFSROOT=$NFSROOT # save original nfsroot

if [ $autodiscover -eq 1 ]; then
Expand Down
2 changes: 1 addition & 1 deletion bin/fai-chboot
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ if ($opt_i) {
# create config so host will boot the install kernel
$kernelname = "kernel ${opt_U}vmlinuz-$kernelsuffix";
$initrd = "initrd=${opt_U}initrd.img-$kernelsuffix";
$rootfs = "root=$nfsroot $bopt";
$rootfs = "root=$nfsroot:vers=3 $bopt";
$bootprot = "ip=dhcp ";

} elsif ($opt_o) {
Expand Down
6 changes: 6 additions & 0 deletions bin/fai-diskimage
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ cleanup() {
sleep $i
done
done

# call zerofree for ext2/3/4 devices if available
if [ -f /var/run/fai/zerofree.$$ -a -x /usr/sbin/zerofree ]; then
. /var/run/fai/zerofree.$$ 2>/dev/null
rm /var/run/fai/zerofree.$$
fi
losetup -d $loop
# if FAI created a volume group, we can remove it after the loop device is removed
if [ -f /var/run/fai/vgremove.$$ ]; then
Expand Down
56 changes: 34 additions & 22 deletions bin/fai-make-nfsroot
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,10 @@ adjust=0
generic=0
force=0
usexz=1
full=1

# option e currently does nothing
while getopts aghervC:B:fkKpUz opt ; do
while getopts aghervC:B:fkKpUzsN opt ; do
case "$opt" in
a) adjust=1 ;;
g) generic=1 ;;
Expand All @@ -109,9 +110,11 @@ while getopts aghervC:B:fkKpUz opt ; do
f) force=1 ;;
k) kinstall=1 ;;
K) kremove=1;;
N) nonfree=NONFREE ;;
h) usage ;;
e) expert=1 ;; # a dummy option, that only fai-setup uses
p) sshpreserve=1 ;;
s) full=0 ;; # do only install a smaller list of packages
?) exit 5 ;; # error in option parsing
esac
done
Expand Down Expand Up @@ -182,11 +185,16 @@ call_verbose() {
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
setclasses() {

local iarch distro
local iarch distro c
# Export all the information we have about the system
iarch=$($ROOTCMD dpkg --print-architecture|tr /a-z/ /A-Z/)
distro=$(. $NFSROOT/etc/os-release; echo ${ID} ${ID}_${VERSION_ID} | tr '[:lower:].' '[:upper:]_')
export classes="NFSROOT $iarch $distro"

# do we want to install the full list of packages?
if [ $full = 1 ]; then
c=FULL
fi
export classes="NFSROOT $c $iarch $distro $nonfree"
if [ X$verbose = X1 ] ; then
echo Classes are set to $classes
fi
Expand Down Expand Up @@ -357,6 +365,8 @@ extract_base() {
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
create_nfsroot() {

local fslist

mkdir -p $NFSROOT/$FAI
cd $NFSROOT || die 1 "Can't cd to $NFSROOT"

Expand All @@ -369,7 +379,6 @@ create_nfsroot() {
# save the list of all packages in the base.tar.gz
$ROOTCMD dpkg --get-selections | awk '/install$/ {print $1}' > var/tmp/base-pkgs.lis

setclasses
if [ -n "$FAI_DEBMIRROR" ]; then
[ X$verbose = X1 ] && echo "Mounting $FAI_DEBMIRROR to $NFSROOT/$MNTPOINT."
mkdir -p $NFSROOT/$MNTPOINT
Expand All @@ -394,11 +403,17 @@ EOF
# do not need all those filesystems inside the initrd
mkdir $NFSROOT/etc/dracut.conf.d
echo 'omit_dracutmodules+="dracut-systemd systemd systemd-initrd systemd-networkd systemd-initrd"' > $NFSROOT/etc/dracut.conf.d/12-no-systemd.conf
echo 'add_dracutmodules+=" livenet "' > $NFSROOT/etc/dracut.conf.d/13-add-cd-support.conf
if [ $full = 1 ];then
echo 'add_dracutmodules+=" livenet "' > $NFSROOT/etc/dracut.conf.d/13-add-cd-support.conf
fslist="nfs lockd ext4"
else
echo 'add_dracutmodules+=" dmsquash-live "' > $NFSROOT/etc/dracut.conf.d/13-add-cd-support.conf
fslist="ext4"
fi
echo 'hostonly="no"' > $NFSROOT/etc/dracut.conf.d/20-generic-image.conf
cat <<EOF > $NFSROOT/etc/dracut.conf.d/01-omit.conf
omit_dracutmodules+=" btrfs crypt dash lvm resume usrmount modsign mdraid shutdown dracut-systemd systemd systemd-initrd systemd-networkd systemd-initrd "
filesystems="nfs lockd ext4"
filesystems="$fslist"
EOF

local fname=$(readlink -f $cfdir/apt/sources.list)
Expand Down Expand Up @@ -450,6 +465,8 @@ EOF
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
upgrade_nfsroot() {

local nfscommon

mount -t proc /proc $NFSROOT/proc
mount -t sysfs /sys $NFSROOT/sys
mount -t devpts devpts $NFSROOT/dev/pts
Expand All @@ -465,14 +482,17 @@ upgrade_nfsroot() {
fi

# if we have the keyring on the host, install the key of the fai-project.org package repository
if [ -n "$(apt-key list | grep 074BCDE4)" ]; then
HOME=/root apt-key export 074BCDE4 | chroot $NFSROOT apt-key add -
if [ -n "$(apt-key list 074BCDE4 2>/dev/null)" ]; then
HOME=/root apt-key export 074BCDE4 | $ROOTCMD apt-key add -
fi

if [ $full = 1 ];then
nfscommon=nfs-common
fi

$ROOTCMD apt-get update
# fai-nfsroot must be sucessfully installed before anything else
$ROOTCMD apt-get -yf --no-install-recommends install fai-nfsroot
$ROOTCMD apt-get -yf --no-install-recommends install dracut-network dracut-config-generic nfs-common
$ROOTCMD apt-get -yf --no-install-recommends install fai-nfsroot dracut-network dracut-config-generic $nfscommon
$ROOTCMD apt-get -y dist-upgrade
fdivert /usr/sbin/update-grub
}
Expand Down Expand Up @@ -520,21 +540,11 @@ umount_dirs() {
setup_tftp(){

# tftp environment
local pxebin

# wheezy path
if [ -f $NFSROOT/usr/lib/PXELINUX/pxelinux.0 ]; then
pxebin=$NFSROOT/usr/lib/PXELINUX/pxelinux.0
else
# jessie/stretch path
pxebin=$NFSROOT/usr/lib/syslinux/pxelinux.0
fi

rm -f $NFSROOT/boot/*.bak
mkdir -p $TFTPROOT/pxelinux.cfg
chmod a+r $NFSROOT/boot/initrd.img-* || die 9 "No initrd was created. Check the package name of the linux-image package in /etc/fai/NFSROOT."
cp -p $v $NFSROOT/boot/vmlinu?-* $NFSROOT/boot/initrd.img-* $TFTPROOT
cp -u $pxebin $TFTPROOT
cp -u $v $NFSROOT/usr/lib/PXELINUX/pxelinux.0 $TFTPROOT
if [ -f $NFSROOT/usr/lib/syslinux/modules/bios/ldlinux.c32 ]; then
cp -u $NFSROOT/usr/lib/syslinux/modules/bios/ldlinux.c32 $TFTPROOT
fi
Expand Down Expand Up @@ -585,7 +595,9 @@ trap "bad_exit" ERR
# remove all kernels from nfsroot
[ -n "$kremove" ] && {
echo "Removing all kernels from NFSROOT."
$ROOTCMD aptitude -y purge ~nlinux-image
LC_ALL=C $ROOTCMD apt-cache dumpavail > $NFSROOT/var/lib/dpkg/available
LC_ALL=C $ROOTCMD apt-get -qq purge linux-image\*
rm $NFSROOT/var/lib/dpkg/available
exit
}

Expand Down
12 changes: 7 additions & 5 deletions bin/fai-mirror
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ verbose=0
add=1
qflag=-qq
bcount=0
while getopts "a:bBvhx:pc:C:m:P:" opt ; do
while getopts "a:bBvhx:pc:C:m:s:P:" opt ; do
case "$opt" in
a) arch=$OPTARG ;;
B) add=0 ; ((bcount++)) ;;
Expand All @@ -203,6 +203,7 @@ while getopts "a:bBvhx:pc:C:m:P:" opt ; do
c) cclasses="$OPTARG";;
m) MAXPACKAGES="$OPTARG";;
p) preserve=1;;
s) csdir="$OPTARG";;
v) verbose=1; vflag=-v; qflag='';;
P) aptpref="$OPTARG";;
?) die 1 "Unknown option";;
Expand All @@ -221,9 +222,11 @@ cfdir=$(readlink -f $cfdir) # canonicalize path
. $cfdir/fai.conf
. $cfdir/nfsroot.conf
: ${MNTPOINT:=/media/mirror} # default value

export NFSROOT

if [ -n "$csdir" ]; then
FAI_CONFIGDIR=$csdir # override by -s
fi
[ -x "$(which reprepro)" ] || die 8 "reprepro not found. Please install the package."
[ -n "$exclasses" -a -n "$cclasses" ] && die 3 "Options -x and -c not allowed at the same time."

Expand Down Expand Up @@ -287,10 +290,9 @@ Codename: cskoeln
Architectures: $arch
Components: main non-free contrib
DebIndices: Packages Release . .xz
Description: FAI packages from author's repository
Description: Package reprository created by fai-mirror
Label: fai-project.org
Origin: Original FAI archive
Suite: stretch
Origin: fai-mirror
EOF
# '

Expand Down
7 changes: 0 additions & 7 deletions bin/fai-setup
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,6 @@ if [ -z "$expert" ]; then
echo "FAI_CONFIGDIR=$FAI_CONFIGDIR" >> /var/log/fai/variables
echo "FAI_CONFIG_SRC=nfs://${myip}$FAI_CONFIGDIR" >> /var/log/fai/variables

# if not NFS v4 entry is found add a dummy entry. Workaround for #676883
if ! egrep -v ^# /etc/exports | grep -q fsid=0; then
echo "No entry for NFS v4 found. Adding a dummy entry. This forces NFS v3 for the nfsroot."
mkdir -p /srv/nfs4
add_export_line "/srv/nfs4 $iprange(fsid=0,async,ro,no_subtree_check)"
fi

add_export_line $FAI_CONFIGDIR "$iprange(async,ro,no_subtree_check)"
add_export_line $NFSROOT "$iprange(async,ro,no_subtree_check,no_root_squash)"
if pidof nfsd >/dev/null
Expand Down
Loading

0 comments on commit b869f0e

Please sign in to comment.