Skip to content

Commit

Permalink
add echo variabels
Browse files Browse the repository at this point in the history
  • Loading branch information
valerius committed Jan 16, 2024
1 parent 6c869d2 commit 8c9ef12
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rpi-aarch64-image-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ jobs:
sudo rm -rf $WORKDIR_BASE
echo "Work folder deleted"
- name: Unmount and Release Loop Device
- name: Release Loop Device
if: always()
run: |
if [ -n "$LOOP_DEVICE" ]; then
Expand Down
12 changes: 11 additions & 1 deletion build-archlinux-rpi-aarch64-img.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,44 +41,52 @@ ARM_VERSION="${3}"
WORKDIR_BASE="${4}"

# Check if the disk exists
echo "Checking if the disk $LOOP_DEVICE exists..."
if [ ! -b "$LOOP_DEVICE" ]; then
echo "The disk $LOOP_DEVICE does not exist. Exiting."
exit 1
fi

echo "Working directory: $WORKDIR_BASE"
echo "Create $WORKDIR_BASE if not exists..."
# Create the working directory if not exists
if [ ! -d "$WORKDIR_BASE" ]; then
mkdir -p $WORKDIR_BASE
fi

echo "setup locales and keymap..."
# Define default locale and keymap settings
default_locale="en_US.UTF-8"
timezone="Europe/Paris"

echo "Setting up the disk..."
# Partition the disk using parted
parted --script ${LOOP_DEVICE} mklabel msdos
parted --script ${LOOP_DEVICE} mkpart primary fat32 1MiB 257MiB
parted --script ${LOOP_DEVICE} set 1 lba on
parted --script ${LOOP_DEVICE} mkpart primary 257MiB 100%

# Create file systems
echo "Creating file systems..."
mkfs.vfat ${LOOP_DEVICE}p1 -F 32 -n PI-BOOT
mkfs.ext4 -q -E lazy_itable_init=0,lazy_journal_init=0 -F ${LOOP_DEVICE}p2 -L PI-ROOT

# Mount partitions
echo "Mounting partitions..."
mkdir -p "${WORKDIR_BASE}/root"
mount ${LOOP_DEVICE}p2 "${WORKDIR_BASE}/root"
mkdir -p "${WORKDIR_BASE}/root/boot"
mount ${LOOP_DEVICE}p1 "${WORKDIR_BASE}/root/boot"

# Download and extract root filesystem
echo "Downloading images..."
if [ ! -f "$WORKDIR_BASE/ArchLinuxARM-rpi-${ARM_VERSION}-latest.tar.gz" ] || [ ! -f "$WORKDIR_BASE/ArchLinuxARM-rpi-${ARM_VERSION}-latest.tar.gz.md5" ]; then
# Download the image and the MD5 checksum file
wget --quiet "${archlinuxarm}" -O "$WORKDIR_BASE/ArchLinuxARM-rpi-${ARM_VERSION}-latest.tar.gz"
wget --quiet "${archlinuxarm_md5}" -O "$WORKDIR_BASE/ArchLinuxARM-rpi-${ARM_VERSION}-latest.tar.gz.md5"
fi

# Verify MD5 checksum
echo "Verifying MD5 checksum..."
cd $WORKDIR_BASE
md5sum --check "ArchLinuxARM-rpi-${ARM_VERSION}-latest.tar.gz.md5"
if [ $? -ne 0 ]; then
Expand All @@ -87,10 +95,12 @@ if [ $? -ne 0 ]; then
fi

# If the checksum is correct, proceed with extraction
echo "Extracting root filesystem..."
bsdtar -xpf "$WORKDIR_BASE/ArchLinuxARM-rpi-${ARM_VERSION}-latest.tar.gz" -C $WORKDIR_BASE/root
sync

# Make the new root folder a mount point
echo "Making the new root folder a mount point..."
mount --bind $WORKDIR_BASE/root $WORKDIR_BASE/root

echo "Setting locale and keymap..."
Expand Down

0 comments on commit 8c9ef12

Please sign in to comment.