-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmkrootfs
executable file
·39 lines (33 loc) · 1.01 KB
/
mkrootfs
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
#!/bin/sh
set -eu
exec 3>&1 >&2 #save stdout for later, diagnostics to stderr
# set defaults
dest=mnt
mirror=http://dl-cdn.alpinelinux.org/alpine
rel=edge
pkg=alpine-baselayout,alpine-keys,apk-tools,musl-utils
while getopts hd:m:r:p:t:ES opt; do
case $opt in
d) dest=$OPTARG ;;
m) mirror=$OPTARG ;;
r) rel=$OPTARG ;;
p) pkg=$OPTARG ;;
t) tzdata=$OPTARG ;;
S) noout=1 ;;
*) exec echo "$0 [-d:] [-m:] [-r:] [-p:] [-t:] [-S]" ;;
esac
done
# ensure the destination exists
mkdir -p "$dest/etc/apk"
cd "$dest"
# set up the repositories file
{ echo "$mirror/$rel/main"
wget -qO- "$mirror/$rel/community" >&4 2>&4 && echo "$mirror/$rel/community"
[ "$rel" = edge ] || echo @edge "$mirror/edge/main"
echo @testing "$mirror/edge/testing"
} > etc/apk/repositories 4>/dev/null
# fetch the container contents
(IFS=,; apk -p . --no-cache --keys-dir /etc/apk/keys add --initdb $pkg)
[ ${tzdata+1} ] && cp "/usr/share/zoneinfo/$tzdata" etc/localtime
# output if requested
[ ${noout+1} ] || tar c * >&3