From eb96e64b989ae7cf39cd0cdf849104ac1d5ee655 Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Wed, 4 Jan 2012 14:53:52 +0000 Subject: [PATCH] init: generate the repositories after relocation This solves problem when UUID is used in syslinux.cfg when booting USB devices. The generated repositories had /media/$UUID/apks but the /media/$UUID got relocated to /media/usb --- initramfs-init.in | 24 +++++++++++++++--------- 1 files changed, 15 insertions(+), 9 deletions(-) diff --git a/initramfs-init.in b/initramfs-init.in index 98916d7..226872b 100755 --- a/initramfs-init.in +++ b/initramfs-init.in @@ -269,6 +269,12 @@ find_fs_type() { done } +# find the dirs under ALPINE_MNT that are boot repositories +find_boot_repositories() { + find $ALPINE_MNT -name .boot_repository -type f -maxdepth 3 \ + | sed 's:/.boot_repository$::' +} + # gotta start from somewhere :) echo "Alpine Init $VERSION" @@ -429,8 +435,7 @@ retry_mount -o ro $mount_opts $ALPINE_DEV $ALPINE_MNT >/dev/null 2>&1 eend $? # generate apk repositories file -echo "$(find $ALPINE_MNT -name .boot_repository -type f -maxdepth 3 \ - | sed 's:/.boot_repository$::')" > /tmp/repositories +find_boot_repositories > /tmp/repositories # early console? if [ "$SINGLEMODE" = "yes" ]; then @@ -526,13 +531,9 @@ mkdir -p $sysroot/etc/apk/keys/ cp -a /etc/apk/keys $sysroot/etc/apk # generate repo opts for apk -if [ ! -f $sysroot/etc/apk/repositories ]; then - mv /tmp/repositories $sysroot/etc/apk/ -else - for i in $(cat /tmp/repositories); do - repo_opt="$repo_opt --repository $i" - done -fi +for i in $(cat /tmp/repositories); do + repo_opt="$repo_opt --repository $i" +done # install new root ebegin "Installing packages to root filesystem" @@ -565,6 +566,11 @@ if [ -z "$has_fstab" ] && [ -f "$sysroot"/etc/fstab ]; then relocate_alpine_mnt "$sysroot"/etc/fstab fi +# generate repositories if none exists. this needs to be done after relocation +if ! [ -f "$sysroot"/etc/apk/repositories ]; then + find_boot_repositories > "$sysroot"/etc/apk/repositories +fi + # respect mount options in fstab for ALPINE_MNT (e.g if user wants rw) opts=$(awk "\$2 == \"$ALPINE_MNT\" {print \$4}" $sysroot/etc/fstab) if [ -n "$opts" ]; then -- 1.7.8.2