forked from thunder9861/kali
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_all.sh
executable file
·80 lines (68 loc) · 2.04 KB
/
build_all.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/sh
set -e
KALI_VERSION="${VERSION:-daily}"
TARGET_DIR=$(dirname $0)/images/kali-$KALI_VERSION
HOST_ARCH="$(dpkg --print-architecture)"
case "$HOST_ARCH" in
i386|amd64)
KALI_ARCHES="amd64 i386"
IMAGE_NAME="binary.hybrid.iso"
;;
armel|armhf)
KALI_ARCHES="$HOST_ARCH"
IMAGE_NAME="binary.img"
;;
*)
echo "ERROR: $HOST_ARCH build is not supported"
exit 1
;;
esac
# Parsing command line options
temp=$(getopt -o sp -l single,proposed-updates -- "$@")
eval set -- "$temp"
while true; do
case "$1" in
-s|--single) OPT_single="1"; shift 1; ;;
-p|--proposed-updates) OPT_pu="1"; shift 1; ;;
--) shift; break; ;;
*) echo "ERROR: Invalid command-line option: $1" >&2; exit 1; ;;
esac
done
if [ -n "$OPT_single" ]; then
echo "Building a single arch ($HOST_ARCH)..."
KALI_ARCHES="$HOST_ARCH"
fi
if [ -n "$OPT_pu" ]; then
echo "Integrating proposed-updates in the image"
KALI_CONFIG_OPTS="-- --proposed-updates"
fi
# Set sane PATH (cron seems to lack /sbin/ dirs)
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
# Either we use a git checkout of live-build
# export LIVE_BUILD=/srv/cdimage.kali.org/live/live-build
# Or we ensure we have proper version installed
ver_live_build=$(dpkg-query -f '${Version}' -W live-build)
if dpkg --compare-versions "$ver_live_build" lt 3.0~b6; then
echo "You need live-build (>= 3.0~b6), you have $ver_live_build" >&2
exit 1
fi
cd $(dirname $0)
mkdir -p $TARGET_DIR
for KALI_ARCH in $KALI_ARCHES; do
lb clean --purge >prepare.log 2>&1
lb config -a $KALI_ARCH $KALI_CONFIG_OPTS >>prepare.log 2>&1
lb build >/dev/null
if [ $? -ne 0 ] || [ ! -e $IMAGE_NAME ]; then
echo "Build of $KALI_ARCH live image failed" >&2
echo "Last 50 lines of the log:" >&2
tail -n 50 binary.log >&2
exit 1
fi
[ -d images ] || mkdir images
IMAGE_EXT="${IMAGE_EXT:-${IMAGE_NAME##*.}}"
mv $IMAGE_NAME $TARGET_DIR/kali-$KALI_VERSION-$KALI_ARCH.$IMAGE_EXT
mv binary.log $TARGET_DIR/kali-$KALI_VERSION-$KALI_ARCH.log
done
if [ -x ../bin/update-checksums ]; then
../bin/update-checksums $TARGET_DIR
fi