Do some better linting (#13)

* Do some better linting

* Update names, Packer version, and more

* Do not lint on push

* More linting and scripting

* Cleanup shellcheck lint

* Add Packer format check

* Fix Packer formatting

* Limit to only one

* Remove generated HCL files

* Only lint checked files

* Use pipes instead

* Improve attempt to build

Actually go back to attempting to build boxes on GitHub. Maybe it will
work better with this structure

* Change to using environment files

* Initialize plugins, first

* More verbose usage of the file

* Do the output properly this time

* PACKER_LOG set to 1

* No need for python3 anymore

* Limit to only one result

* Choose a specific CPU model

* Init separately

* Update actions version

* Add version outputting

* Correct actions version

* Try to execute qemu properly

* Fix CPU model name

* Do not over-subscribe GitHub runners

* Try type instead of command to guard runs

* Do not write to non-existent folder

* Cache packer plugins

* Use ~ instead of /home/greg

* Try the proper path

* Move to intelligent matrix

* Set global env path

* Add lots of waits for VBoxManage on hosted runners

* Add more waits

* Add more waits
This commit is contained in:
Greg Hellings
2023-12-06 10:21:32 -06:00
committed by GitHub
parent 86dfe113a0
commit 634aae8d75
55 changed files with 536 additions and 495 deletions
+2 -2
View File
@@ -5,7 +5,7 @@ inputs:
version: version:
description: Version of Packer to install description: Version of Packer to install
required: true required: true
default: "1.9.2" default: "1.9.4"
pup_version: pup_version:
description: Version of Pup to install description: Version of Pup to install
required: true required: true
@@ -21,7 +21,7 @@ runs:
# Install virtualbox # Install virtualbox
sudo apt-get update sudo apt-get update
# Install QEmu, etc # Install QEmu, etc
sudo apt-get install -y unzip python3-{virtualenv,yaml} cloud-utils xorriso qemu-system-{x86,ppc} vagrant sudo apt-get install -y unzip cloud-utils xorriso qemu-system-{x86,ppc} vagrant
# Install packer.io # Install packer.io
curl -O https://releases.hashicorp.com/packer/${{ inputs.version }}/packer_${{ inputs.version }}_linux_amd64.zip curl -O https://releases.hashicorp.com/packer/${{ inputs.version }}/packer_${{ inputs.version }}_linux_amd64.zip
unzip -o packer_${{ inputs.version }}_linux_amd64.zip -d /usr/local/bin unzip -o packer_${{ inputs.version }}_linux_amd64.zip -d /usr/local/bin
-33
View File
@@ -1,33 +0,0 @@
name: Setup environment
description: Sets up some basic components of the environment
inputs:
ansible:
description: Install Ansible as well
required: false
default: false
runs:
using: composite
steps:
- name: Install Python 3
uses: actions/setup-python@v3
with:
python-version: "3"
- name: Setup pip cache
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip
- name: Install Pip and tox
shell: bash
run: |
set -exo pipefail
python3 -m pip install -U pip
pip install -U wheel
pip install -U tox
- name: Install Ansible
if: inputs.ansible == 'true'
shell: bash
run: |
set -exo pipefail
pip install -U ansible
ansible-galaxy collection install -r ansible/requirements.yml
+70 -29
View File
@@ -8,72 +8,113 @@ name: Build the boxes
- prereleased - prereleased
pull_request: pull_request:
env:
PACKER_PLUGIN_PATH: "~/.config/packer/plugins"
jobs: jobs:
collect: collect:
name: Discover distros name: Discover distros
runs-on: ubuntu-22.04 runs-on: ubuntu-latest
outputs: outputs:
distros: ${{ steps.distros.outputs.distros }} distros: ${{ steps.distros.outputs.distros }}
build: ${{ steps.time.outputs.time }} build: ${{ steps.time.outputs.time }}
steps: steps:
- uses: actions/checkout@v3 - name: Checkout code
uses: actions/checkout@v3
- name: Install python
uses: actions/setup-python@v4
with:
python-version: 3
cache: pip
cache-dependency-path: .github/workflows/build.yml
- name: Discover boxes - name: Discover boxes
id: distros id: distros
run: |- run: |-
set -eo pipefail set -exo pipefail
distros=$(ls distros/*.hcl{,.sh} | jq -cRs 'split("\n") | [ .[] | if length > 0 then . else empty end ]') pip install xonsh PyYAML
echo "::set-output name=distros::${distros}" echo "distros=$(xonsh build.xsh -a --list)" >> "$GITHUB_OUTPUT"
- name: Find timestamp for versioning - name: Find timestamp for versioning
id: time id: time
uses: nanzm/get-time-action@v1.1 uses: nanzm/get-time-action@v2.0
with: with:
format: 'YYYY.MM.DD.HH' format: 'YYYY.MM.DD.HH'
build: build:
name: Build box name: Build box
runs-on: ${{ matrix.builder == 'virtualbox-iso.amd64' && 'macOS-12' || 'ubuntu-22.04' }} runs-on: ${{ matrix.runner }}
needs: needs:
- collect - collect
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix: ${{ fromJson( needs.collect.outputs.distros ) }}
builder:
- virtualbox-iso.amd64
- qemu.amd64
distro: ${{ fromJson( needs.collect.outputs.distros ) }}
needs_timeout:
- distros/ubuntu-20.04-x86_64.pkrvars.hcl
steps: steps:
- name: Checkout project - name: Checkout project
uses: actions/checkout@v3 uses: actions/checkout@v3
with:
submodules: recursive
- name: Setup system dependnecies
uses: ./.github/actions/setup
with:
ansible: true
- name: Install Packer and related tools - name: Install Packer and related tools
uses: ./.github/actions/install_packer uses: ./.github/actions/install_packer
- name: Clear disk space - name: Clear disk space
uses: greg-hellings/make-space@main uses: greg-hellings/make-space@main
- name: Modify build timeouts, if necessary
if: contains(matrix.needs_timeout, matrix.distro) - name: Output tool versions
shell: bash shell: bash
run: ./modify_timeout.sh "${{ matrix.distro }}" run: |
set -x
packer -version
if $(type qemu-system-x86_64); then
qemu-system-x86_64 -version
fi
if $(type VBoxManage); then
VBoxManage --version;
fi
- name: Run generator, if necessary - name: Run generator, if necessary
if: endsWith(matrix.distro, '.sh') shell: bash
run: "${{ matrix.distro }}" run: |
if [ -f "${{ matrix.distro }}.sh" ]; then
"./${{ matrix.distro }}.sh"
fi
- name: Restore Packer plugin cache
uses: actions/cache/restore@v3
id: cache-restore
with:
path: ~/.config/packer/plugins
key: ${{ runner.os }}-${{ hashFiles('sources/build.pkr.hcl') }}
- name: Install Packer plugins
shell: bash
run: packer init sources
- name: Cache Packer plugins
uses: actions/cache/save@v3
if: always()
with:
path: ~/.config/packer/plugins
key: ${{ steps.cache-restore.outputs.cache-primary-key }}
- name: Build - name: Build
shell: bash shell: bash
run: | run: |
set -e set -e
# Strip .sh if it is a dynamic one
file="$(printf "${{ matrix.distro }}" | sed -E -e 's/^(.*).sh$/\1/')"
# Add a retry in case something bogus like a network failure happens # Add a retry in case something bogus like a network failure happens
packer build -only="${{ matrix.builder }}" -var-file="${file}" -var "qemu_accelerator=tcg" -var "build=${{ needs.collect.outputs.build }}" ${{ github.event_name != 'release' && '-except=upload' || '' }} sources packer build -only="${{ matrix.builder }}" \
-var-file="${{ matrix.distro }}" \
-var "qemu_accelerator=tcg" \
-var "build=${{ needs.collect.outputs.build }}" \
-var "cpu_model=Skylake-Client" \
-var "cpus=2" \
-var "memory=4096" \
${{ github.event_name != 'release' && '-except=upload' || '' }} \
sources
env: env:
VAGRANT_CLOUD_TOKEN: ${{ secrets.VAGRANT_CLOUD_TOKEN }} VAGRANT_CLOUD_TOKEN: ${{ secrets.VAGRANT_CLOUD_TOKEN }}
PACKER_LOG: ${{ contains(matrix.needs_timeout, matrix.distro) && '0' || '0' }} PACKER_LOG: 1 #${{ contains(matrix.needs_timeout, matrix.distro) && '0' || '0' }}
- name: Upload artifact - name: Upload artifact
if: ${{ failure() }} if: ${{ failure() }}
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
+37 -24
View File
@@ -1,28 +1,42 @@
name: Test the components of it name: Lint and validation
"on": "on":
push:
paths-ignore:
- .github/workflow/build.yml
- http/**
- README.box.md
- README.md
- LICENSE
pull_request: pull_request:
workflow_dispatch: workflow_dispatch:
jobs: jobs:
validate: validate:
name: Validate Packer templates are reasonable name: Validate Packer templates are reasonable
runs-on: ubuntu-22.04 runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - name: Checkout code
- uses: ./.github/actions/setup uses: actions/checkout@v3
- uses: ./.github/actions/install_packer
- name: Run syntax check - name: Install Packer
uses: ./.github/actions/install_packer
- name: Restore Packer plugin cache
uses: actions/cache/restore@v3
id: cache-restore
with:
path: ~/.config/packer/plugins
key: ${{ runner.os }}-${{ hashFiles('sources/build.pkr.hcl') }}
- name: Install Packer plugins
shell: bash
run: packer init sources
- name: Cache Packer plugins
uses: actions/cache/save@v3
if: always()
with:
path: ~/.config/packer/plugins
key: ${{ steps.cache-restore.outputs.cache-primary-key }}
- name: Run validate check
run: | run: |
set -exo pipefail set -exo pipefail
for vars in $(find distros/ -name '*.pkrvars.hcl'); do for vars in $(find distros/ -name '*.pkrvars.hcl*'); do
if [[ "${vars}" == *.sh ]]; then if [[ "${vars}" == *.sh ]]; then
"./${vars}" "./${vars}"
vars=${vars%.sh} vars=${vars%.sh}
@@ -30,18 +44,17 @@ jobs:
packer validate -except=upload -var-file=${vars} sources/ packer validate -except=upload -var-file=${vars} sources/
done done
- name: Run Packer format check
run: git ls-files | grep -E -e '.hcl$' | xargs -L 1 packer fmt -check
lint: lint:
name: Lint Ansible code name: Lint shell code
runs-on: ubuntu-22.04 runs-on: ubuntu-latest
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: Setup test environment
uses: ./.github/actions/setup - name: Install shellcheck
with:
ansible: true
- name: Run lint
run: | run: |
yamllint -c ansible/yamllint.yml ansible .github distros shellcheck --version
find distros/ -name user-data | xargs yamllint -c ansible/yamllint.yml shellcheck $(find . -name '*.sh')
# TODO: Add ansible-lint run
+1
View File
@@ -11,6 +11,7 @@ Vagrantfile
# Generated distros # Generated distros
distros/fedora/rawhide/*.hcl distros/fedora/rawhide/*.hcl
distros/nixos/**/*.hcl distros/nixos/**/*.hcl
distros/centos-stream/**/*.hcl
__pycache__ __pycache__
*.pyc *.pyc
+8 -1
View File
@@ -5,6 +5,7 @@ import sys
sys.path.append(str(Path(__file__).parent / "lib")) sys.path.append(str(Path(__file__).parent / "lib"))
from support import Support, BASE from support import Support, BASE
import time import time
import json
source test.xsh source test.xsh
@@ -25,6 +26,9 @@ parser.add_argument("--stamp", "-s", help="Time stamp for builds", default=STAMP
args = parser.parse_args() args = parser.parse_args()
my_list = []
# Now provide menus if we don't have defaults # Now provide menus if we don't have defaults
def process_all(): def process_all():
if args.distro: if args.distro:
@@ -55,7 +59,7 @@ def do_build(build):
headless = "headless=false" headless = "headless=false"
if args.list: if args.list:
print(f"Would build: {build.var_file}") my_list.append(build)
else: else:
if args.upload: if args.upload:
if "VAGRANT_CLOUD_TOKEN" not in ${...}: if "VAGRANT_CLOUD_TOKEN" not in ${...}:
@@ -73,5 +77,8 @@ def do_build(build):
if args.all or args.list or (args.distro and args.version and args.build): if args.all or args.list or (args.distro and args.version and args.build):
process_all() process_all()
if args.list:
my_list = [d.matrix for d in my_list if d.is_github]
print(json.dumps({"include": my_list}))
else: else:
print("Doing menu stuff") print("Doing menu stuff")
+2 -2
View File
@@ -7,9 +7,9 @@ iso = {
boot_command = [ boot_command = [
"<tab><wait> net.ifnames=0<wait> <wait>bi<wait>osdevnames=0<enter>", "<tab><wait> net.ifnames=0<wait> <wait>bi<wait>osdevnames=0<enter>",
"<wait60>", # Wait for system to come up? "<wait60>", # Wait for system to come up?
"curl -o /tmp/install.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/install.sh<enter>", "curl <wait>-o <wait>/tmp/install.sh <wait>http://{{ .HTTPIP }}<wait>:{{ .HTTPPort }}/install.sh<enter>",
"<wait5>", "<wait5>",
"/usr/bin/bash /tmp/install.sh {{ .HTTPPort }} {{ .HTTPIP }}<enter>" "/usr/bin/bash <wait>/tmp/install.sh <wait>{{ .HTTPPort }} <wait>{{ .HTTPIP }}<enter>"
] ]
http_directory = "distros/archlinux/rolling/http/" http_directory = "distros/archlinux/rolling/http/"
boot_wait = "10s" boot_wait = "10s"
+1 -1
View File
@@ -3,7 +3,7 @@ set -ex
pacman -Syyu --noconfirm pacman -Syyu --noconfirm
echo << EOF > /etc/ssh/sshd_config.d/00-vagrant_accept_pubkey.conf cat << EOF > /etc/ssh/sshd_config.d/00-vagrant_accept_pubkey.conf
UseDNS no UseDNS no
PubkeyAcceptedKeyTypes +ssh-rsa PubkeyAcceptedKeyTypes +ssh-rsa
EOF EOF
-12
View File
@@ -1,12 +0,0 @@
distro = "centos-stream"
version = "8"
iso = {
url = "http://mirror.centos.org/centos/8-stream/isos/x86_64/CentOS-Stream-8-x86_64-latest-boot.iso"
checksum = "83fb6025b52ba893669575f7df0048b3adc8e66b4d7c19d8f5522651f19150ba"
}
boot_command = [
"<up><tab><wait><bs><bs><bs><bs><bs>",
"inst.text inst.ks=cdrom:/ks.cfg console=tty0",
"<enter><wait>"
]
cd_files = [ "distros/centos-stream/8/disc/*" ]
+1 -1
View File
@@ -9,7 +9,7 @@ checksums="$(mktemp)"
until curl -f -L -o "${checksums}" "http://mirror.centos.org/centos/8-stream/isos/x86_64/CHECKSUM"; do until curl -f -L -o "${checksums}" "http://mirror.centos.org/centos/8-stream/isos/x86_64/CHECKSUM"; do
sleep 1 sleep 1
done done
sha="$(cat "${checksums}" | grep latest-boot | grep SHA256 | cut -d' ' -f 4)" sha="$(grep -e latest-boot "${checksums}" | grep SHA256 | cut -d' ' -f 4)"
cat << HERPDERP > "${name}" cat << HERPDERP > "${name}"
distro = "centos-stream" distro = "centos-stream"
+2 -2
View File
@@ -1,8 +1,8 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -ex set -ex
packages="gcc make bzip2 kernel-devel elfutils-libelf-devel" packages=(gcc make bzip2 kernel-devel elfutils-libelf-devel)
dnf install -y ${packages} # Intentionally not quoted dnf install -y "${packages[@]}"
mount -t auto /home/vagrant/VBoxGuestAdditions.iso /mnt mount -t auto /home/vagrant/VBoxGuestAdditions.iso /mnt
/mnt/VBoxLinuxAdditions.run install --nox11 2>&1 | tee /root/vbox_addon_install.log /mnt/VBoxLinuxAdditions.run install --nox11 2>&1 | tee /root/vbox_addon_install.log
umount /mnt umount /mnt
-12
View File
@@ -1,12 +0,0 @@
distro = "centos-stream"
version = "9"
iso = {
url = "https://mirror.stream.centos.org/9-stream/BaseOS/x86_64/iso/CentOS-Stream-9-latest-x86_64-boot.iso"
checksum = "2553e0812dba592ae4f73a06105eec1a285623c9ae790a5674456eed1ce9dc4c"
}
boot_command = [
"<up><tab><wait><bs><bs><bs><bs><bs>",
"inst.text inst.ks=cdrom:/ks.cfg console=tty0",
"<enter><wait>"
]
cd_files = [ "distros/centos-stream/9/disc/*" ]
+2 -2
View File
@@ -10,7 +10,7 @@ checksums="$(mktemp)"
until curl -f -L -o "${checksums}" "${baseurl}.SHA256SUM"; do until curl -f -L -o "${checksums}" "${baseurl}.SHA256SUM"; do
sleep 1 sleep 1
done done
sha="$(cat "${checksums}" | awk '/SHA256/ {print $4}')" sha="$(awk '/SHA256/ {print $4}' "${checksums}")"
rm "${checksums}" rm "${checksums}"
cat << HERPDERP > "${name}" cat << HERPDERP > "${name}"
@@ -22,7 +22,7 @@ iso = {
} }
boot_command = [ boot_command = [
"<up><tab><wait><bs><bs><bs><bs><bs>", "<up><tab><wait><bs><bs><bs><bs><bs>",
"inst.text inst.ks=cdrom:/ks.cfg console=tty0", "inst.text <wait>inst.ks=cdrom:/ks.cfg <wait>console=tty0",
"<enter><wait>" "<enter><wait>"
] ]
cd_files = [ "distros/centos-stream/9/disc/*" ] cd_files = [ "distros/centos-stream/9/disc/*" ]
+2 -2
View File
@@ -1,8 +1,8 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -ex set -ex
packages="bzip2 kernel-devel kernel-headers make perl gcc" packages=(bzip2 kernel-devel kernel-headers make perl gcc)
dnf install -y ${packages} # Intentionally not quoted dnf install -y "${packages[@]}"
mount -t auto /home/vagrant/VBoxGuestAdditions.iso /mnt mount -t auto /home/vagrant/VBoxGuestAdditions.iso /mnt
/mnt/VBoxLinuxAdditions.run install --nox11 2>&1 | tee /root/vbox_addon_install.log /mnt/VBoxLinuxAdditions.run install --nox11 2>&1 | tee /root/vbox_addon_install.log
umount /mnt umount /mnt
+2 -2
View File
@@ -1,8 +1,8 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -ex set -ex
packages="bzip2 dkms kernel-devel kernel-headers make perl gcc" packages=(bzip2 dkms kernel-devel kernel-headers make perl gcc)
yum install -y ${packages} # Intentionally not quoted yum install -y "${packages[@]}"
mount -t auto /home/vagrant/VBoxGuestAdditions.iso /mnt mount -t auto /home/vagrant/VBoxGuestAdditions.iso /mnt
/mnt/VBoxLinuxAdditions.run install 2>&1 | tee /root/vbox_addon_install.log /mnt/VBoxLinuxAdditions.run install 2>&1 | tee /root/vbox_addon_install.log
umount /mnt umount /mnt
+5 -5
View File
@@ -6,11 +6,11 @@ iso = {
} }
boot_command = [ boot_command = [
"<esc><wait>", "<esc><wait>",
"auto ", "auto <wait>",
"DEBIAN_FRONTEND=text ", "DEBIAN_FRONTEND=text <wait>",
"preseed/url=http://{{.HTTPIP}}:{{ .HTTPPort }}/preseed.cfg ", "preseed/url<wait>=http://{{.HTTPIP}}<wait>:{{ .HTTPPort }}/preseed.cfg <wait>",
"console=tty0 ", "console=tty0 <wait>",
"--- net.ifnames=0 biosdevnames=0 ", "--- <wait>net.ifnames=0 <wait>biosdevnames=0 <wait>",
"<enter>" "<enter>"
] ]
http_directory = "distros/debian/10/http/" http_directory = "distros/debian/10/http/"
+3 -3
View File
@@ -1,10 +1,10 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -ex set -ex
packages="bzip2 dkms build-essential linux-headers-$(uname -r)" packages=(bzip2 dkms build-essential "linux-headers-$(uname -r)")
apt install -y ${packages} # Intentionally not quoted apt install -y "${packages[@]}"
mount -t auto /home/vagrant/VBoxGuestAdditions.iso /mnt mount -t auto /home/vagrant/VBoxGuestAdditions.iso /mnt
/mnt/VBoxLinuxAdditions.run install 2>&1 | tee /root/vbox_addon_install.log /mnt/VBoxLinuxAdditions.run install 2>&1 | tee /root/vbox_addon_install.log
apt remove -y ${packages} # Also intentionally not quoted apt remove -y "${packages[@]}"
umount /mnt umount /mnt
rm /home/vagrant/VBoxGuestAdditions.iso rm /home/vagrant/VBoxGuestAdditions.iso
+5 -5
View File
@@ -6,11 +6,11 @@ iso = {
} }
boot_command = [ boot_command = [
"<esc><wait>", "<esc><wait>",
"auto ", "auto <wait>",
"DEBIAN_FRONTEND=text ", "DEBIAN_FRONTEND=text <wait>",
"preseed/url=http://{{.HTTPIP}}:{{ .HTTPPort }}/preseed.cfg ", "preseed/url<wait>=http://{{.HTTPIP}}<wait>:{{ .HTTPPort }}/preseed.cfg <wait>",
"console=tty0 ", "console=tty0 <wait>",
"--- net.ifnames=0 biosdevnames=0 ", "--- <wait>net.ifnames=0 <wait>biosdevnames=0 <wait>",
"<enter>" "<enter>"
] ]
http_directory = "distros/debian/11/http/" http_directory = "distros/debian/11/http/"
+1 -1
View File
@@ -6,7 +6,7 @@ apt autoremove -y
apt upgrade -y apt upgrade -y
# Configure sshd to be faster # Configure sshd to be faster
echo << EOF > /etc/ssh/sshd_config.d/00-vagrant_accept_pubkey.conf cat << EOF > /etc/ssh/sshd_config.d/00-vagrant_accept_pubkey.conf
UseDNS no UseDNS no
PubkeyAcceptedKeyTypes +ssh-rsa PubkeyAcceptedKeyTypes +ssh-rsa
EOF EOF
+3 -3
View File
@@ -1,10 +1,10 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -ex set -ex
packages="bzip2 dkms build-essential linux-headers-$(uname -r)" packages=(bzip2 dkms build-essential "linux-headers-$(uname -r)")
apt install -y ${packages} # Intentionally not quoted apt install -y "${packages[@]}"
mount -t auto /home/vagrant/VBoxGuestAdditions.iso /mnt mount -t auto /home/vagrant/VBoxGuestAdditions.iso /mnt
/mnt/VBoxLinuxAdditions.run install 2>&1 | tee /root/vbox_addon_install.log /mnt/VBoxLinuxAdditions.run install 2>&1 | tee /root/vbox_addon_install.log
apt remove -y ${packages} # Also intentionally not quoted apt remove -y "${packages[@]}"
umount /mnt umount /mnt
rm /home/vagrant/VBoxGuestAdditions.iso rm /home/vagrant/VBoxGuestAdditions.iso
+5 -5
View File
@@ -6,11 +6,11 @@ iso = {
} }
boot_command = [ boot_command = [
"<esc><wait>", "<esc><wait>",
"auto ", "auto <wait>",
"DEBIAN_FRONTEND=text ", "DEBIAN_FRONTEND=text <wait>",
"preseed/url=http://{{.HTTPIP}}:{{ .HTTPPort }}/preseed.cfg ", "preseed/url<wait>=http://{{.HTTPIP}}<wait>:{{ .HTTPPort }}/preseed.cfg <wait>",
"console=tty0 ", "console=tty0 <wait>",
"--- net.ifnames=0 biosdevnames=0 ", "--- <wait>net.ifnames=0 <wait>biosdevnames=0 ",
"<enter>" "<enter>"
] ]
http_directory = "distros/debian/12/http/" http_directory = "distros/debian/12/http/"
+1 -1
View File
@@ -6,7 +6,7 @@ apt autoremove -y
apt upgrade -y apt upgrade -y
# Configure sshd to be faster # Configure sshd to be faster
echo << EOF > /etc/ssh/sshd_config.d/00-vagrant_accept_pubkey.conf cat << EOF > /etc/ssh/sshd_config.d/00-vagrant_accept_pubkey.conf
UseDNS no UseDNS no
PubkeyAcceptedKeyTypes +ssh-rsa PubkeyAcceptedKeyTypes +ssh-rsa
EOF EOF
+3 -3
View File
@@ -1,10 +1,10 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -ex set -ex
packages="bzip2 dkms build-essential linux-headers-$(uname -r)" packages=(bzip2 dkms build-essential "linux-headers-$(uname -r)")
apt install -y ${packages} # Intentionally not quoted apt install -y "${packages[@]}"
mount -t auto /home/vagrant/VBoxGuestAdditions.iso /mnt mount -t auto /home/vagrant/VBoxGuestAdditions.iso /mnt
/mnt/VBoxLinuxAdditions.run install 2>&1 | tee /root/vbox_addon_install.log /mnt/VBoxLinuxAdditions.run install 2>&1 | tee /root/vbox_addon_install.log
apt remove -y ${packages} # Also intentionally not quoted apt remove -y "${packages[@]}"
umount /mnt umount /mnt
rm /home/vagrant/VBoxGuestAdditions.iso rm /home/vagrant/VBoxGuestAdditions.iso
-6
View File
@@ -4,11 +4,5 @@ set -ex
apt update apt update
apt upgrade -y apt upgrade -y
# Configure sshd to be faster
echo << EOF > /etc/ssh/sshd_config.d/00-vagrant_accept_pubkey.conf
UseDNS no
PubkeyAcceptedKeyTypes +ssh-rsa
EOF
# Clean up after ourselves # Clean up after ourselves
apt-get clean apt-get clean
+3 -3
View File
@@ -1,10 +1,10 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -ex set -ex
packages="bzip2 dkms build-essential linux-headers-$(uname -r)" packages=(bzip2 dkms build-essential "linux-headers-$(uname -r)")
apt install -y ${packages} # Intentionally not quoted apt install -y "${packages[@]}"
mount -t auto /home/vagrant/VBoxGuestAdditions.iso /mnt mount -t auto /home/vagrant/VBoxGuestAdditions.iso /mnt
/mnt/VBoxLinuxAdditions.run install 2>&1 | tee /root/vbox_addon_install.log /mnt/VBoxLinuxAdditions.run install 2>&1 | tee /root/vbox_addon_install.log
apt remove -y ${packages} # Also intentionally not quoted apt remove -y "${packages[@]}"
umount /mnt umount /mnt
rm /home/vagrant/VBoxGuestAdditions.iso rm /home/vagrant/VBoxGuestAdditions.iso
+1 -1
View File
@@ -6,7 +6,7 @@ iso = {
} }
boot_command = [ boot_command = [
"<up>e<down><down><end> ", "<up>e<down><down><end> ",
"net.ifnames=0 biosdevnames=0 inst.ks=cdrom:/x86_64.ks console=tty0<f10>" "net.ifnames=0 <wait>biosdevnames=0 <wait>inst.ks=cdrom:/x86_64.ks <wait>console=tty0<f10>"
] ]
cd_files = [ cd_files = [
"distros/fedora/38/*.ks" "distros/fedora/38/*.ks"
+4 -4
View File
@@ -14,16 +14,16 @@ checksums="${tmp}/checksums"
# First, find the proper URL, since it updates every build # First, find the proper URL, since it updates every build
curl -L -o "${listing}" "${fedora}" curl -L -o "${listing}" "${fedora}"
links="$(cat "${listing}" | pup 'a[href*=".iso"] attr{href}' | grep dvd)" links="$(pup -f "${listing}" 'a[href*=".iso"] attr{href}' | grep dvd)"
iso_name="$(echo "${links}" | grep -e 'iso$')" iso_name="$(echo "${links}" | grep -e 'iso$' | head -1)"
iso="${fedora}${iso_name}" iso="${fedora}${iso_name}"
# Read the SHA256 sum value # Read the SHA256 sum value
sums="$(cat "${listing}" | pup 'a[href*="CHECKSUM"] attr{href}')" sums="$(pup -f "${listing}" 'a[href*="CHECKSUM"] attr{href}' | head -1)"
until curl -f -L -o "${checksums}" "${fedora}${sums}"; do until curl -f -L -o "${checksums}" "${fedora}${sums}"; do
sleep 1 sleep 1
done done
sha="$(cat "${checksums}" | grep dvd | grep SHA256 | cut -d' ' -f 4)" sha="$(grep -e dvd "${checksums}" | grep SHA256 | cut -d' ' -f 4)"
# Write out HCL file # Write out HCL file
cat << EOF > "${name}" cat << EOF > "${name}"
+1 -1
View File
@@ -18,7 +18,7 @@ curl -L -o "${checksums}" "${base}.sha256"
until curl -f -L -o "${checksums}" "${base}.sha256"; do until curl -f -L -o "${checksums}" "${base}.sha256"; do
sleep 1 sleep 1
done done
sha="$(cat "${checksums}" | grep minimal | cut -d' ' -f 1)" sha="$(grep -e minimal "${checksums}" | cut -d' ' -f 1)"
# Write out HCL file # Write out HCL file
cat << EOF > "${name}" cat << EOF > "${name}"
+1 -1
View File
@@ -18,7 +18,7 @@ curl -L -o "${checksums}" "${base}.sha256"
until curl -f -L -o "${checksums}" "${base}.sha256"; do until curl -f -L -o "${checksums}" "${base}.sha256"; do
sleep 1 sleep 1
done done
sha="$(cat "${checksums}" | grep minimal | cut -d' ' -f 1)" sha="$(grep -e minimal "${checksums}" | cut -d' ' -f 1)"
# Write out HCL file # Write out HCL file
cat << EOF > "${name}" cat << EOF > "${name}"
+1 -1
View File
@@ -9,7 +9,7 @@ apt upgrade -y
# Do some magic with init # Do some magic with init
sed -i -E -e 's,^(ACTIVE_CONSOLES="/dev/tty).*",\11,' /etc/default/console-setup sed -i -E -e 's,^(ACTIVE_CONSOLES="/dev/tty).*",\11,' /etc/default/console-setup
echo << EOF > /etc/ssh/sshd_config.d/00-vagrant_accept_pubkey.conf cat << EOF > /etc/ssh/sshd_config.d/00-vagrant_accept_pubkey.conf
UseDNS no UseDNS no
PubkeyAcceptedKeyTypes +ssh-rsa PubkeyAcceptedKeyTypes +ssh-rsa
EOF EOF
+1 -1
View File
@@ -10,7 +10,7 @@ apt upgrade -y
sed -i -E -e 's,^(ACTIVE_CONSOLES="/dev/tty).*",\11,' /etc/default/console-setup sed -i -E -e 's,^(ACTIVE_CONSOLES="/dev/tty).*",\11,' /etc/default/console-setup
# Make sshd faster # Make sshd faster
echo << EOF > /etc/ssh/sshd_config.d/00-vagrant_accept_pubkey.conf cat << EOF > /etc/ssh/sshd_config.d/00-vagrant_accept_pubkey.conf
UseDNS no UseDNS no
PubkeyAcceptedKeyTypes +ssh-rsa PubkeyAcceptedKeyTypes +ssh-rsa
EOF EOF
+6 -6
View File
@@ -6,12 +6,12 @@ iso = {
} }
boot_command = [ boot_command = [
"e<down><down><down><end><bs><bs><bs>", "e<down><down><down><end><bs><bs><bs>",
"console=tty0 ", "console=tty0 <wait>",
"fsck.mode=skip ", "fsck.mode=skip <wait>",
"locale=en_US ", "locale=en_US <wait>",
"auto=true ", "auto=true <wait>",
"priority=critical ", "priority=<wait>critical <wait>",
"autoinstall", "autoinstall<wait>",
"<F10>", "<F10>",
] ]
cd_files = [ cd_files = [
+1 -1
View File
@@ -10,7 +10,7 @@ apt upgrade -y
sed -i -E -e 's,^(ACTIVE_CONSOLES="/dev/tty).*",\11,' /etc/default/console-setup sed -i -E -e 's,^(ACTIVE_CONSOLES="/dev/tty).*",\11,' /etc/default/console-setup
# Make sshd faster # Make sshd faster
echo << EOF > /etc/ssh/sshd_config.d/00-vagrant_accept_pubkey.conf cat << EOF > /etc/ssh/sshd_config.d/00-vagrant_accept_pubkey.conf
UseDNS no UseDNS no
PubkeyAcceptedKeyTypes +ssh-rsa PubkeyAcceptedKeyTypes +ssh-rsa
EOF EOF
+6 -6
View File
@@ -6,12 +6,12 @@ iso = {
} }
boot_command = [ boot_command = [
"e<down><down><down><end><bs><bs><bs>", "e<down><down><down><end><bs><bs><bs>",
"console=tty0 ", "console=tty0 <wait>",
"fsck.mode=skip ", "fsck.mode=skip <wait>",
"locale=en_US ", "locale=en_US <wait>",
"auto=true ", "auto=true <wait>",
"priority=critical ", "priority=critical <wait>",
"autoinstall", "autoinstall<wait>",
"<F10>", "<F10>",
] ]
cd_files = [ cd_files = [
+1 -1
View File
@@ -10,7 +10,7 @@ apt upgrade -y
sed -i -E -e 's,^(ACTIVE_CONSOLES="/dev/tty).*",\11,' /etc/default/console-setup sed -i -E -e 's,^(ACTIVE_CONSOLES="/dev/tty).*",\11,' /etc/default/console-setup
# Make sshd faster # Make sshd faster
echo << EOF > /etc/ssh/sshd_config.d/00-vagrant_accept_pubkey.conf cat << EOF > /etc/ssh/sshd_config.d/00-vagrant_accept_pubkey.conf
UseDNS no UseDNS no
PubkeyAcceptedKeyTypes +ssh-rsa PubkeyAcceptedKeyTypes +ssh-rsa
EOF EOF
+20 -2
View File
@@ -5,11 +5,29 @@ class Build:
def __init__(self, distro, version, provider: Provider): def __init__(self, distro, version, provider: Provider):
self.distro: str = distro self.distro: str = distro
self.version: str = str(version) self.version: str = str(version)
self.provider: str = provider self.provider: Provider = provider
@property @property
def var_file(self): def var_file(self):
return f"-var-file=distros/{self.distro}/{self.version}/{self.provider.arch}.pkrvars.hcl" return f"-var-file={self.var_path}"
@property
def matrix(self):
return {
"builder": str(self.provider),
"distro": self.var_path,
"runner": self.provider.runner,
}
@property
def is_github(self) -> bool:
if self.provider.runner is not None:
return True
return False
@property
def var_path(self):
return f"distros/{self.distro}/{self.version}/{self.provider.arch}.pkrvars.hcl"
@property @property
def only(self): def only(self):
+8
View File
@@ -5,3 +5,11 @@ class Provider:
def __str__(self) -> str: def __str__(self) -> str:
return f"{self.name}.{self.arch}" return f"{self.name}.{self.arch}"
@property
def runner(self) -> str:
if self.name == "qemu":
return "ubuntu-latest"
elif self.name.startswith("virtualbox"):
return "macos-12"
return None
+2 -2
View File
@@ -4,11 +4,11 @@ set -exo pipefail
distro="${1}" distro="${1}"
# Find URL # Find URL
url="$(cat "${distro}" | grep url | cut -f2 -d'"')" url="$(grep -e url "${distro}" | cut -f2 -d'"')"
curl -C - -O "${url}" curl -C - -O "${url}"
# Mount and extract # Mount and extract
file=$(printf "${url}" | sed -E -e 's#.*/(.*)$#\1#') file=$(printf '%s' "${url}" | sed -E -e 's#.*/(.*)$#\1#')
work="$(mktemp -d)" work="$(mktemp -d)"
xorriso -osirrox on -indev "${file}" -extract / "${work}" xorriso -osirrox on -indev "${file}" -extract / "${work}"
+5 -5
View File
@@ -13,15 +13,15 @@ if [ ! -e /etc/fedora-release ]; then
fi fi
# In CentOS 7, blkid returns duplicate devices # In CentOS 7, blkid returns duplicate devices
swap_device_uuid=`sudo /sbin/blkid -t TYPE=swap -o value -s UUID | uniq` swap_device_uuid=$(sudo /sbin/blkid -t TYPE=swap -o value -s UUID | uniq)
swap_device_label=`sudo /sbin/blkid -t TYPE=swap -o value -s LABEL | uniq` swap_device_label=$(sudo /sbin/blkid -t TYPE=swap -o value -s LABEL | uniq)
if [ -n "$swap_device_uuid" ]; then if [ -n "$swap_device_uuid" ]; then
swap_device=`readlink -f /dev/disk/by-uuid/"$swap_device_uuid"` swap_device=$(readlink -f /dev/disk/by-uuid/"$swap_device_uuid")
elif [ -n "$swap_device_label" ]; then elif [ -n "$swap_device_label" ]; then
swap_device=`readlink -f /dev/disk/by-label/"$swap_device_label"` swap_device=$(readlink -f /dev/disk/by-label/"$swap_device_label")
fi fi
if [ ! -z "${swap_device}" -a -e "${swap_device}" ]; then if [ -n "${swap_device}" ] && [ -e "${swap_device}" ]; then
sudo /sbin/swapoff "$swap_device" sudo /sbin/swapoff "$swap_device"
sudo dd if=/dev/zero of="$swap_device" bs=1M || : sudo dd if=/dev/zero of="$swap_device" bs=1M || :
sudo /sbin/mkswap ${swap_device_label:+-L "$swap_device_label"} ${swap_device_uuid:+-U "$swap_device_uuid"} "$swap_device" sudo /sbin/mkswap ${swap_device_label:+-L "$swap_device_label"} ${swap_device_uuid:+-U "$swap_device_uuid"} "$swap_device"
+1
View File
@@ -2,6 +2,7 @@
set -ex set -ex
# Configure vagrant user's SSH key # Configure vagrant user's SSH key
# shellcheck disable=SC2174
mkdir -m 0700 -p ~vagrant/.ssh mkdir -m 0700 -p ~vagrant/.ssh
curl -L -o ~vagrant/.ssh/authorized_keys "https://raw.githubusercontent.com/hashicorp/vagrant/master/keys/vagrant.pub" curl -L -o ~vagrant/.ssh/authorized_keys "https://raw.githubusercontent.com/hashicorp/vagrant/master/keys/vagrant.pub"
chmod 600 ~vagrant/.ssh/authorized_keys chmod 600 ~vagrant/.ssh/authorized_keys
+17 -2
View File
@@ -74,6 +74,21 @@ variable "http_directory" {
default = "" default = ""
} }
variable "cpu_model" {
type = string
default = "host"
}
variable "cpus" {
type = number
default = 4
}
variable "memory" {
type = number
default = 8192
}
locals { locals {
name = "${var.distro}-${var.version}" name = "${var.distro}-${var.version}"
description = templatefile("../README.box.md", { description = templatefile("../README.box.md", {
@@ -83,8 +98,8 @@ locals {
build = var.build build = var.build
}) })
cpus = 4 cpus = var.cpus
memory = 8192 memory = var.memory
disk_size = 10 disk_size = 10
ssh = { ssh = {
username = "vagrant" username = "vagrant"
+1 -1
View File
@@ -24,7 +24,7 @@ source "qemu" "amd64" {
headless = var.headless headless = var.headless
disk_cache = "writeback" disk_cache = "writeback"
format = "qcow2" format = "qcow2"
cpu_model = "host" cpu_model = var.cpu_model
qemuargs = [ qemuargs = [
#["-chardev", "stdio,id=char0,logfile=serial-output-qemu-${var.arch}-${var.distro}-${var.version},signal=off"], #["-chardev", "stdio,id=char0,logfile=serial-output-qemu-${var.arch}-${var.distro}-${var.version},signal=off"],