Skip to content

Commit

Permalink
Merge branch 'master' into dracut-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
adrelanos authored Nov 18, 2023
2 parents aee6850 + 75f5c29 commit 6b922c1
Show file tree
Hide file tree
Showing 30 changed files with 731 additions and 573 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/pr-review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# PR Review workflows.
# The intention is for these to only find *new* issues.

name: pr-review
on:
pull_request:
jobs:

shellcheck-code:
name: shellcheck grml-debootstrap
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: shellcheck
uses: reviewdog/action-shellcheck@v1
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-review
path: "."
pattern: |
chroot-script
grml-debootstrap
config
tests/shellcheck-stub-debootstrap-variables
check_all_files_with_shebangs: "false"

shellcheck-tests:
name: shellcheck test scripts
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: shellcheck
uses: reviewdog/action-shellcheck@v1
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-review
path: "."
pattern: |
tests/*
check_all_files_with_shebangs: "false"
100 changes: 100 additions & 0 deletions .github/workflows/test-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: test-build
on:
pull_request:
concurrency:
group: "${{ github.ref }}"
cancel-in-progress: true
jobs:
build-debian:
strategy:
# Keep other matrix jobs running, even if one fails.
fail-fast: false
matrix:
host_release:
- unstable
- trixie
- bookworm
- bullseye

# We want a working shell, qemu, python and docker. Specific version should not matter (much).
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- run: ./tests/gha-build-deb.sh
name: "Build .deb for ${{matrix.host_release}}"
env:
HOST_RELEASE: ${{matrix.host_release}}

- name: Archive built .deb
uses: actions/upload-artifact@v3
with:
name: deb-${{matrix.host_release}}
if-no-files-found: error
path: |
*.deb
test-debian:
needs: build-debian
strategy:
# Keep other matrix jobs running, even if one fails.
fail-fast: false
matrix:
host_release:
- unstable
- trixie
- bookworm
- bullseye

release:
- trixie
- bookworm
- bullseye
- buster
- stretch

debootstrap:
- ''
- mmdebstrap

exclude:
# debootstrap in bullseye is too old.
- host_release: bullseye
release: trixie
# unclear how to pass --no-check-gpg to mmdebstrap
- release: stretch
debootstrap: mmdebstrap

# We want a working shell, qemu, python and docker. Specific version should not matter (much).
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Download built deb
uses: actions/download-artifact@v3
with:
name: deb-${{matrix.host_release}}

- run: ./tests/build-vm-and-test.sh setup
name: "Setup test environment"

- run: ./tests/build-vm-and-test.sh run
name: "Build VM image using grml-debootstrap on host ${{matrix.host_release}} for ${{matrix.release}} using debootstrap=${{matrix.debootstrap}}"
env:
HOST_RELEASE: ${{matrix.host_release}}
RELEASE: ${{matrix.release}}
DEBOOTSTRAP: ${{matrix.debootstrap}}

- run: ./tests/build-vm-and-test.sh test
name: "Test built VM image for ${{matrix.release}}"
env:
RELEASE: ${{matrix.release}}

- name: Archive VM test results
uses: actions/upload-artifact@v3
with:
name: vm-results-${{matrix.host_release}}-${{matrix.release}}-${{matrix.debootstrap}}
if-no-files-found: error
path: tests/results/
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
*.box
packer_cache
*_output
qemu.img
tests/dgoss
tests/goss
15 changes: 0 additions & 15 deletions .travis.yml

This file was deleted.

1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ install:
mkdir -p $(DESTDIR)/usr/sbin/
mkdir -p $(DESTDIR)/usr/share/zsh/vendor-completions
install -m 644 config $(DESTDIR)/etc/debootstrap/
install -m 644 devices.tar.gz $(DESTDIR)/etc/debootstrap/
install -m 644 locale.gen $(DESTDIR)/etc/debootstrap/
install -m 644 packages $(DESTDIR)/etc/debootstrap/
install -m 644 packages-arm64 $(DESTDIR)/etc/debootstrap/
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
grml-debootstrap
================

[![Build Status](https://travis-ci.org/grml/grml-debootstrap.svg?branch=master)](https://travis-ci.org/grml/grml-debootstrap)
[![test-build](https://github.com/grml/grml-debootstrap/actions/workflows/test-build.yml/badge.svg)](https://github.com/grml/grml-debootstrap/actions/workflows/test-build.yml)

This tool is a wrapper suite around debootstrap and cdebootstrap
to ease installation of a pure [Debian](https://debian.org/) system.
Expand Down
95 changes: 33 additions & 62 deletions chroot-script
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# GRML_CHROOT_SCRIPT_MARKER - do not remove this line unless you want to keep
# this script as /bin/chroot-script on your new installed system
################################################################################
# shellcheck disable=SC2317 # shellcheck has trouble understanding the code flow in this file

# error_handler {{{
if [ "$REPORT_TRAP_ERR" = "yes" ] || [ "$FAIL_TRAP_ERR" = "yes" ]; then
Expand All @@ -18,9 +19,9 @@ if [ "$REPORT_TRAP_ERR" = "yes" ] || [ "$FAIL_TRAP_ERR" = "yes" ]; then
fi
# }}}

# shellcheck disable=SC1091
# shellcheck source=config
. /etc/debootstrap/config || exit 1
# shellcheck disable=SC1091
# shellcheck source=tests/shellcheck-stub-debootstrap-variables
. /etc/debootstrap/variables || exit 1

[ -r /proc/1 ] || mount -t proc none /proc
Expand Down Expand Up @@ -101,20 +102,10 @@ chrootmirror() {
fi
fi

# LTS support
case "$RELEASE" in
squeeze)
if [ -n "$MIRROR" ] ; then
echo "Release matching $RELEASE - enabling LTS support in sources.list"
echo "deb $MIRROR ${RELEASE}-lts $COMPONENTS" >> /etc/apt/sources.list
fi
;;
esac

# add security.debian.org:
case "$RELEASE" in
unstable|sid|lenny) ;; # no security pool available
squeeze|wheezy|jessie|stretch|buster)
unstable|sid) ;; # no security pool available
jessie|stretch|buster)
echo "Adding security.debian.org to sources.list."
echo "deb http://security.debian.org ${RELEASE}/updates $COMPONENTS" >> /etc/apt/sources.list
;;
Expand Down Expand Up @@ -324,11 +315,7 @@ get_kernel_version() {
# shellcheck disable=SC2153
case "$ARCH" in
i386)
case "$RELEASE" in
lenny|squeeze|wheezy) KARCH='686' ;;
# since jessie the linux-image-686 image doesn't exist any longer
*) KARCH='686-pae' ;;
esac
KARCH='686-pae'
;;
amd64)
KARCH='amd64'
Expand All @@ -341,14 +328,15 @@ get_kernel_version() {
return 1
esac

for KPREFIX in "" "2.6-" ; do # iterate through the kernel prefixes,
# currently "" and "2.6-"
if package_exists linux-image-${KPREFIX}${KARCH} ; then
echo ${KPREFIX}${KARCH}
return 0
fi
local KPACKAGE
KPACKAGE=linux-image-"${KPREFIX}${KARCH}"
if package_exists "$KPACKAGE"; then
echo "${KPREFIX}${KARCH}"
return 0
fi

done
echo "Expected kernel package $KPACKAGE not found" >&2
return 1
}

# install kernel packages {{{
Expand Down Expand Up @@ -396,15 +384,13 @@ passwords()
return 0
fi

echo "Activating shadow passwords."
shadowconfig on

CHPASSWD_OPTION=
if chpasswd --help 2>&1 | grep -q -- '-m,' ; then
CHPASSWD_OPTION='-m'
fi

if [ -n "$ROOTPASSWORD" ] ; then
# shellcheck disable=SC2086
echo root:"$ROOTPASSWORD" | chpasswd $CHPASSWD_OPTION
export ROOTPASSWORD=''
else
Expand All @@ -427,6 +413,7 @@ passwords()
a='1'
b='2'
else
# shellcheck disable=SC2086
echo root:"$a" | chpasswd $CHPASSWD_OPTION
unset a
unset b
Expand Down Expand Up @@ -613,8 +600,10 @@ initrd() {
if [ -n "$INITRD" ] ; then
echo "Generating initrd."
if [ "$INITRD_GENERATOR" = 'dracut' ] ; then
# shellcheck disable=SC2086
dracut --no-hostonly --kver "$KERNELVER" --fstab --add-fstab /etc/fstab --force --reproducible $INITRD_GENERATOR_OPTS
else
# shellcheck disable=SC2086
update-initramfs -c -t -k "$KERNELVER" $INITRD_GENERATOR_OPTS
fi
fi
Expand Down Expand Up @@ -710,15 +699,19 @@ grub_install() {
echo "Setting ${GRUB_PACKAGE} debconf configuration for install device to $GRUB"
echo "${GRUB_PACKAGE} ${GRUB_PACKAGE}/install_devices multiselect ${grub_device}" | debconf-set-selections

if ! dpkg --list ${GRUB_PACKAGE} 2>/dev/null | grep -q '^ii' ; then
if ! dpkg --list "${GRUB_PACKAGE}" 2>/dev/null | grep -q '^ii' ; then
echo "Notice: grub option set but no ${GRUB_PACKAGE} package, installing it therefore."
DEBIAN_FRONTEND=$DEBIAN_FRONTEND $APTINSTALL ${GRUB_PACKAGE}
DEBIAN_FRONTEND=$DEBIAN_FRONTEND $APTINSTALL "${GRUB_PACKAGE}"
fi

if ! [ -x "$(command -v grub-install)" ] ; then
echo "Error: grub-install not available. (Error while installing grub package?)" >&2
return 1
fi
if ! [ -x "$(command -v update-grub)" ] ; then
echo "Error: update-grub not available. (Error while installing grub package?)" >&2
return 1
fi

if [ -n "$SELECTED_PARTITIONS" ] ; then # using sw-raid
for device in $SELECTED_PARTITIONS ; do
Expand All @@ -732,48 +725,26 @@ grub_install() {
done
rm -f /boot/grub/device.map
else
echo "Installing grub on ${GRUB}:"
case "$RELEASE" in
lenny|squeeze|wheezy)
local grub_dev
grub_dev="$(readlink -f "${GRUB}")"
if ! grub-install --no-floppy "${grub_dev}" ; then
echo "Error: failed to execute 'grub-install --no-floppy ${grub_dev}'." >&2
exit 1
fi
rm -f /boot/grub/device.map
;;
*)
echo "(hd0) ${GRUB}" > /boot/grub/device.map
if ! grub-install "(hd0)" ; then
echo "Error: failed to execute 'grub-install (hd0)'." >&2
exit 1
fi
rm /boot/grub/device.map
;;
esac
echo "Installing grub on ${GRUB}:"
echo "(hd0) ${GRUB}" > /boot/grub/device.map
if ! grub-install "(hd0)" ; then
echo "Error: failed to execute 'grub-install (hd0)'." >&2
exit 1
fi
rm /boot/grub/device.map
fi

echo "Adjusting grub configuration for use on ${GRUB}."

# finally install grub
if [ -x /usr/sbin/update-grub ] ; then
UPDATEGRUB='/usr/sbin/update-grub'
elif [ -x /sbin/update-grub ] ; then
UPDATEGRUB='/sbin/update-grub'
else
echo "Error: update-grub not available, can not execute it." >&2
return 1
fi

if [ -n "${BOOT_APPEND}" ] ; then
echo "Adding BOOT_APPEND configuration ['${BOOT_APPEND}'] to /etc/default/grub."
sed -i "/GRUB_CMDLINE_LINUX_DEFAULT/ s#\"\$# ${BOOT_APPEND}\"#" /etc/default/grub
fi

mountpoint /boot/efi &>/dev/null && umount /boot/efi

$UPDATEGRUB
# finally install grub. Existence of update-grub is checked above.
update-grub
}
# }}}

Expand Down
3 changes: 2 additions & 1 deletion config
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# Bug-Reports: see https://grml.org/bugs/
# License: This file is licensed under the GPL v2 or any later version.
################################################################################
# shellcheck shell=sh

################################################################################
# Important: adjust this file if you want to execute grml-debootstrap
Expand Down Expand Up @@ -72,7 +73,7 @@
# BACKPORTREPOS='yes'

# Debian release that should be installed.
# Supported values: lenny, squeeze, wheezy, jessie, stretch, buster, bullseye, sid
# Supported values: jessie, stretch, buster, bullseye, sid
# Default: 'bullseye'
# RELEASE='bullseye'

Expand Down
Loading

0 comments on commit 6b922c1

Please sign in to comment.