Skip to content

Commit

Permalink
Merge pull request #6803 from inverse-inc/feature/debian-installer
Browse files Browse the repository at this point in the history
Feature/debian installer
  • Loading branch information
nqb authored Feb 15, 2022
2 parents aa9d54c + 9b02d8e commit ad5ecd1
Show file tree
Hide file tree
Showing 10 changed files with 763 additions and 2 deletions.
47 changes: 45 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ variables:
RELEASEDIR: ${CILIBDIR}/release
PACKERDIR: $CIDIR/packer
ZENDIR: $CIDIR/packer/zen
ISODIR: $CIDIR/debian-installer
VAGRANT_IMG_DIR: $CIDIR/packer/vagrant_img
TESTDIR: t/venom
UPLOAD_DIR: $CILIBDIR/upload
SF_REPO_URL: https://sourceforge.net/projects/packetfence/files/PacketFence%20ZEN
SF_ZEN_REPO_URL: https://sourceforge.net/projects/packetfence/files/PacketFence%20ZEN
SF_ISO_REPO_URL: https://sourceforge.net/projects/packetfence/files/PacketFence%20ISO
# env variables
ANSIBLE_FORCE_COLOR: 1
ANSIBLE_STDOUT_CALLBACK: yaml
Expand Down Expand Up @@ -151,6 +153,14 @@ variables:
- if: '$CI_COMMIT_REF_NAME == "devel" && ( $BUILD_PF_IMG_ZEN == "yes" || $CI_COMMIT_MESSAGE =~ /build_pf_img_zen=yes/ )'
- if: '$CI_COMMIT_REF_NAME != "devel" && $CI_COMMIT_REF_NAME !~ /^maintenance\/[[:digit:]]+\.[[:digit:]]+$/ && $CI_COMMIT_TAG == null && $CI_PIPELINE_SOURCE == "web" && ( $BUILD_PF_IMG_ZEN == "yes" || $CI_COMMIT_MESSAGE =~ /build_pf_img_zen=yes/ )'

# run this job on:
# - devel branch with BUILD_PF_IMG_ISO variable defined or build_pf_img_iso=yes in commit message
# - all branches, except maintenance/X.Y and devel (web) if variable BUILD_PF_IMG_ISO sets to yes or if CI_COMMIT_MESSAGE contains "build_pf_img_iso=yes".
.build_pf_img_iso_devel_rules:
rules:
- if: '$CI_COMMIT_REF_NAME == "devel" && ( $BUILD_PF_IMG_ISO == "yes" || $CI_COMMIT_MESSAGE =~ /build_pf_img_iso=yes/ )'
- if: '$CI_COMMIT_REF_NAME != "devel" && $CI_COMMIT_REF_NAME !~ /^maintenance\/[[:digit:]]+\.[[:digit:]]+$/ && $CI_COMMIT_TAG == null && $CI_PIPELINE_SOURCE == "web" && ( $BUILD_PF_IMG_ISO == "yes" || $CI_COMMIT_MESSAGE =~ /build_pf_img_ISO=yes/ )'

# run this job on:
# - devel branch with BUILD_ARTIFACTS_WEBSITE variable defined or build_artifacts_website=yes in commit message
# - all branches, except maintenance/X.Y and devel (web) if variable BUILD_ARTIFACTS_WEBSITE sets to yes or if CI_COMMIT_MESSAGE contains "build_artifacts_website=yes".
Expand Down Expand Up @@ -345,14 +355,24 @@ variables:
stage: build_pf_img
environment:
name: sourceforge
url: ${SF_REPO_URL}/${CI_COMMIT_REF_NAME}
url: ${SF_ZEN_REPO_URL}/${CI_COMMIT_REF_NAME}
after_script:
- make -e -C ${ZENDIR} clean
- make -e -C ${ZENDIR} clean_cache
dependencies: []
tags:
- shell

.build_pf_img_iso_job:
stage: build_pf_img
environment:
name: sourceforge
after_script:
- make -e -C ${ISODIR} clean
dependencies: []
tags:
- shell

.build_pf_img_vagrant_release_job:
stage: build_pf_img
variables:
Expand Down Expand Up @@ -858,6 +878,29 @@ build_pf_img_zen_release:
when: manual
allow_failure: true

### build_pf_img_iso jobs
build_pf_img_iso_devel:
extends:
- .build_pf_img_iso_job
- .build_pf_img_iso_devel_rules
environment:
url: ${SF_ISO_REPO_URL}/${CI_COMMIT_REF_SLUG}
script:
- PF_VERSION=${CI_COMMIT_REF_SLUG} make -e -C ${ISODIR} iso

build_pf_img_iso_release:
extends:
- .build_pf_img_iso_job
environment:
url: ${SF_ISO_REPO_URL}/${CI_COMMIT_TAG}
script:
- PF_VERSION=${CI_COMMIT_TAG} make -e -C ${ISODIR} iso
# workaround for https://forum.gitlab.com/t/specify-when-at-job-level-with-a-job-that-has-rules/4769
rules:
- if: '$CI_COMMIT_TAG'
when: manual
allow_failure: true

### build_pf_img_vagrant jobs
# build_pf_img_vagrant_release_el_8:
# extends:
Expand Down
2 changes: 2 additions & 0 deletions ci/debian-installer/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
preseed.cfg
*.iso
15 changes: 15 additions & 0 deletions ci/debian-installer/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

RESULT_DIR=results

.PHONY: packetfence-debian-installer.iso

iso:
echo "Building Debian installer for $(PF_VERSION)"
PF_RELEASE='$(shell cat ../../conf/pf-release)' \
PF_VERSION='$(PF_VERSION)' \
./build-and-upload.sh

.PHONY: clean
clean:
rm -rf $(RESULT_DIR)

34 changes: 34 additions & 0 deletions ci/debian-installer/build-and-upload.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash
set -o nounset -o pipefail -o errexit

PF_VERSION=${PF_VERSION:-localtest}

PF_RELEASE="`echo $PF_RELEASE | sed -r 's/.*\b([0-9]+\.[0-9]+)\.[0-9]+/\1/g'`"

ISO_NAME=PacketFence-ISO-${PF_VERSION}.iso

# upload
SF_RESULT_DIR=results/sf/${PF_VERSION}
PUBLIC_REPO_DIR="/home/frs/project/p/pa/packetfence/PacketFence\ ISO/${PF_VERSION}"
DEPLOY_SF_USER=${DEPLOY_SF_USER:-inverse-bot,packetfence}
DEPLOY_SF_HOST=${DEPLOY_SF_HOST:-frs.sourceforge.net}

upload_to_sf() {
# warning: slashs at end of dirs are significant for rsync
local src_dir="${SF_RESULT_DIR}/"
local dst_repo="${PUBLIC_REPO_DIR}/"
local dst_dir="${DEPLOY_SF_USER}@${DEPLOY_SF_HOST}:${dst_repo}"
declare -p src_dir dst_dir
echo "rsync: $src_dir -> $dst_dir"

# quotes to handle space in filename
rsync -avz $src_dir "$dst_dir"
}

mkdir -p ${SF_RESULT_DIR}

echo "===> Build ISO for release $PF_RELEASE"
docker run --rm -e PF_RELEASE=$PF_RELEASE -e ISO_OUT="${SF_RESULT_DIR}/${ISO_NAME}" -v `pwd`:/debian-installer debian:11 /debian-installer/create-debian-installer-docker.sh

echo "===> Upload to Sourceforge"
upload_to_sf
10 changes: 10 additions & 0 deletions ci/debian-installer/create-debian-installer-docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
set -o nounset -o pipefail -o errexit

cd /debian-installer

apt update
apt install xorriso wget cpio genisoimage -yqq

./create-debian-installer.sh

45 changes: 45 additions & 0 deletions ci/debian-installer/create-debian-installer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash
set -o nounset -o pipefail -o errexit

function clean() {
rm -fr isofiles/
rm -f preseed.cfg
chmod a+rw $ISO_IN
chmod a+rw $ISO_OUT
}

ISO_IN=${ISO_IN:-debian-11.2.0-amd64-netinst.iso}
ISO_OUT=${ISO_OUT:-packetfence-debian-installer.iso}

if ! [ -f $ISO_IN ]; then
wget https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/$ISO_IN
fi

rm -fr isofiles/

cat preseed.cfg.tmpl | sed "s/%%PF_VERSION%%/$PF_RELEASE/g" > preseed.cfg

xorriso -osirrox on -indev $ISO_IN -extract / isofiles

chmod +w -R isofiles/install.amd/
gunzip isofiles/install.amd/initrd.gz
echo preseed.cfg | cpio -H newc -o -A -F isofiles/install.amd/initrd
gzip isofiles/install.amd/initrd
chmod -w -R isofiles/install.amd/

chmod a+w isofiles/isolinux/gtk.cfg isofiles/isolinux/drkgtk.cfg isofiles/boot/grub/grub.cfg
cp gtk.cfg isofiles/isolinux/gtk.cfg
cp gtk.cfg isofiles/isolinux/drkgtk.cfg
cp grub.cfg isofiles/boot/grub/grub.cfg
chmod 0444 isofiles/isolinux/gtk.cfg isofiles/isolinux/drkgtk.cfg isofiles/boot/grub/grub.cfg

cd isofiles
chmod +w md5sum.txt
# The '|| echo' is there so that it always exits with 0 because find returns a non-zero status because there is debian symlink in isofiles that points to '.'
find -follow -type f ! -name md5sum.txt -print0 | xargs -0 md5sum > md5sum.txt || echo
chmod -w md5sum.txt
cd ..

genisoimage -r -J -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o $ISO_OUT isofiles

clean
88 changes: 88 additions & 0 deletions ci/debian-installer/grub.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
if loadfont $prefix/font.pf2 ; then
set gfxmode=800x600
set gfxpayload=keep
insmod efi_gop
insmod efi_uga
insmod video_bochs
insmod video_cirrus
insmod gfxterm
insmod png
terminal_output gfxterm
fi

if background_image /isolinux/splash.png; then
set color_normal=light-gray/black
set color_highlight=white/black
elif background_image /splash.png; then
set color_normal=light-gray/black
set color_highlight=white/black
else
set menu_color_normal=cyan/blue
set menu_color_highlight=white/blue
fi

insmod play
play 960 440 1 0 4 440 1
set theme=/boot/grub/theme/1
menuentry --hotkey=i 'Install' {
set background_color=black
linux /install.amd/vmlinuz vga=788 net.ifnames=0 --- quiet
initrd /install.amd/initrd.gz
}
submenu --hotkey=a 'Advanced options ...' {
set menu_color_normal=cyan/blue
set menu_color_highlight=white/blue
set theme=/boot/grub/theme/1-1
set gfxpayload=keep
menuentry '... Graphical expert install' {
set background_color=black
linux /install.amd/vmlinuz priority=low vga=788 ---
initrd /install.amd/gtk/initrd.gz
}
menuentry '... Graphical rescue mode' {
set background_color=black
linux /install.amd/vmlinuz vga=788 rescue/enable=true --- quiet
initrd /install.amd/gtk/initrd.gz
}
menuentry '... Graphical automated install' {
set background_color=black
linux /install.amd/vmlinuz auto=true priority=critical vga=788 --- quiet
initrd /install.amd/gtk/initrd.gz
}
menuentry --hotkey=x '... Expert install' {
set background_color=black
linux /install.amd/vmlinuz priority=low vga=788 ---
initrd /install.amd/initrd.gz
}
menuentry --hotkey=r '... Rescue mode' {
set background_color=black
linux /install.amd/vmlinuz vga=788 rescue/enable=true --- quiet
initrd /install.amd/initrd.gz
}
menuentry --hotkey=a '... Automated install' {
set background_color=black
linux /install.amd/vmlinuz auto=true priority=critical vga=788 --- quiet
initrd /install.amd/initrd.gz
}
submenu --hotkey=s '... Speech-enabled advanced options ...' {
set menu_color_normal=cyan/blue
set menu_color_highlight=white/blue
set theme=/boot/grub/theme/1-1-1
set gfxpayload=keep
menuentry --hotkey=x '... Expert speech install' {
set background_color=black
linux /install.amd/vmlinuz priority=low vga=788 speakup.synth=soft ---
initrd /install.amd/gtk/initrd.gz
}
menuentry --hotkey=r '... Rescue speech mode' {
set background_color=black
linux /install.amd/vmlinuz vga=788 rescue/enable=true speakup.synth=soft --- quiet
initrd /install.amd/gtk/initrd.gz
}
menuentry --hotkey=a '... Automated speech install' {
set background_color=black
linux /install.amd/vmlinuz auto=true priority=critical vga=788 speakup.synth=soft --- quiet
initrd /install.amd/gtk/initrd.gz
}
}
}
7 changes: 7 additions & 0 deletions ci/debian-installer/gtk.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
default install
label install
menu label ^Install PacketFence
menu default
kernel /install.amd/vmlinuz
append vga=788 net.ifnames=0 initrd=/install.amd/initrd.gz --- quiet

Loading

0 comments on commit ad5ecd1

Please sign in to comment.