From fd82cbe2792c9746ba52255470a4a4a6b221d9a0 Mon Sep 17 00:00:00 2001 From: Matt Compton Date: Sat, 17 Apr 2021 15:01:18 -0400 Subject: [PATCH] migrating from old repo --- .gitignore | 3 + README.md | 13 + build_iso.sh | 25 + chrooted.sh | 18 + inject.sh | 11 + mkarchiso | 1005 +++++++++++++++++ pear/airootfs/etc/buildstamp | 1 + pear/airootfs/etc/doas.conf | 2 + pear/airootfs/etc/mkinitcpio.conf | 70 ++ pear/airootfs/etc/mkinitcpio.d/linux.preset | 11 + pear/airootfs/etc/packages.x86_64 | 51 + pear/airootfs/etc/pacman.conf | 111 ++ pear/airootfs/etc/pacman.d/.keep | 1 + pear/airootfs/etc/pacman.d/mirrorlist | 128 +++ pear/airootfs/etc/profile | 1 + pear/airootfs/etc/skel/.bashrc | 15 + pear/airootfs/etc/skel/.xinitrc | 3 + pear/airootfs/etc/ssh/sshd_config | 116 ++ pear/airootfs/etc/sudoers | 2 + pear/airootfs/etc/sysrootpkgs | 10 + .../etc/systemd/network/20-ethernet.network | 13 + .../cloud-config.service | 1 + .../cloud-final.service | 1 + .../cloud-init-local.service | 1 + .../cloud-init.service | 1 + .../systemd/system/etc-pacman.d-gnupg.mount | 11 + .../getty@tty1.service.d/autologin.conf | 3 + .../multi-user.target.wants/sshd.service | 1 + .../systemd-networkd.service | 1 + .../systemd-resolved.service | 1 + .../etc-pacman.d-gnupg.mount | 1 + .../pacman-init.service | 1 + .../systemd-networkd-wait-online.service | 1 + .../etc/systemd/system/pacman-init.service | 20 + .../systemd-networkd.socket | 1 + .../wait-for-only-one-interface.conf | 5 + pear/airootfs/root/.profile | 3 + pear/airootfs/root/.xinitrc | 3 + .../loader/entries/archiso-x86_64-linux.conf | 7 + pear/efiboot/loader/loader.conf | 5 + pear/packages.x86_64 | 51 + pear/pacman.conf | 111 ++ pear/profiledef.sh | 15 + pear/syslinux/syslinux-linux.cfg | 8 + pear/syslinux/syslinux.cfg | 11 + sysrootpkgs | 2 + 46 files changed, 1876 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100755 build_iso.sh create mode 100644 chrooted.sh create mode 100755 inject.sh create mode 100755 mkarchiso create mode 100644 pear/airootfs/etc/buildstamp create mode 100644 pear/airootfs/etc/doas.conf create mode 100644 pear/airootfs/etc/mkinitcpio.conf create mode 100644 pear/airootfs/etc/mkinitcpio.d/linux.preset create mode 100644 pear/airootfs/etc/packages.x86_64 create mode 100644 pear/airootfs/etc/pacman.conf create mode 100644 pear/airootfs/etc/pacman.d/.keep create mode 100644 pear/airootfs/etc/pacman.d/mirrorlist create mode 100644 pear/airootfs/etc/profile create mode 100755 pear/airootfs/etc/skel/.bashrc create mode 100755 pear/airootfs/etc/skel/.xinitrc create mode 100644 pear/airootfs/etc/ssh/sshd_config create mode 100644 pear/airootfs/etc/sudoers create mode 100644 pear/airootfs/etc/sysrootpkgs create mode 100644 pear/airootfs/etc/systemd/network/20-ethernet.network create mode 120000 pear/airootfs/etc/systemd/system/cloud-init.target.wants/cloud-config.service create mode 120000 pear/airootfs/etc/systemd/system/cloud-init.target.wants/cloud-final.service create mode 120000 pear/airootfs/etc/systemd/system/cloud-init.target.wants/cloud-init-local.service create mode 120000 pear/airootfs/etc/systemd/system/cloud-init.target.wants/cloud-init.service create mode 100644 pear/airootfs/etc/systemd/system/etc-pacman.d-gnupg.mount create mode 100644 pear/airootfs/etc/systemd/system/getty@tty1.service.d/autologin.conf create mode 120000 pear/airootfs/etc/systemd/system/multi-user.target.wants/sshd.service create mode 120000 pear/airootfs/etc/systemd/system/multi-user.target.wants/systemd-networkd.service create mode 120000 pear/airootfs/etc/systemd/system/multi-user.target.wants/systemd-resolved.service create mode 120000 pear/airootfs/etc/systemd/system/network-online.target.wants/etc-pacman.d-gnupg.mount create mode 120000 pear/airootfs/etc/systemd/system/network-online.target.wants/pacman-init.service create mode 120000 pear/airootfs/etc/systemd/system/network-online.target.wants/systemd-networkd-wait-online.service create mode 100644 pear/airootfs/etc/systemd/system/pacman-init.service create mode 120000 pear/airootfs/etc/systemd/system/sockets.target.wants/systemd-networkd.socket create mode 100644 pear/airootfs/etc/systemd/system/systemd-networkd-wait-online.service.d/wait-for-only-one-interface.conf create mode 100755 pear/airootfs/root/.profile create mode 100755 pear/airootfs/root/.xinitrc create mode 100644 pear/efiboot/loader/entries/archiso-x86_64-linux.conf create mode 100644 pear/efiboot/loader/loader.conf create mode 100644 pear/packages.x86_64 create mode 100644 pear/pacman.conf create mode 100644 pear/profiledef.sh create mode 100644 pear/syslinux/syslinux-linux.cfg create mode 100644 pear/syslinux/syslinux.cfg create mode 100644 sysrootpkgs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..157ab3f --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*.iso +sysroot/ +sysroot.* \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..c21c6ac --- /dev/null +++ b/README.md @@ -0,0 +1,13 @@ +# PearISO +Build the (new) Arch-based pear iso. + +## Packages: +* `pacman-contrib` +* `archiso` +That's all, I think + +## Build ISO: +* `build_iso.sh` +* If you get an error about `/tmp/` running out of space, reboot (to clear tmpfs), then edit the `WORKDIR=...` line to a regular dir name. + * This (could) happen because the script is written to make a temp dir in `/tmp`, which is a virtual FS that lives in RAM. + * If it happens to many people, we can just add a commandline arg to change `WORKDIR` \ No newline at end of file diff --git a/build_iso.sh b/build_iso.sh new file mode 100755 index 0000000..3338353 --- /dev/null +++ b/build_iso.sh @@ -0,0 +1,25 @@ +rm -fv pearos-live-*.iso + +""" +fallocate -l800M sysroot.img +loopdev=$(sudo losetup -Pf --show sysroot.img) +sudo mkfs.ext4 ${loopdev} +sysrootwork=$(mktemp -d) +sudo mount ${loopdev} $sysrootwork +sudo pacstrap ${sysrootwork} $(cat sysrootpkgs) +sudo umount ${sysrootwork} +mv sysroot.img pear/airootfs/. +""" + +WORKDIR=$(mktemp -d) +# idk if this would've happened automatically? +cp pear/pacman.conf pear/airootfs/etc/. +cp pear/packages.x86_64 pear/airootfs/etc/packages.x86_64 +cp /etc/pacman.d/mirrorlist pear/airootfs/etc/pacman.d/. +echo "Built on $(date +"%D @ %T EST")" > pear/airootfs/etc/buildstamp +time sudo ./mkarchiso -v -w $WORKDIR -o . pear +sudo rm -rf $WORKDIR + +if [[ "$1" == "docker" ]]; then + cp *.iso /output/. +fi \ No newline at end of file diff --git a/chrooted.sh b/chrooted.sh new file mode 100644 index 0000000..18ebb80 --- /dev/null +++ b/chrooted.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# This file is run via mkarchiso while chrooted as the new system +echo "We're in the new system. :)" +echo "Performing minor tweaks" +sed -i 's/Arch/PearOS/g' /etc/issue +sed -i 's/Arch/PearOS/g' /etc/arch-release +sed -i 's/Arch/PearOS/g' /etc/os-release +echo "PearLive" > /etc/hostname +#reflector --latest 5 --sort rate --save /etc/pacman.d/mirrorlist +echo "sudo reflector --verbose --latest 5 --sort rate --save /etc/pacman.d/mirrorlist" >> /usr/bin/mirrorsetup +chmod +x /usr/bin/mirrorsetup +# We don't add carly until here so that our packages which change +# /etc/skel have been installed already +/usr/bin/useradd -m carly +/usr/bin/usermod -p $(echo "pear" | openssl passwd -6 -stdin) carly +/usr/bin/usermod -p $(echo "pear" | openssl passwd -6 -stdin) root +/usr/bin/chmod +x /home/carly/.xinitrc +echo "Configured the 'carly' user. Exiting chroot." diff --git a/inject.sh b/inject.sh new file mode 100755 index 0000000..10e93e1 --- /dev/null +++ b/inject.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +echo "inject.sh started." + +echo "Chrooting to $1, and running chrooted.sh" +cp chrooted.sh ${1}/. +chmod +x ${1}/chrooted.sh +chroot $1 /bin/bash -c ./chrooted.sh +rm ${1}/chrooted.sh + +echo "inject.sh completed." \ No newline at end of file diff --git a/mkarchiso b/mkarchiso new file mode 100755 index 0000000..ab920dd --- /dev/null +++ b/mkarchiso @@ -0,0 +1,1005 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: GPL-3.0-or-later + +set -e -u + +# Control the environment +umask 0022 +export LANG="C" +export SOURCE_DATE_EPOCH="${SOURCE_DATE_EPOCH:-"$(date +%s)"}" + +# Set application name from the script's file name +app_name="${0##*/}" + +# Define global variables. All of them will be overwritten later +pkg_list=() +quiet="" +work_dir="" +out_dir="" +img_name="" +gpg_key="" +iso_name="" +iso_label="" +iso_publisher="" +iso_application="" +iso_version="" +install_dir="" +arch="" +pacman_conf="" +packages="" +bootmodes=() +airootfs_image_type="" +airootfs_image_tool_options=() +declare -A file_permissions=() + +startdir=$(pwd) + +# Show an INFO message +# $1: message string +_msg_info() { + local _msg="${1}" + [[ "${quiet}" == "y" ]] || printf '[%s] INFO: %s\n' "${app_name}" "${_msg}" +} + +# Show a WARNING message +# $1: message string +_msg_warning() { + local _msg="${1}" + printf '[%s] WARNING: %s\n' "${app_name}" "${_msg}" >&2 +} + +# Show an ERROR message then exit with status +# $1: message string +# $2: exit code number (with 0 does not exit) +_msg_error() { + local _msg="${1}" + local _error=${2} + printf '[%s] ERROR: %s\n' "${app_name}" "${_msg}" >&2 + if (( _error > 0 )); then + exit "${_error}" + fi +} + +_mount_airootfs() { + trap "_umount_airootfs" EXIT HUP INT TERM + install -d -m 0755 -- "${work_dir}/mnt/airootfs" + _msg_info "Mounting '${airootfs_dir}.img' on '${work_dir}/mnt/airootfs'..." + mount -- "${airootfs_dir}.img" "${work_dir}/mnt/airootfs" + _msg_info "Done!" +} + +_umount_airootfs() { + _msg_info "Unmounting '${work_dir}/mnt/airootfs'..." + umount -d -- "${work_dir}/mnt/airootfs" + _msg_info "Done!" + rmdir -- "${work_dir}/mnt/airootfs" + trap - EXIT HUP INT TERM +} + +# Show help usage, with an exit status. +# $1: exit status number. +_usage() { + IFS='' read -r -d '' usagetext < + options: + -A Set an application name for the ISO + Default: '${iso_application}' + -C pacman configuration file. + Default: '${pacman_conf}' + -D Set an install_dir. All files will by located here. + Default: '${install_dir}' + NOTE: Max 8 characters, use only [a-z0-9] + -L