Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework build_iso.sh #1805

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 75 additions & 22 deletions build_iso.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
#!/bin/bash

packages_file="/tmp/archlive/packages.x86_64"
set -eu

# Packages to add to the archiso profile packages
readonly base_profile="/usr/share/archiso/configs/releng/"
readonly custom_profile="/tmp/archlive"
readonly packages_file="$custom_profile/packages.x86_64"
readonly airootfs="$custom_profile/airootfs"
readonly archinstall_dir="/root/archinstall"
readonly build_script="/root/build-archinstall.sh"
readonly build_service="/etc/systemd/system/build-archinstall.service"

# Packages to add to the archiso custom profile
packages=(
git
python
Expand All @@ -13,34 +21,79 @@ packages=(
python-pyparted
)

mkdir -p /tmp/archlive/airootfs/root/archinstall-git
cp -r . /tmp/archlive/airootfs/root/archinstall-git

cat <<- _EOF_ | tee /tmp/archlive/airootfs/root/.zprofile
cd archinstall-git
rm -rf dist

python -m build --wheel --no-isolation
pip install dist/archinstall*.whl

echo "This is an unofficial ISO for development and testing of archinstall. No support will be provided."
echo "This ISO was built from Git SHA $GITHUB_SHA"
echo "Type archinstall to launch the installer."
_EOF_

pacman -Sy
pacman --noconfirm -S git archiso
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps you can add the --disable-download-timeout flag here. It helps with errors like Operation too slow.


cp -r /usr/share/archiso/configs/releng/* /tmp/archlive
# Copy an archiso base profile to create a custom profile from
cp -r $base_profile $custom_profile

# Copy the archinstall directory to the archiso custom profile
cp -r "$(dirname "$0")" ${airootfs}${archinstall_dir}

# Remove the archinstall package from the archiso custom profile
sed -i /archinstall/d $packages_file

# Add packages to the archiso profile packages
# Add packages to the archiso custom profile
for package in "${packages[@]}"; do
echo "$package" >> $packages_file
done

find /tmp/archlive
cd /tmp/archlive
# Use the `GITHUB_SHA` environment variable for the commit hash if it exists
if [[ -v GITHUB_SHA ]]; then
commit_hash="$GITHUB_SHA"
# Use git for the commit hash if the `GITHUB_SHA` environment varible is not set
else
commit_hash="$(git rev-parse HEAD)"
fi

# Append an archinstall developement message to motd
cat <<- _EOF_ >> $airootfs/etc/motd

archinstall development ISO
Git commit hash: $commit_hash
This is an unofficial ISO for development and testing of archinstall. No support will be provided.
_EOF_

# A script to build archinstall in the live environment
cat <<- _EOF_ > ${airootfs}${build_script}
cd $archinstall_dir
rm -rf dist

python -m build --wheel --no-isolation
pip install dist/*.whl
_EOF_

# A service to run the archinstall build script in the live environment
cat <<- _EOF_ > ${airootfs}${build_service}
[Unit]
Description=Build archinstall
After=network.target

[Service]
Type=oneshot
ExecStart=/bin/sh $build_script

[Install]
WantedBy=multi-user.target
_EOF_

# Enable the service that runs the archinstall build script
ln -sf $build_service $airootfs/etc/systemd/system/multi-user.target.wants/

# A startup file to wait for the completion of the service that runs the archinstall build script
cat <<- _EOF_ > $airootfs/root/.zprofile
if [ "\$(systemctl show -p SubState --value ${build_service##*/})" != "dead" ]; then
printf "Building archinstall (${build_service##*/})..."
while [ "\$(systemctl show -p SubState --value ${build_service##*/})" != "dead" ]; do
sleep 1
done
echo " done"
echo "Type archinstall to launch the installer."
fi

cd $archinstall_dir
_EOF_

cd $custom_profile

mkarchiso -v -w work/ -o out/ ./
mkarchiso -v $custom_profile