blob: 1c4d08430bd7c2812dc9f91c3324954745392901 (
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
78
79
80
81
82
83
84
85
|
#!/bin/sh -e
ARCH=$(apk --print-arch)
FLAVOR="vanilla"
FEATURE="base squashfs network zfs"
PACKAGE="spl-vanilla zfs-vanilla"
OUTDIR="$PWD/out"
RELEASE="edge"
MIRROR="http://dl-cdn.alpinelinux.org/alpine"
usage() {
local ws=$(printf %${#0}s)
cat <<-EOF
$0 [--arch ARCH] [--flavor FLAVOR] [--feature FEATURE]
$ws [--outdir OUTDIR] [--release RELEASE] [--repository REPO]
$0 --help
options:
--arch Specify which architecture images to build
--flavor Specify which kernel flavor images to build
--feature Specify which initramfs features to include
--package Additional module or firmware package
--outdir Specify directory for the created images
--release Build images for specified release from main repository
--repository Package repository to use (overides --release)
--extra-repository Add repository to search packages from (overides --release)
EOF
}
# parse parameters
while [ $# -gt 0 ]; do
opt="$1"
shift
case "$opt" in
--arch) ARCH="$1"; shift ;;
--flavor) FLAVOR="$1"; shift ;;
--feature) FEATURE="$1"; shift ;;
--outdir) OUTDIR="$1"; shift ;;
--release) RELEASE="$1"; shift ;;
--repository) REPO="$1"; shift ;;
--extra-repository) EXTRAREPO="$EXTRAREPO $1"; shift ;;
--) break ;;
-*) usage; exit 1;;
esac
done
rm -rf "$OUTDIR"
mkdir -p "$OUTDIR"
REPOFILE=$(mktemp)
DEFAULT_REPO="$MIRROR/$RELEASE/main"
echo "${REPO:-$DEFAULT_REPO}" >> "$REPOFILE"
for repo in $EXTRAREPO; do
echo "$repo" >> "$REPOFILE"
done
echo "Creating netboot image: $RELEASE/$ARCH/$FLAVOR"
update-kernel \
--arch "$ARCH" \
--flavor "$FLAVOR" \
--feature "$FEATURE" \
--package "$PACKAGE" \
--repositories-file "$REPOFILE" \
"$OUTDIR"
# older vanilla kernels do not have the flavor appended.
for file in vmlinuz config System.map; do
if [ -f "$OUTDIR"/$file ]; then
mv "$OUTDIR"/$file "$OUTDIR"/$file-"$FLAVOR"
fi
done
# arm64 kernel is not a std bzImage but intead gzip compressed image
# iPXE efi mode (default for aarch64) does not support compressed kernel image
if [ "$ARCH" = "aarch64" ] && gunzip -t "$OUTDIR"/vmlinuz-"$FLAVOR" 2> /dev/null; then
TMP_KERNEL=$(mktemp)
zcat "$OUTDIR"/vmlinuz-"$FLAVOR" > $TMP_KERNEL && mv $TMP_KERNEL \
"$OUTDIR"/vmlinuz-"$FLAVOR"
chmod 644 "$OUTDIR"/vmlinuz-"$FLAVOR"
fi
rm -f "$REPOFILE"
|