This repository has been archived by the owner on Jan 1, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
update.sh
executable file
·51 lines (38 loc) · 1.54 KB
/
update.sh
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
#!/bin/bash
set -e
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
stage3="$(wget -qO- 'http://distfiles.gentoo.org/releases/amd64/autobuilds/latest-stage3-amd64.txt' | tail -n1)"
if [ -z "$stage3" ]; then
echo >&2 'wtf failure'
exit 1
fi
url="http://distfiles.gentoo.org/releases/amd64/autobuilds/$stage3"
name="$(basename "$stage3")"
( set -x; wget -N "$url" )
base="${name%%.*}"
image="gentoo-temp:$base"
container="gentoo-temp-$base"
# bzcat thanks to https://code.google.com/p/go/issues/detail?id=7279
( set -x; bzcat -p "$name" | docker import - "$image" )
docker rm -f "$container" > /dev/null 2>&1 || true
( set -x; docker run -t -v /usr/portage:/usr/portage:ro --name "$container" "$image" bash -exc $'
export MAKEOPTS="-j$(nproc)"
pythonTarget="$(emerge --info | sed -n \'s/.*PYTHON_TARGETS="\\([^"]*\\)".*/\\1/p\')"
pythonTarget="${pythonTarget##* }"
echo \'PYTHON_TARGETS="\'$pythonTarget\'"\' >> /etc/portage/make.conf
echo \'PYTHON_SINGLE_TARGET="\'$pythonTarget\'"\' >> /etc/portage/make.conf
emerge --newuse --deep --with-bdeps=y @system @world
emerge -C editor ssh man man-pages openrc e2fsprogs texinfo service-manager
emerge --depclean
' )
xz="$base.tar.xz"
( set -x; docker export "$container" | xz -9 > "$xz" )
docker rm "$container"
docker rmi "$image"
echo 'FROM scratch' > Dockerfile
echo "ADD $xz /" >> Dockerfile
echo 'CMD ["/bin/bash"]' >> Dockerfile
user="$(docker info | awk '/^Username:/ { print $2 }')"
[ -z "$user" ] || user="$user/"
( set -x; docker build -t "${user}gentoo-stage3" . )
( set -x; git add Dockerfile "$xz" )