Browse code

Add support for Arch Linux ARM. (Close #16695)

Signed-off-by: Giampaolo Mancini <giampaolo@trampolineup.com>

Switch to "case"

Signed-off-by: Giampaolo Mancini <giampaolo@trampolineup.com>

Support multiple ARM architectures

Signed-off-by: Giampaolo Mancini <giampaolo@trampolineup.com>

Add check for ArchLinuxARM Keyring

Signed-off-by: Giampaolo Mancini <giampaolo@trampolineup.com>

mkimage-arch.sh: Fix for merging

Signed-off-by: Giampaolo Mancini <giampaolo@trampolineup.com>

manchoz authored on 2015/09/29 21:06:19
Showing 2 changed files
... ...
@@ -14,6 +14,7 @@ hash expect &>/dev/null || {
14 14
 	exit 1
15 15
 }
16 16
 
17
+
17 18
 export LANG="C.UTF-8"
18 19
 
19 20
 ROOTFS=$(mktemp -d ${TMPDIR:-/var/tmp}/rootfs-archlinux-XXXXXXXXXX)
... ...
@@ -47,15 +48,43 @@ IFS=','
47 47
 PKGIGNORE="${PKGIGNORE[*]}"
48 48
 unset IFS
49 49
 
50
+case "$(uname -m)" in
51
+	armv*)
52
+		if pacman -Q archlinuxarm-keyring >/dev/null 2>&1; then
53
+			pacman-key --init
54
+			pacman-key --populate archlinuxarm
55
+		else
56
+			echo "Could not find archlinuxarm-keyring. Please, install it and run pacman-key --populate archlinuxarm"
57
+			exit 1
58
+		fi
59
+		PACMAN_CONF='./mkimage-archarm-pacman.conf'
60
+		PACMAN_MIRRORLIST='Server = http://mirror.archlinuxarm.org/$arch/$repo'
61
+		PACMAN_EXTRA_PKGS='archlinuxarm-keyring'
62
+		EXPECT_TIMEOUT=120
63
+		ARCH_KEYRING=archlinuxarm
64
+		DOCKER_IMAGE_NAME=archlinuxarm
65
+		;;
66
+	*)
67
+		PACMAN_CONF='./mkimage-arch-pacman.conf'
68
+		PACMAN_MIRRORLIST='Server = https://mirrors.kernel.org/archlinux/$repo/os/$arch'
69
+		PACMAN_EXTRA_PKGS=''
70
+		EXPECT_TIMEOUT=60
71
+		ARCH_KEYRING=archlinux
72
+		DOCKER_IMAGE_NAME=archlinux
73
+		;;
74
+esac
75
+
76
+export PACMAN_MIRRORLIST
77
+
50 78
 expect <<EOF
51 79
 	set send_slow {1 .1}
52 80
 	proc send {ignore arg} {
53 81
 		sleep .1
54 82
 		exp_send -s -- \$arg
55 83
 	}
56
-	set timeout 60
84
+	set timeout $EXPECT_TIMEOUT
57 85
 
58
-	spawn pacstrap -C ./mkimage-arch-pacman.conf -c -d -G -i $ROOTFS base haveged --ignore $PKGIGNORE
86
+	spawn pacstrap -C $PACMAN_CONF -c -d -G -i $ROOTFS base haveged $PACMAN_EXTRA_PKGS --ignore $PKGIGNORE
59 87
 	expect {
60 88
 		-exact "anyway? \[Y/n\] " { send -- "n\r"; exp_continue }
61 89
 		-exact "(default=all): " { send -- "\r"; exp_continue }
... ...
@@ -64,11 +93,11 @@ expect <<EOF
64 64
 EOF
65 65
 
66 66
 arch-chroot $ROOTFS /bin/sh -c 'rm -r /usr/share/man/*'
67
-arch-chroot $ROOTFS /bin/sh -c "haveged -w 1024; pacman-key --init; pkill haveged; pacman -Rs --noconfirm haveged; pacman-key --populate archlinux; pkill gpg-agent"
67
+arch-chroot $ROOTFS /bin/sh -c "haveged -w 1024; pacman-key --init; pkill haveged; pacman -Rs --noconfirm haveged; pacman-key --populate $ARCH_KEYRING; pkill gpg-agent"
68 68
 arch-chroot $ROOTFS /bin/sh -c "ln -s /usr/share/zoneinfo/UTC /etc/localtime"
69 69
 echo 'en_US.UTF-8 UTF-8' > $ROOTFS/etc/locale.gen
70 70
 arch-chroot $ROOTFS locale-gen
71
-arch-chroot $ROOTFS /bin/sh -c 'echo "Server = https://mirrors.kernel.org/archlinux/\$repo/os/\$arch" > /etc/pacman.d/mirrorlist'
71
+arch-chroot $ROOTFS /bin/sh -c 'echo $PACMAN_MIRRORLIST > /etc/pacman.d/mirrorlist'
72 72
 
73 73
 # udev doesn't work in containers, rebuild /dev
74 74
 DEV=$ROOTFS/dev
... ...
@@ -88,6 +117,6 @@ mknod -m 600 $DEV/initctl p
88 88
 mknod -m 666 $DEV/ptmx c 5 2
89 89
 ln -sf /proc/self/fd $DEV/fd
90 90
 
91
-tar --numeric-owner --xattrs --acls -C $ROOTFS -c . | docker import - archlinux
92
-docker run --rm -t archlinux echo Success.
91
+tar --numeric-owner --xattrs --acls -C $ROOTFS -c . | docker import - $DOCKER_IMAGE_NAME
92
+docker run --rm -t $DOCKER_IMAGE_NAME echo Success.
93 93
 rm -rf $ROOTFS
94 94
new file mode 100644
... ...
@@ -0,0 +1,98 @@
0
+#
1
+# /etc/pacman.conf
2
+#
3
+# See the pacman.conf(5) manpage for option and repository directives
4
+
5
+#
6
+# GENERAL OPTIONS
7
+#
8
+[options]
9
+# The following paths are commented out with their default values listed.
10
+# If you wish to use different paths, uncomment and update the paths.
11
+#RootDir     = /
12
+#DBPath      = /var/lib/pacman/
13
+#CacheDir    = /var/cache/pacman/pkg/
14
+#LogFile     = /var/log/pacman.log
15
+#GPGDir      = /etc/pacman.d/gnupg/
16
+HoldPkg     = pacman glibc
17
+#XferCommand = /usr/bin/curl -C - -f %u > %o
18
+#XferCommand = /usr/bin/wget --passive-ftp -c -O %o %u
19
+#CleanMethod = KeepInstalled
20
+#UseDelta    = 0.7
21
+Architecture = armv7h
22
+
23
+# Pacman won't upgrade packages listed in IgnorePkg and members of IgnoreGroup
24
+#IgnorePkg   =
25
+#IgnoreGroup =
26
+
27
+#NoUpgrade   =
28
+#NoExtract   =
29
+
30
+# Misc options
31
+#UseSyslog
32
+#Color
33
+#TotalDownload
34
+# We cannot check disk space from within a chroot environment
35
+#CheckSpace
36
+#VerbosePkgLists
37
+
38
+# By default, pacman accepts packages signed by keys that its local keyring
39
+# trusts (see pacman-key and its man page), as well as unsigned packages.
40
+SigLevel    = Required DatabaseOptional
41
+LocalFileSigLevel = Optional
42
+#RemoteFileSigLevel = Required
43
+
44
+# NOTE: You must run `pacman-key --init` before first using pacman; the local
45
+# keyring can then be populated with the keys of all official Arch Linux
46
+# packagers with `pacman-key --populate archlinux`.
47
+
48
+#
49
+# REPOSITORIES
50
+#   - can be defined here or included from another file
51
+#   - pacman will search repositories in the order defined here
52
+#   - local/custom mirrors can be added here or in separate files
53
+#   - repositories listed first will take precedence when packages
54
+#     have identical names, regardless of version number
55
+#   - URLs will have $repo replaced by the name of the current repo
56
+#   - URLs will have $arch replaced by the name of the architecture
57
+#
58
+# Repository entries are of the format:
59
+#       [repo-name]
60
+#       Server = ServerName
61
+#       Include = IncludePath
62
+#
63
+# The header [repo-name] is crucial - it must be present and
64
+# uncommented to enable the repo.
65
+#
66
+
67
+# The testing repositories are disabled by default. To enable, uncomment the
68
+# repo name header and Include lines. You can add preferred servers immediately
69
+# after the header, and they will be used before the default mirrors.
70
+
71
+#[testing]
72
+#Include = /etc/pacman.d/mirrorlist
73
+
74
+[core]
75
+Include = /etc/pacman.d/mirrorlist
76
+
77
+[extra]
78
+Include = /etc/pacman.d/mirrorlist
79
+
80
+#[community-testing]
81
+#Include = /etc/pacman.d/mirrorlist
82
+
83
+[community]
84
+Include = /etc/pacman.d/mirrorlist
85
+
86
+[alarm]
87
+Include = /etc/pacman.d/mirrorlist
88
+
89
+[aur]
90
+Include = /etc/pacman.d/mirrorlist
91
+
92
+# An example of a custom package repository.  See the pacman manpage for
93
+# tips on creating your own repositories.
94
+#[custom]
95
+#SigLevel = Optional TrustAll
96
+#Server = file:///home/custompkgs
97
+