-
Notifications
You must be signed in to change notification settings - Fork 1
/
create-rootfs.sh
executable file
·58 lines (50 loc) · 1.5 KB
/
create-rootfs.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
52
53
54
55
56
57
58
#!/bin/bash
set -e
# check for root privileges
if [ "$UID" != "0" ]; then
echo "You need root privileges to run this"
exit 1
fi
# argument check
if [ -z $1 ]; then
echo "You need to provide the arch as an argument." >&2
echo "Example: $0 x86_64" >&2
exit 1
fi
if [[ $1 != "x86_64" ]] && [[ $1 != "i486" ]]; then
echo "arch can only be i486 or x86_64"
exit 1
fi
ARCH=$1
ROOTFS=rootfs-$ARCH
VERSIONS=docker-$ARCH/PKG_VERSIONS
VERSIONS_TMP=`mktemp`
rm -rf $ROOTFS pkgstore
mkdir -p $ROOTFS pkgstore docker-$ARCH
slapt-get --config slapt-getrc.$ARCH --update
for pkg in `cat PKG_NAMES | cut -d'#' -f 1`; do
URI=`slapt-get --config slapt-getrc.$ARCH --install --reinstall --no-dep --print-uris $pkg | grep "^http://"`
PKGFILE=`basename $URI`
echo "Downloading $PKGFILE..."
[ ! -f pkgstore/$PKGFILE ] && wget -q -P pkgstore $URI
echo "Installing $PKGFILE..."
spkg -qq -i --root $ROOTFS pkgstore/$PKGFILE
echo $PKGFILE >> $VERSIONS_TMP
done
cat > $VERSIONS << EOF
# This package lists the full package names, including version number
# and build number of all packages included in the mini-root fs.
EOF
cat $VERSIONS_TMP | sort | uniq >> $VERSIONS
rm -f $VERSIONS_TMP
# sed default lang to en_US
sed -i "s/^ *\(export LANG=\).*$/\1en_US.utf8/" $ROOTFS/etc/profile.d/lang.sh
# add a nameserver
echo "nameserver 1.1.1.1" > $ROOTFS/etc/resolv.conf
# default symlink for elvis -> vi
( cd $ROOTFS/usr/bin; ln -s elvis vi )
# create the tarball
cd rootfs-$ARCH
tar cv ./ | xz -9 > ../docker-$ARCH/rootfs-$ARCH.tar.xz
cd ..
set +e