summaryrefslogtreecommitdiff
path: root/examples/build_gold_image/build_archlinux.sh
blob: af0f485b535716d640d9ec7537902c065777543e (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
#!/bin/sh

# ArchLinux

export PATH=/bin:/sbin:/usr/bin:/usr/sbin:${PATH}

ARCH=$1

if test "x$ARCH" = "x"; then
	echo "One argument expected (architecture)" 1>&2
	exit 1
fi

case $ARCH in
	i686)
		PACKAGE_ARCH=i386
		ARCH_SWITCH=linux32
		;;
		
	x86_64)
		PACKAGE_ARCH=x86_64
		ARCH_SWITCH=
		;;
		
	*)
		echo "Unsupported architecture '$ARCH'" 1>&2
		exit 1
esac

CHROOT_DIR=archlinux-${ARCH}

umount ${CHROOT_DIR}-mnt/proc
umount ${CHROOT_DIR}-mnt

rm -rf $CHROOT_DIR

mkdir $CHROOT_DIR

# pacstrap only installs into a mountpoint, so emulate one
mkdir ${CHROOT_DIR}-mnt
mount --bind ${CHROOT_DIR} ${CHROOT_DIR}-mnt

${ARCH_SWITCH} pacstrap ${CHROOT_DIR}-mnt filesystem bash coreutils pacman

mount -t proc proc ${CHROOT_DIR}/proc

${ARCH_SWITCH} arch-chroot ${CHROOT_DIR} pacman --noconfirm -Syyu

${ARCH_SWITCH} arch-chroot ${CHROOT_DIR} pacman -S --noconfirm make gcc cmake tar openssh git

umount ${CHROOT_DIR}-mnt/proc
umount ${CHROOT_DIR}-mnt
rmdir ${CHROOT_DIR}-mnt