diff --git a/auto/clean b/auto/clean index 77cb682..3f78b8e 100755 --- a/auto/clean +++ b/auto/clean @@ -3,13 +3,13 @@ lb clean noauto "$@" rm -fv config/binary \ - config/bootstrap \ - config/chroot \ - config/common \ - config/source \ - config/package-lists/live.list.chroot + config/bootstrap \ + config/chroot \ + config/common \ + config/source \ + config/package-lists/live.list.chroot if [ -e config/hooks/ ]; then - find config/hooks/ -type l \ - | xargs --no-run-if-empty rm -f + find config/hooks/ -type l \ + | xargs --no-run-if-empty rm -f fi diff --git a/auto/config b/auto/config index ce9c71b..0d62a06 100755 --- a/auto/config +++ b/auto/config @@ -6,9 +6,9 @@ set -o pipefail # Bashism # You can put a local mirror here if you want (or you can set # it in .mirror) if [ -e .mirror ]; then - kali_mirror=$(cat .mirror) + kali_mirror=$(cat .mirror) else - kali_mirror=http://kali.download/kali + kali_mirror=http://kali.download/kali fi ### DO NOT EDIT THE REST OF THIS FILE ### @@ -21,93 +21,93 @@ arch=$(dpkg --print-architecture) dist="kali-rolling" lb_opts="" while [ $# -gt 0 ]; do - arg="$1" - case "$arg" in - -a|--arch|--architecture|--architectures) - arch="$2" - temp="$temp "'"'"$arg"'"' - temp="$temp "'"'"$2"'"' - shift - ;; - --distribution) - dist="$2" - shift - ;; - --variant) - variant="$2" - shift - ;; - -p|--proposed-updates) - enable_pu="1" - ;; - --) - # Skip the separator, it was added so that "lb config" - # doesn't barf on our own options, but now we are - # filtering them away assuming that the remaining ones - # are intended for lb config ! - ;; - *) - temp="$temp "'"'"$arg"'"' - ;; - esac - shift + arg="$1" + case "$arg" in + -a|--arch|--architecture|--architectures) + arch="$2" + temp="$temp "'"'"$arg"'"' + temp="$temp "'"'"$2"'"' + shift + ;; + --distribution) + dist="$2" + shift + ;; + --variant) + variant="$2" + shift + ;; + -p|--proposed-updates) + enable_pu="1" + ;; + --) + # Skip the separator, it was added so that "lb config" + # doesn't barf on our own options, but now we are + # filtering them away assuming that the remaining ones + # are intended for lb config ! + ;; + *) + temp="$temp "'"'"$arg"'"' + ;; + esac + shift done eval set -- "$temp" # Resolve release name dist=$(wget -q -O- $kali_mirror/dists/$dist/Release | awk '/^Codename:/ {print $2}') if [ -z "$dist" ]; then - echo "ERROR: Build release could not be resolved" - exit 1 + echo "ERROR: Build release could not be resolved" + exit 1 fi # live-build doesn't work if --parent-debian-distribution is unknown of # debian-cd => we have to put a symlink so that it deals with kali like sid if [ ! -e ${LIVE_BUILD:-/usr/share/live/build}/data/debian-cd/$dist ]; then - if [ -w ${LIVE_BUILD:-/usr/share/live/build}/data/debian-cd ]; then - ln -sf sid ${LIVE_BUILD:-/usr/share/live/build}/data/debian-cd/$dist - else - echo "ERROR: Run this first:" - echo "ln -sf sid ${LIVE_BUILD:-/usr/share/live/build}/data/debian-cd/$dist" - exit 1 - fi + if [ -w ${LIVE_BUILD:-/usr/share/live/build}/data/debian-cd ]; then + ln -sf sid ${LIVE_BUILD:-/usr/share/live/build}/data/debian-cd/$dist + else + echo "ERROR: Run this first:" + echo "ln -sf sid ${LIVE_BUILD:-/usr/share/live/build}/data/debian-cd/$dist" + exit 1 + fi fi # Define options that vary across architectures case "$arch" in - amd64) - lb_opts="$lb_opts --debian-installer live" - ;; - i386) - lb_opts="$lb_opts --debian-installer live --linux-flavours 686-pae" - ;; - arm64) - lb_opts="$lb_opts --bootloaders grub-efi --uefi-secure-boot disable" - ;; - armel|armhf) - lb_opts="$lb_opts --binary-images hdd --binary-filesystem ext4 --chroot-filesystem none" - ;; - *) - echo "WARNING: configuration not tested on arch $arch" >&2 - ;; + amd64) + lb_opts="$lb_opts --debian-installer live" + ;; + i386) + lb_opts="$lb_opts --debian-installer live --linux-flavours 686-pae" + ;; + arm64) + lb_opts="$lb_opts --bootloaders grub-efi --uefi-secure-boot disable" + ;; + armel|armhf) + lb_opts="$lb_opts --binary-images hdd --binary-filesystem ext4 --chroot-filesystem none" + ;; + *) + echo "WARNING: configuration not tested on arch $arch" >&2 + ;; esac # Define options that vary across distributions case "$dist" in - kali-last-snapshot) - # We don't want kali-last-snapshot to end up in the image, it - # should be replaced with kali-rolling - lb_opts="$lb_opts --distribution-binary kali-rolling" - lb_opts="$lb_opts --debootstrap-script /usr/share/debootstrap/scripts/kali-rolling" - ;; + kali-last-snapshot) + # We don't want kali-last-snapshot to end up in the image, it + # should be replaced with kali-rolling + lb_opts="$lb_opts --distribution-binary kali-rolling" + lb_opts="$lb_opts --debootstrap-script /usr/share/debootstrap/scripts/kali-rolling" + ;; esac # Setup configuration files from variant and options # Drop all files that a former run might have put into place for file in $(cd kali-config && find ./common ./variant-* -type f); do - file=${file#./*/} - rm -fv config/$file + file=${file#./*/} + rm -fv config/$file done rm -fv config/archives/kali-proposed-updates.list.* @@ -116,37 +116,37 @@ cp -rT kali-config/common config [ ! -d kali-config/variant-$variant ] || cp -rTL kali-config/variant-$variant config if [ -n "$enable_pu" ]; then - mkdir -p config/archives - echo "deb $kali_mirror $dist-proposed-updates main contrib non-free non-free-firmware" \ - > config/archives/kali-proposed-updates.list.chroot - echo "deb $public_kali_mirror $dist-proposed-updates main contrib non-free non-free-firmware" \ - > config/archives/kali-proposed-updates.list.binary + mkdir -p config/archives + echo "deb $kali_mirror $dist-proposed-updates main contrib non-free non-free-firmware" \ + > config/archives/kali-proposed-updates.list.chroot + echo "deb $public_kali_mirror $dist-proposed-updates main contrib non-free non-free-firmware" \ + > config/archives/kali-proposed-updates.list.binary fi lb config noauto \ - --apt-indices=false \ - --distribution "$dist" \ - --debian-installer-distribution "$dist" \ - --archive-areas "main contrib non-free non-free-firmware" \ - --debootstrap-options "--keyring=/usr/share/keyrings/kali-archive-keyring.gpg" \ - --keyring-packages kali-archive-keyring \ - --updates false \ - --backports false \ - --source false \ - --firmware-binary true \ - --firmware-chroot true \ - --mirror-bootstrap "$kali_mirror" \ - --mirror-debian-installer "$kali_mirror" \ - --mirror-binary "$public_kali_mirror" \ - --iso-application "Kali Linux" \ - --iso-publisher "Kali" \ - --iso-volume "Kali Live" \ - --linux-packages linux-image \ - --memtest memtest86+ \ - --bootappend-live "boot=live components quiet splash noeject" \ - --bootappend-live-failsafe "boot=live components noeject memtest noapic noapm nodma nomce nolapic nomodeset nosmp nosplash vga=normal" \ - --bootappend-install "net.ifnames=0" \ - --security false \ - --win32-loader false \ - $lb_opts \ - "$@" + --apt-indices=false \ + --distribution "$dist" \ + --debian-installer-distribution "$dist" \ + --archive-areas "main contrib non-free non-free-firmware" \ + --debootstrap-options "--keyring=/usr/share/keyrings/kali-archive-keyring.gpg" \ + --keyring-packages kali-archive-keyring \ + --updates false \ + --backports false \ + --source false \ + --firmware-binary true \ + --firmware-chroot true \ + --mirror-bootstrap "$kali_mirror" \ + --mirror-debian-installer "$kali_mirror" \ + --mirror-binary "$public_kali_mirror" \ + --iso-application "Kali Linux" \ + --iso-publisher "Kali" \ + --iso-volume "Kali Live" \ + --linux-packages linux-image \ + --memtest memtest86+ \ + --bootappend-live "boot=live components quiet splash noeject" \ + --bootappend-live-failsafe "boot=live components noeject memtest noapic noapm nodma nomce nolapic nomodeset nosmp nosplash vga=normal" \ + --bootappend-install "net.ifnames=0" \ + --security false \ + --win32-loader false \ + $lb_opts \ + "$@" diff --git a/build.sh b/build.sh index ed74220..d9ec793 100755 --- a/build.sh +++ b/build.sh @@ -17,111 +17,111 @@ DEBUG="" HOST_ARCH=$(dpkg --print-architecture) image_name() { - case "$KALI_ARCH" in - i386|amd64|arm64) - echo "live-image-$KALI_ARCH.hybrid.iso" - ;; - armel|armhf) - echo "live-image-$KALI_ARCH.img" - ;; - esac + case "$KALI_ARCH" in + i386|amd64|arm64) + echo "live-image-$KALI_ARCH.hybrid.iso" + ;; + armel|armhf) + echo "live-image-$KALI_ARCH.img" + ;; + esac } target_image_name() { - local arch=$1 - - IMAGE_NAME="$(image_name $arch)" - IMAGE_EXT="${IMAGE_NAME##*.}" - if [ "$IMAGE_EXT" = "$IMAGE_NAME" ]; then - IMAGE_EXT="img" - fi - if [ "$KALI_VARIANT" = "default" ]; then - echo "${TARGET_SUBDIR:+$TARGET_SUBDIR/}kali-linux-$KALI_VERSION-live-$KALI_ARCH.$IMAGE_EXT" - else - echo "${TARGET_SUBDIR:+$TARGET_SUBDIR/}kali-linux-$KALI_VERSION-live-$KALI_VARIANT-$KALI_ARCH.$IMAGE_EXT" - fi + local arch=$1 + + IMAGE_NAME="$(image_name $arch)" + IMAGE_EXT="${IMAGE_NAME##*.}" + if [ "$IMAGE_EXT" = "$IMAGE_NAME" ]; then + IMAGE_EXT="img" + fi + if [ "$KALI_VARIANT" = "default" ]; then + echo "${TARGET_SUBDIR:+$TARGET_SUBDIR/}kali-linux-$KALI_VERSION-live-$KALI_ARCH.$IMAGE_EXT" + else + echo "${TARGET_SUBDIR:+$TARGET_SUBDIR/}kali-linux-$KALI_VERSION-live-$KALI_VARIANT-$KALI_ARCH.$IMAGE_EXT" + fi } target_build_log() { - TARGET_IMAGE_NAME=$(target_image_name $1) - echo ${TARGET_IMAGE_NAME%.*}.log + TARGET_IMAGE_NAME=$(target_image_name $1) + echo ${TARGET_IMAGE_NAME%.*}.log } default_version() { - case "$1" in - kali-*) - echo "${1#kali-}" - ;; - *) - echo "$1" - ;; - esac + case "$1" in + kali-*) + echo "${1#kali-}" + ;; + *) + echo "$1" + ;; + esac } failure() { - echo "Build of $KALI_DIST/$KALI_VARIANT/$KALI_ARCH live image failed (see build.log for details)" >&2 - echo "Log: $BUILD_LOG" >&2 - exit 2 + echo "Build of $KALI_DIST/$KALI_VARIANT/$KALI_ARCH live image failed (see build.log for details)" >&2 + echo "Log: $BUILD_LOG" >&2 + exit 2 } run_and_log() { - if [ -n "$VERBOSE" ] || [ -n "$DEBUG" ]; then - printf "RUNNING:" >&2 - for _ in "$@"; do - [[ $_ =~ [[:space:]] ]] && printf " '%s'" "$_" || printf " %s" "$_" - done >&2 - printf "\n" >&2 - "$@" 2>&1 | tee -a "$BUILD_LOG" - else - "$@" >>"$BUILD_LOG" 2>&1 - fi - return $? + if [ -n "$VERBOSE" ] || [ -n "$DEBUG" ]; then + printf "RUNNING:" >&2 + for _ in "$@"; do + [[ $_ =~ [[:space:]] ]] && printf " '%s'" "$_" || printf " %s" "$_" + done >&2 + printf "\n" >&2 + "$@" 2>&1 | tee -a "$BUILD_LOG" + else + "$@" >>"$BUILD_LOG" 2>&1 + fi + return $? } debug() { - if [ -n "$DEBUG" ]; then - echo "DEBUG: $*" >&2 - fi + if [ -n "$DEBUG" ]; then + echo "DEBUG: $*" >&2 + fi } clean() { - debug "Cleaning" - - run_and_log $SUDO lb clean --purge - #run_and_log $SUDO umount -l $(pwd)/chroot/proc - #run_and_log $SUDO umount -l $(pwd)/chroot/dev/pts - #run_and_log $SUDO umount -l $(pwd)/chroot/sys - #run_and_log $SUDO rm -rf $(pwd)/chroot - #run_and_log $SUDO rm -rf $(pwd)/binary + debug "Cleaning" + + run_and_log $SUDO lb clean --purge + #run_and_log $SUDO umount -l $(pwd)/chroot/proc + #run_and_log $SUDO umount -l $(pwd)/chroot/dev/pts + #run_and_log $SUDO umount -l $(pwd)/chroot/sys + #run_and_log $SUDO rm -rf $(pwd)/chroot + #run_and_log $SUDO rm -rf $(pwd)/binary } print_help() { - echo "Usage: $0 [