summaryrefslogtreecommitdiffstats
path: root/main/mkinitfs/0001-init-generate-the-repositories-after-relocation.patch
blob: b5c14d8dd665133bb602be210372390092e66e42 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
From eb96e64b989ae7cf39cd0cdf849104ac1d5ee655 Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
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