summaryrefslogtreecommitdiff
path: root/examples/build_gold_image/build_fedora24.sh
blob: fe74ce183f9cb40f6a5775119f63515810207faf (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
72
73
74
75
76
77
#!/bin/sh

# Fedora 24

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=fed24-${ARCH}

rm -rf $CHROOT_DIR

mkdir $CHROOT_DIR

mkdir -p $CHROOT_DIR/var/lib/rpm

rpm -v --rebuilddb --root=`pwd`/$CHROOT_DIR

wget http://mirror.switch.ch/ftp/mirror/fedora/linux/releases/24/Server/${PACKAGE_ARCH}/os/Packages/f/fedora-release-24-1.noarch.rpm
wget http://mirror.switch.ch/ftp/mirror/fedora/linux/releases/24/Server/${PACKAGE_ARCH}/os/Packages/f/fedora-repos-24-1.noarch.rpm

rpm -v -i --root=`pwd`/$CHROOT_DIR --nodeps fedora-release-24-1.noarch.rpm fedora-repos-24-1.noarch.rpm

rm -f fedora-release-24-1.noarch.rpm
rm -f fedora-repos-24-1.noarch.rpm

wget -O RPM_PGP-KEY-Fedora-24 https://getfedora.org/static/81B46521.txt

rpm -v --root=`pwd`/$CHROOT_DIR --import RPM_PGP-KEY-Fedora-24

rm RPM_PGP-KEY-Fedora-24

${ARCH_SWITCH} yum --installroot=`pwd`/$CHROOT_DIR install -y yum
${ARCH_SWITCH} yum --installroot=`pwd`/$CHROOT_DIR install -y dnf

${ARCH_SWITCH} yum --installroot=`pwd`/$CHROOT_DIR install -y coreutils procps net-tools wget

# rebuild the RPM database with the rpm inside the chroot
${ARCH_SWITCH} chroot $CHROOT_DIR /bin/rpm -v --rebuilddb

cp /etc/resolv.conf $CHROOT_DIR/etc/

${ARCH_SWITCH} chroot ${CHROOT_DIR} dnf -y update

cp $CHROOT_DIR/etc/skel/.bashrc $CHROOT_DIR/root
cp $CHROOT_DIR/etc/skel/.bash_profile $CHROOT_DIR/root
cp $CHROOT_DIR/etc/skel/.bash_logout $CHROOT_DIR/root

cat >> $CHROOT_DIR/root/.bash_profile <<EOF
export PATH=\$PATH:/usr/sbin:/usr/bin:/sbin:/bin
export PS1='[fedora24:\u@\h \W]\$ '
EOF

# development stuff

${ARCH_SWITCH} chroot ${CHROOT_DIR} dnf install -y make gcc gcc-c++ rpm-build tar ccache distcc