This commit is contained in:
commit
32dfb09078
4 changed files with 111 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
archiso
|
16
.woodpecker.yaml
Normal file
16
.woodpecker.yaml
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
when:
|
||||||
|
- event: [manual, cron]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: build
|
||||||
|
secrets: [registry_user, registry_password]
|
||||||
|
image: archlinux:base-devel
|
||||||
|
commands:
|
||||||
|
- ./build-iso
|
||||||
|
- eval $(grep iso_ archiso/profiledef.sh)
|
||||||
|
- ISO_FILE="$iso_name-$iso_version-x86_64.iso"
|
||||||
|
- echo $ISO_FILE
|
||||||
|
- |
|
||||||
|
curl --user ${REGISTRY_USER}:${REGISTRY_PASSWORD}
|
||||||
|
--upload-file $ISO_FILE
|
||||||
|
${CI_FORGE_URL}/api/packages/${CI_REPO_OWNER}/generic/$ISO_FILE
|
93
build-iso
Executable file
93
build-iso
Executable file
|
@ -0,0 +1,93 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
kernel=linux-lts
|
||||||
|
config=releng
|
||||||
|
working_dir=$PWD
|
||||||
|
build_dir=${working_dir}/archiso
|
||||||
|
|
||||||
|
pkg_add=(
|
||||||
|
"$kernel-headers"
|
||||||
|
ansible
|
||||||
|
zfs-dkms
|
||||||
|
)
|
||||||
|
|
||||||
|
function as_root {
|
||||||
|
if [ $(id -u) == 0 ]; then
|
||||||
|
$@
|
||||||
|
else
|
||||||
|
sudo "$@"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function install_archiso {
|
||||||
|
if ! type mkarchiso >/dev/null 2>&1; then
|
||||||
|
as_root pacman -S archiso --noconfirm
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function prepare {
|
||||||
|
install_archiso
|
||||||
|
[ -d "$build_dir" ] && as_root rm -rf "$build_dir"
|
||||||
|
cp -r "/usr/share/archiso/configs/${config}" $build_dir
|
||||||
|
}
|
||||||
|
|
||||||
|
function replace_kernel_paths {
|
||||||
|
for file in "${@}"; do
|
||||||
|
sed -i "s/vmlinuz-linux/vmlinuz-$kernel/" "$file"
|
||||||
|
sed -i "s/initramfs-linux.img/initramfs-$kernel.img/" "$file"
|
||||||
|
echo "replaced kernel paths: $file"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
function add_packages {
|
||||||
|
sed -i "s/^linux$/$kernel/" "$build_dir/packages.x86_64"
|
||||||
|
for pkg in "${pkg_add[@]}"; do
|
||||||
|
echo "add package: $pkg"
|
||||||
|
echo "$pkg" >> "$build_dir/packages.x86_64"
|
||||||
|
done
|
||||||
|
preset_path="$build_dir/airootfs/etc/mkinitcpio.d/$kernel.preset"
|
||||||
|
mv "$build_dir/airootfs/etc/mkinitcpio.d/linux.preset" "$preset_path"
|
||||||
|
replace_kernel_paths "$preset_path"
|
||||||
|
}
|
||||||
|
|
||||||
|
function boot_config {
|
||||||
|
replace_kernel_paths "$build_dir"/syslinux/*.cfg
|
||||||
|
replace_kernel_paths "$build_dir"/efiboot/loader/entries/*.conf
|
||||||
|
}
|
||||||
|
|
||||||
|
function pacman_config {
|
||||||
|
echo -e "\n[archzfs]\nServer = https://zxcvfdsa.com/archzfs/\$repo/\$arch" >> "$build_dir"/pacman.conf
|
||||||
|
}
|
||||||
|
|
||||||
|
function iso_config {
|
||||||
|
profile="$build_dir"/profiledef.sh
|
||||||
|
sed -i "s/iso_name=\"archlinux\"/iso_name=\"archlinux-klowner\"/" "$profile"
|
||||||
|
}
|
||||||
|
|
||||||
|
function pubkey_config {
|
||||||
|
root_ssh_dir="$build_dir"/airootfs/root/.ssh
|
||||||
|
mkdir $root_ssh_dir
|
||||||
|
chmod 700 $root_ssh_dir
|
||||||
|
authorized_keys="$root_ssh_dir"/authorized_keys
|
||||||
|
for key in $PWD/keys/*.pub; do
|
||||||
|
echo "add authorized key: ${key##*/}"
|
||||||
|
cat "$key" >> "$authorized_keys"
|
||||||
|
done
|
||||||
|
chmod 600 "$authorized_keys"
|
||||||
|
}
|
||||||
|
|
||||||
|
function build_iso {
|
||||||
|
temp_dir=$(as_root mktemp -d)
|
||||||
|
as_root chmod 755 "$temp_dir"
|
||||||
|
as_root mkarchiso -v -w "$temp_dir/archiso" -o "$build_dir"/out "$build_dir" && echo "ISO build complete"
|
||||||
|
as_root rm -rf "$temp_dir"
|
||||||
|
}
|
||||||
|
|
||||||
|
prepare
|
||||||
|
add_packages
|
||||||
|
boot_config
|
||||||
|
pacman_config
|
||||||
|
iso_config
|
||||||
|
pubkey_config
|
||||||
|
build_iso
|
1
keys/id_ed25519_ansible.pub
Normal file
1
keys/id_ed25519_ansible.pub
Normal file
|
@ -0,0 +1 @@
|
||||||
|
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAe6iofwtrKOfMpOcI0g0UFLfculiBShLTeM/ucez8ND Ansible infrastructure key
|
Loading…
Add table
Add a link
Reference in a new issue