From e4fa270582d37ef32f30792b2c8402866db4f02e Mon Sep 17 00:00:00 2001 From: Ben Wilson Date: Sun, 19 Sep 2021 10:11:39 +0100 Subject: [PATCH] basedir -> base_dir \ imagename -> image_name --- banana-pi.sh | 14 +++--- banana-pro.sh | 12 ++--- beaglebone-black.sh | 52 ++++++++++---------- builder.txt.example | 2 +- chromebook-exynos.sh | 56 ++++++++++----------- chromebook-nyan.sh | 66 ++++++++++++------------- chromebook-veyron.sh | 98 ++++++++++++++++++------------------- common.d/check.sh | 6 +-- common.d/compress_img.sh | 14 +++--- common.d/functions.sh | 10 ++-- common.d/rpi_userland.sh | 6 +-- common.d/variables.sh | 6 +-- cubieboard2.sh | 60 +++++++++++------------ cubietruck.sh | 56 ++++++++++----------- cubox-i4pro.sh | 48 +++++++++--------- cubox.sh | 50 +++++++++---------- gateworks-newport.sh | 32 ++++++------ gateworks-ventana.sh | 14 +++--- mini-x.sh | 40 +++++++-------- nanopc-t.sh | 48 +++++++++--------- nanopi-neo-plus2-minimal.sh | 14 +++--- nanopi-neo-plus2.sh | 14 +++--- nanopi2.sh | 70 +++++++++++++------------- odroid-c.sh | 64 ++++++++++++------------ odroid-c2.sh | 24 ++++----- odroid-u2.sh | 64 ++++++++++++------------ odroid-xu3.sh | 26 +++++----- pinebook-pro.sh | 14 +++--- pinebook.sh | 12 ++--- riotboard.sh | 52 ++++++++++---------- rpi-64bit-minimal.sh | 20 ++++---- rpi-64bit.sh | 20 ++++---- rpi.sh | 45 ++++++++++------- rpi0w-minimal.sh | 20 ++++---- rpi0w-p4wnp1-aloa.sh | 72 +++++++++++++-------------- rpi0w-pitail.sh | 48 +++++++++--------- rpi0w.sh | 20 ++++---- rpi1.sh | 20 ++++---- trimslice.sh | 46 ++++++++--------- usb-armory-mki.sh | 42 ++++++++-------- usb-armory-mkii.sh | 12 ++--- utilite-pro.sh | 56 ++++++++++----------- 42 files changed, 738 insertions(+), 727 deletions(-) diff --git a/banana-pi.sh b/banana-pi.sh index 54f62b1..0665b02 100755 --- a/banana-pi.sh +++ b/banana-pi.sh @@ -162,7 +162,7 @@ echo "T1:12345:respawn:/sbin/agetty -L ttyS0 115200 vt100" >> ${work_dir}/etc/in echo "sunxi_emac" >> ${work_dir}/etc/modules mkdir -p ${work_dir}/etc/X11/xorg.conf.d/ -cp "${basedir}"/../bsp/xorg/20-fbdev.conf ${work_dir}/etc/X11/xorg.conf.d/ +cp "${base_dir}"/../bsp/xorg/20-fbdev.conf ${work_dir}/etc/X11/xorg.conf.d/ # Build system will insert it's root filesystem into the extlinux.conf file so # we sed it out, this only affects build time, not upgrading the kernel on the @@ -171,11 +171,11 @@ sed -i -e 's/append.*/append console=ttyS0,115200 console=tty1 root=\/dev\/mmcbl # Create the disk partitions log "Create the disk partitions" green -parted -s ${current_dir}/${imagename}.img mklabel msdos -parted -s -a minimal ${current_dir}/${imagename}.img mkpart primary $fstype 4MiB 100% +parted -s ${current_dir}/${image_name}.img mklabel msdos +parted -s -a minimal ${current_dir}/${image_name}.img mkpart primary $fstype 4MiB 100% # Set the partition variables -loopdevice=$(losetup -f --show ${current_dir}/${imagename}.img) +loopdevice=$(losetup -f --show ${current_dir}/${image_name}.img) device=$(kpartx -va ${loopdevice} | sed 's/.*\(loop[0-9]\+\)p.*/\1/g' | head -1) sleep 5 device="/dev/mapper/${device}" @@ -190,8 +190,8 @@ mkfs -O "$features" -t "$fstype" -L ROOTFS "${rootp}" # Create the dirs for the partitions and mount them log "Create the dirs for the partitions and mount them" green -mkdir -p ${basedir}/root -mount ${rootp} ${basedir}/root +mkdir -p ${base_dir}/root +mount ${rootp} ${base_dir}/root # Create an fstab so that we don't mount / read-only log "/etc/fstab" green @@ -199,7 +199,7 @@ UUID=$(blkid -s UUID -o value ${rootp}) echo "UUID=$UUID / $fstype errors=remount-ro 0 1" >> ${work_dir}/etc/fstab echo "Rsyncing rootfs to image file" -rsync -HPavz -q ${work_dir}/ ${basedir}/root/ +rsync -HPavz -q ${work_dir}/ ${base_dir}/root/ sync # Flush buffers and bytes - this is nicked from the Devuan arm-sdk. diff --git a/banana-pro.sh b/banana-pro.sh index 0304b16..1df0ab4 100755 --- a/banana-pro.sh +++ b/banana-pro.sh @@ -162,11 +162,11 @@ sed -i -e 's/append.*/append console=ttyS0,115200 console=tty1 root=\/dev\/mmcbl # Create the disk partitions log "Create the disk partitions" green -parted -s "${current_dir}"/"${imagename}".img mklabel msdos -parted -s -a minimal "${current_dir}"/"${imagename}".img mkpart primary "$fstype" 4MiB 100% +parted -s "${current_dir}"/"${image_name}".img mklabel msdos +parted -s -a minimal "${current_dir}"/"${image_name}".img mkpart primary "$fstype" 4MiB 100% # Set the partition variables -loopdevice=$(losetup -f --show ${current_dir}/${imagename}.img) +loopdevice=$(losetup -f --show ${current_dir}/${image_name}.img) device=$(kpartx -va ${loopdevice} | sed 's/.*\(loop[0-9]\+\)p.*/\1/g' | head -1) sleep 5s device="/dev/mapper/${device}" @@ -181,11 +181,11 @@ mkfs -O "$features" -t "$fstype" -L ROOTFS "${rootp}" # Create the dirs for the partitions and mount them log "Create the dirs for the partitions and mount them" green -mkdir -p "${basedir}"/root -mount ${rootp} "${basedir}"/root +mkdir -p "${base_dir}"/root +mount ${rootp} "${base_dir}"/root log "Rsyncing rootfs into image file" green -rsync -HPavz -q ${work_dir}/ ${basedir}/root/ +rsync -HPavz -q ${work_dir}/ ${base_dir}/root/ sync # Flush buffers and bytes - this is nicked from the Devuan arm-sdk. diff --git a/beaglebone-black.sh b/beaglebone-black.sh index 7237f04..1ef5b61 100755 --- a/beaglebone-black.sh +++ b/beaglebone-black.sh @@ -25,7 +25,7 @@ machine=$(tr -cd 'A-Za-z0-9' < /dev/urandom | head -c16 ; echo) # Custom hostname variable hostname=${2:-kali} # Custom image file name variable - MUST NOT include .img at the end -imagename=${3:-kali-linux-$1-beaglebone-black} +image_name=${3:-kali-linux-$1-beaglebone-black} # Suite to use, valid options are: # kali-rolling, kali-dev, kali-bleeding-edge, kali-dev-only, kali-experimental, kali-last-snapshot suite=${suite:-"kali-rolling"} @@ -67,20 +67,20 @@ fi # Current directory current_dir="$(pwd)" # Base directory -basedir=${current_dir}/bbb-"$1" +base_dir=${current_dir}/bbb-"$1" # Working directory -work_dir="${basedir}/kali-${architecture}" +work_dir="${base_dir}/kali-${architecture}" # Check directory build -if [ -e "${basedir}" ]; then - echo "${basedir} directory exists, will not continue" >&2 +if [ -e "${base_dir}" ]; then + echo "${base_dir} directory exists, will not continue" >&2 exit 1 elif [[ ${current_dir} =~ [[:space:]] ]]; then echo "The directory "\"${current_dir}"\" contains whitespace. Not supported." >&2 exit 1 else - echo "The basedir thinks it is: ${basedir}" - mkdir -p ${basedir} + echo "The base_dir thinks it is: ${base_dir}" + mkdir -p ${base_dir} fi components="main,contrib,non-free" @@ -363,7 +363,7 @@ make INSTALL_MOD_PATH=${work_dir} modules_install make INSTALL_MOD_PATH=${work_dir} firmware_install make mrproper make bb.org_defconfig -cd "${basedir}" +cd "${base_dir}" # Create uEnv.txt file cat << EOF > ${work_dir}/boot/uEnv.txt @@ -442,7 +442,7 @@ rm build rm source ln -s /usr/src/kernel build ln -s /usr/src/kernel source -cd "${basedir}" +cd "${base_dir}" # Unused currently, but this script is a part of using the usb as an ethernet # device @@ -463,15 +463,15 @@ raw_size=$(($((${free_space}*1024))+${root_extra}+$((${bootsize}*1024))+4096)) echo $raw_size # Create the disk and partition it -echo "Creating image file ${imagename}.img" -fallocate -l $(echo ${raw_size}Ki | numfmt --from=iec-i --to=si) ${current_dir}/${imagename}.img -echo "Partitioning ${imagename}.img" -parted -s ${current_dir}/${imagename}.img mklabel msdos -parted -s ${current_dir}/${imagename}.img mkpart primary fat32 1MiB ${bootsize}MiB -parted -s -a minimal ${current_dir}/${imagename}.img mkpart primary $fstype ${bootsize}MiB 100% +echo "Creating image file ${image_name}.img" +fallocate -l $(echo ${raw_size}Ki | numfmt --from=iec-i --to=si) ${current_dir}/${image_name}.img +echo "Partitioning ${image_name}.img" +parted -s ${current_dir}/${image_name}.img mklabel msdos +parted -s ${current_dir}/${image_name}.img mkpart primary fat32 1MiB ${bootsize}MiB +parted -s -a minimal ${current_dir}/${image_name}.img mkpart primary $fstype ${bootsize}MiB 100% # Set the partition variables -loopdevice=`losetup -f --show ${current_dir}/${imagename}.img` +loopdevice=`losetup -f --show ${current_dir}/${image_name}.img` device=`kpartx -va ${loopdevice} | sed 's/.*\(loop[0-9]\+\)p.*/\1/g' | head -1` sleep 5 device="/dev/mapper/${device}" @@ -488,10 +488,10 @@ fi mkfs $features -t $fstype -L ROOTFS ${rootp} # Create the dirs for the partitions and mount them -mkdir -p "${basedir}"/root -mount ${rootp} "${basedir}"/root -mkdir -p "${basedir}"/root/boot -mount ${bootp} "${basedir}"/root/boot +mkdir -p "${base_dir}"/root +mount ${rootp} "${base_dir}"/root +mkdir -p "${base_dir}"/root/boot +mount ${bootp} "${base_dir}"/root/boot # We do this down here to get rid of the build system's resolv.conf after running through the build echo "nameserver ${nameserver}" > "${work_dir}"/etc/resolv.conf @@ -501,7 +501,7 @@ UUID=$(blkid -s UUID -o value ${rootp}) echo "UUID=$UUID / $fstype errors=remount-ro 0 1" >> ${work_dir}/etc/fstab echo "Rsyncing rootfs into image file" -rsync -HPavz -q ${work_dir}/ ${basedir}/root/ +rsync -HPavz -q ${work_dir}/ ${base_dir}/root/ # Unmount partitions sync @@ -534,16 +534,16 @@ limit_cpu (){ if [ $compress = xz ]; then if [ $(arch) == 'x86_64' ]; then - echo "Compressing ${imagename}.img" + echo "Compressing ${image_name}.img" [ $(nproc) \< 3 ] || cpu_cores=3 # cpu_cores = Number of cores to use - limit_cpu pixz -p ${cpu_cores:-2} ${current_dir}/${imagename}.img # -p Nº cpu cores use - chmod 0644 ${current_dir}/${imagename}.img.xz + limit_cpu pixz -p ${cpu_cores:-2} ${current_dir}/${image_name}.img # -p Nº cpu cores use + chmod 0644 ${current_dir}/${image_name}.img.xz fi else - chmod 0644 ${current_dir}/${imagename}.img + chmod 0644 ${current_dir}/${image_name}.img fi # Clean up all the temporary build stuff and remove the directories # Comment this out to keep things around if you want to see what may have gone wrong echo "Cleaning up the temporary build files..." -rm -rf "${basedir}" +rm -rf "${base_dir}" diff --git a/builder.txt.example b/builder.txt.example index db1d5c8..d38bbb8 100644 --- a/builder.txt.example +++ b/builder.txt.example @@ -53,4 +53,4 @@ fstype="ext4" # "kali-linux-202X-WXX-rpi4-nexmon-arm64" for the default filename. # For release builds from Kali, the requirements are that it start with kali-linuxi # and end with the architecture. -#imagename="kali-linux-$(date +%Y)-W$(date +%U)-${hw_model}-${variant}" +#image_name="kali-linux-$(date +%Y)-W$(date +%U)-${hw_model}-${variant}" diff --git a/chromebook-exynos.sh b/chromebook-exynos.sh index 50985ce..ae73017 100755 --- a/chromebook-exynos.sh +++ b/chromebook-exynos.sh @@ -25,7 +25,7 @@ machine=$(tr -cd 'A-Za-z0-9' < /dev/urandom | head -c16 ; echo) # Custom hostname variable hostname=${2:-kali} # Custom image file name variable - MUST NOT include .img at the end -imagename=${3:-kali-linux-$1-chromebook-exynos} +image_name=${3:-kali-linux-$1-chromebook-exynos} # Suite to use, valid options are: # kali-rolling, kali-dev, kali-bleeding-edge, kali-dev-only, kali-experimental, kali-last-snapshot suite=${suite:-"kali-rolling"} @@ -67,20 +67,20 @@ fi # Current directory current_dir="$(pwd)" # Base directory -basedir=${current_dir}/exynos-"$1" +base_dir=${current_dir}/exynos-"$1" # Working directory -work_dir="${basedir}/kali-${architecture}" +work_dir="${base_dir}/kali-${architecture}" # Check directory build -if [ -e "${basedir}" ]; then - echo "${basedir} directory exists, will not continue" >&2 +if [ -e "${base_dir}" ]; then + echo "${base_dir} directory exists, will not continue" >&2 exit 1 elif [[ ${current_dir} =~ [[:space:]] ]]; then echo "The directory "\"${current_dir}"\" contains whitespace. Not supported." >&2 exit 1 else - echo "The basedir thinks it is: ${basedir}" - mkdir -p ${basedir} + echo "The base_dir thinks it is: ${base_dir}" + mkdir -p ${base_dir} fi components="main,contrib,non-free" @@ -324,7 +324,7 @@ EOF # Pull in the gcc 4.7 cross compiler to build the kernel # Debian uses a gcc that the chromebook kernel doesn't have support for -cd "${basedir}" +cd "${base_dir}" git clone --depth 1 https://gitlab.com/kalilinux/packages/gcc-arm-linux-gnueabihf-4-7.git gcc-arm-linux-gnueabihf-4.7 # Kernel section. If you want to use a custom kernel, or configuration, replace @@ -337,7 +337,7 @@ cp ${current_dir}/kernel-configs/chromebook-3.8_wireless-3.4.config exynos_wifi3 git rev-parse HEAD > ${work_dir}/usr/src/kernel-at-commit export ARCH=arm # Edit the CROSS_COMPILE variable as needed -export CROSS_COMPILE="${basedir}"/gcc-arm-linux-gnueabihf-4.7/bin/arm-linux-gnueabihf- +export CROSS_COMPILE="${base_dir}"/gcc-arm-linux-gnueabihf-4.7/bin/arm-linux-gnueabihf- patch -p1 --no-backup-if-mismatch < ${current_dir}/patches/mac80211.patch patch -p1 --no-backup-if-mismatch < ${current_dir}/patches/0001-exynos-drm-smem-start-len.patch patch -p1 --no-backup-if-mismatch < ${current_dir}/patches/0001-mwifiex-do-not-create-AP-and-P2P-interfaces-upon-dri.patch @@ -561,12 +561,12 @@ echo 'noinitrd console=tty1 quiet root=PARTUUID=%U/PARTNROFF=1 rootwait rw lsm.m # bootloader in the kernel partition on ARM dd if=/dev/zero of=bootloader.bin bs=512 count=1 -vbutil_kernel --arch arm --pack "${basedir}"/kernel.bin --keyblock /usr/share/vboot/devkeys/kernel.keyblock --signprivate /usr/share/vboot/devkeys/kernel_data_key.vbprivk --version 1 --config cmdline --bootloader bootloader.bin --vmlinuz exynos-kernel +vbutil_kernel --arch arm --pack "${base_dir}"/kernel.bin --keyblock /usr/share/vboot/devkeys/kernel.keyblock --signprivate /usr/share/vboot/devkeys/kernel_data_key.vbprivk --version 1 --config cmdline --bootloader bootloader.bin --vmlinuz exynos-kernel cd ${work_dir}/usr/src/kernel/ make mrproper cp ../exynos.config .config -cd "${basedir}" +cd "${base_dir}" # Fix up the symlink for building external modules # kernver is used so we don't need to keep track of what the current compiled @@ -668,16 +668,16 @@ root_extra=$((${root_size}/1024/1000*5*1024/5)) raw_size=$(($((${free_space}*1024))+${root_extra}+$((${bootsize}*1024))+4096)) # Create the disk and partition it -echo "Creating image file ${imagename}.img" -fallocate -l $(echo ${raw_size}Ki | numfmt --from=iec-i --to=si) ${current_dir}/${imagename}.img -parted -s ${current_dir}/${imagename}.img mklabel gpt -cgpt create -z ${current_dir}/${imagename}.img -cgpt create ${current_dir}/${imagename}.img +echo "Creating image file ${image_name}.img" +fallocate -l $(echo ${raw_size}Ki | numfmt --from=iec-i --to=si) ${current_dir}/${image_name}.img +parted -s ${current_dir}/${image_name}.img mklabel gpt +cgpt create -z ${current_dir}/${image_name}.img +cgpt create ${current_dir}/${image_name}.img -cgpt add -i 1 -t kernel -b 8192 -s 32768 -l kernel -S 1 -T 5 -P 10 ${current_dir}/${imagename}.img -cgpt add -i 2 -t data -b 40960 -s `expr $(cgpt show ${current_dir}/${imagename}.img | grep 'Sec GPT table' | awk '{ print \$1 }') - 40960` -l Root ${current_dir}/${imagename}.img +cgpt add -i 1 -t kernel -b 8192 -s 32768 -l kernel -S 1 -T 5 -P 10 ${current_dir}/${image_name}.img +cgpt add -i 2 -t data -b 40960 -s `expr $(cgpt show ${current_dir}/${image_name}.img | grep 'Sec GPT table' | awk '{ print \$1 }') - 40960` -l Root ${current_dir}/${image_name}.img -loopdevice=`losetup -f --show ${current_dir}/${imagename}.img` +loopdevice=`losetup -f --show ${current_dir}/${image_name}.img` device=`kpartx -va ${loopdevice} | sed 's/.*\(loop[0-9]\+\)p.*/\1/g' | head -1` sleep 5 device="/dev/mapper/${device}" @@ -691,8 +691,8 @@ elif [[ $fstype == ext3 ]]; then fi mkfs $features -t $fstype -L ROOTFS ${rootp} -mkdir -p "${basedir}"/root -mount ${rootp} "${basedir}"/root +mkdir -p "${base_dir}"/root +mount ${rootp} "${base_dir}"/root # We do this down here to get rid of the build system's resolv.conf after running through the build echo "nameserver ${nameserver}" > "${work_dir}"/etc/resolv.conf @@ -702,13 +702,13 @@ UUID=$(blkid -s UUID -o value ${rootp}) echo "UUID=$UUID / $fstype errors=remount-ro 0 1" >> ${work_dir}/etc/fstab echo "Rsyncing rootfs into image file" -rsync -HPavz -q ${work_dir}/ ${basedir}/root/ +rsync -HPavz -q ${work_dir}/ ${base_dir}/root/ # Unmount partition sync umount ${rootp} -dd if="${basedir}"/kernel.bin of=${bootp} +dd if="${base_dir}"/kernel.bin of=${bootp} cgpt repair ${loopdevice} @@ -739,16 +739,16 @@ limit_cpu (){ if [ $compress = xz ]; then if [ $(arch) == 'x86_64' ]; then - echo "Compressing ${imagename}.img" + echo "Compressing ${image_name}.img" [ $(nproc) \< 3 ] || cpu_cores=3 # cpu_cores = Number of cores to use - limit_cpu pixz -p ${cpu_cores:-2} ${current_dir}/${imagename}.img # -p Nº cpu cores use - chmod 0644 ${current_dir}/${imagename}.img.xz + limit_cpu pixz -p ${cpu_cores:-2} ${current_dir}/${image_name}.img # -p Nº cpu cores use + chmod 0644 ${current_dir}/${image_name}.img.xz fi else - chmod 0644 ${current_dir}/${imagename}.img + chmod 0644 ${current_dir}/${image_name}.img fi # Clean up all the temporary build stuff and remove the directories # Comment this out to keep things around if you want to see what may have gone wrong echo "Removing temporary build files" -rm -rf "${basedir}" +rm -rf "${base_dir}" diff --git a/chromebook-nyan.sh b/chromebook-nyan.sh index 928d78a..262b0de 100755 --- a/chromebook-nyan.sh +++ b/chromebook-nyan.sh @@ -25,7 +25,7 @@ machine=$(tr -cd 'A-Za-z0-9' < /dev/urandom | head -c16 ; echo) # Custom hostname variable hostname=${2:-kali} # Custom image file name variable - MUST NOT include .img at the end -imagename=${3:-kali-linux-$1-chromebook-nyan} +image_name=${3:-kali-linux-$1-chromebook-nyan} # Suite to use, valid options are: # kali-rolling, kali-dev, kali-bleeding-edge, kali-dev-only, kali-experimental, kali-last-snapshot suite=${suite:-"kali-rolling"} @@ -67,20 +67,20 @@ fi # Current directory current_dir="$(pwd)" # Base directory -basedir=${current_dir}/nyan-"$1" +base_dir=${current_dir}/nyan-"$1" # Working directory -work_dir="${basedir}/kali-${architecture}" +work_dir="${base_dir}/kali-${architecture}" # Check directory build -if [ -e "${basedir}" ]; then - echo "${basedir} directory exists, will not continue" >&2 +if [ -e "${base_dir}" ]; then + echo "${base_dir} directory exists, will not continue" >&2 exit 1 elif [[ ${current_dir} =~ [[:space:]] ]]; then echo "The directory "\"${current_dir}"\" contains whitespace. Not supported." >&2 exit 1 else - echo "The basedir thinks it is: ${basedir}" - mkdir -p ${basedir} + echo "The base_dir thinks it is: ${base_dir}" + mkdir -p ${base_dir} fi components="main,contrib,non-free" @@ -327,12 +327,12 @@ EOF # Pull in the gcc 5.3 cross compiler to build the kernel # Debian uses a newer compiler and the # This is a community script - you will need to generate your own image to usebook kernel doesn't support # that -cd "${basedir}" +cd "${base_dir}" git clone --depth 1 https://gitlab.com/kalilinux/packages/gcc-arm-linux-gnueabihf-4-7.git gcc-arm-linux-gnueabihf-4.7 # Kernel section. If you want to use a custom kernel, or configuration, replace # them in this section -cd "${basedir}" +cd "${base_dir}" git clone --depth 1 https://chromium.googlesource.com/chromiumos/third_party/kernel -b release-${kernel_release} ${work_dir}/usr/src/kernel cd ${work_dir}/usr/src/kernel mkdir -p ${work_dir}/usr/src/kernel/firmware/nvidia/tegra124/ @@ -342,7 +342,7 @@ cp ${current_dir}/kernel-configs/# This is a community script - you will need to git rev-parse HEAD > ${work_dir}/usr/src/kernel-at-commit export ARCH=arm # Edit the CROSS_COMPILE variable as needed -export CROSS_COMPILE="${basedir}"/gcc-arm-linux-gnueabihf-4.7/bin/arm-linux-gnueabihf- +export CROSS_COMPILE="${base_dir}"/gcc-arm-linux-gnueabihf-4.7/bin/arm-linux-gnueabihf- patch -p1 --no-backup-if-mismatch < ${current_dir}/patches/mac80211-3.8.patch patch -p1 --no-backup-if-mismatch < ${work_dir}/patches/0001-mwifiex-do-not-create-AP-and-P2P-interfaces-upon-dri-3.8.patch patch -p1 --no-backup-if-mismatch < ${work_dir}/patches/0001-Comment-out-a-pr_debug-print.patch @@ -495,14 +495,14 @@ echo "noinitrd console=tty1 quiet root=PARTUUID=%U/PARTNROFF=1 rootwait rw lsm.m # # bootloader in the kernel partition on ARM dd if=/dev/zero of=bootloader.bin bs=512 count=1 -vbutil_kernel --arch arm --pack "${basedir}"/kernel.bin --keyblock /usr/share/vboot/devkeys/kernel.keyblock --signprivate /usr/share/vboot/devkeys/kernel_data_key.vbprivk --version 1 --config cmdline --bootloader bootloader.bin --vmlinuz nyan-big-kernel +vbutil_kernel --arch arm --pack "${base_dir}"/kernel.bin --keyblock /usr/share/vboot/devkeys/kernel.keyblock --signprivate /usr/share/vboot/devkeys/kernel_data_key.vbprivk --version 1 --config cmdline --bootloader bootloader.bin --vmlinuz nyan-big-kernel cd ${work_dir}/usr/src/kernel # Clean up our build of the kernel, then copy the config and run make # modules_prepare so that users can more easily build kernel modules.. make WIFIVERSION="-3.8" mrproper cp ../nyan.config .config -cd "${basedir}" +cd "${base_dir}" # Fix up the symlink for building external modules # kernver is used so we don't need to keep track of what the current compiled @@ -513,7 +513,7 @@ rm build rm source ln -s /usr/src/kernel build ln -s /usr/src/kernel source -cd "${basedir}" +cd "${base_dir}" # Lid switch cat << EOF > ${work_dir}/etc/udev/rules.d/99-tegra-lid-switch.rules @@ -557,14 +557,14 @@ cp ${current_dir}/bsp/xorg/10-synaptics-# This is a community script - you will # lp0 resume firmware.. # Check https://chromium.googlesource.com/chromiumos/overlays/chromiumos-overlay/+/master/sys-kernel/tegra_lp0_resume/ # to find the lastest commit to use (note: CROS_WORKON_COMMIT ) -cd "${basedir}" +cd "${base_dir}" git clone https://chromium.googlesource.com/chromiumos/third_party/coreboot -cd "${basedir}"/coreboot +cd "${base_dir}"/coreboot git checkout fb840ee4195f9c365375e8914e243ce2f5e4f7bf make -C src/soc/nvidia/tegra124/lp0 GCC_PREFIX=arm-linux-gnueabihf- mkdir -p ${work_dir}/lib/firmware/tegra12x/ cp src/soc/nvidia/tegra124/lp0/tegra_lp0_resume.fw ${work_dir}/lib/firmware/tegra12x/ -cd "${basedir}" +cd "${base_dir}" # Calculate the space to create the image root_size=$(du -s -B1 ${work_dir} --exclude=${work_dir}/boot | cut -f1) @@ -572,16 +572,16 @@ root_extra=$((${root_size}/1024/1000*5*1024/5)) raw_size=$(($((${free_space}*1024))+${root_extra}+$((${bootsize}*1024))+4096)) # Create the disk and partition it -echo "Creating image file ${imagename}.img" -fallocate -l $(echo ${raw_size}Ki | numfmt --from=iec-i --to=si) ${current_dir}/${imagename}.img -parted -s ${current_dir}/${imagename}.img mklabel gpt -cgpt create -z ${current_dir}/${imagename}.img -cgpt create ${current_dir}/${imagename}.img +echo "Creating image file ${image_name}.img" +fallocate -l $(echo ${raw_size}Ki | numfmt --from=iec-i --to=si) ${current_dir}/${image_name}.img +parted -s ${current_dir}/${image_name}.img mklabel gpt +cgpt create -z ${current_dir}/${image_name}.img +cgpt create ${current_dir}/${image_name}.img -cgpt add -i 1 -t kernel -b 8192 -s 32768 -l kernel -S 1 -T 5 -P 10 ${current_dir}/${imagename}.img -cgpt add -i 2 -t data -b 40960 -s `expr $(cgpt show ${current_dir}/${imagename}.img | grep 'Sec GPT table' | awk '{ print \$1 }') - 40960` -l Root ${current_dir}/${imagename}.img +cgpt add -i 1 -t kernel -b 8192 -s 32768 -l kernel -S 1 -T 5 -P 10 ${current_dir}/${image_name}.img +cgpt add -i 2 -t data -b 40960 -s `expr $(cgpt show ${current_dir}/${image_name}.img | grep 'Sec GPT table' | awk '{ print \$1 }') - 40960` -l Root ${current_dir}/${image_name}.img -loopdevice=`losetup -f --show ${current_dir}/${imagename}.img` +loopdevice=`losetup -f --show ${current_dir}/${image_name}.img` device=`kpartx -va ${loopdevice} | sed 's/.*\(loop[0-9]\+\)p.*/\1/g' | head -1` sleep 5 device="/dev/mapper/${device}" @@ -595,8 +595,8 @@ elif [[ $fstype == ext3 ]]; then fi mkfs $features -t $fstype -L ROOTFS ${rootp} -mkdir -p "${basedir}"/root -mount ${rootp} "${basedir}"/root +mkdir -p "${base_dir}"/root +mount ${rootp} "${base_dir}"/root # We do this down here to get rid of the build system's resolv.conf after running through the build echo "nameserver ${nameserver}" > "${work_dir}"/etc/resolv.conf @@ -606,13 +606,13 @@ UUID=$(blkid -s UUID -o value ${rootp}) echo "UUID=$UUID / $fstype errors=remount-ro 0 1" >> ${work_dir}/etc/fstab echo "Rsyncing rootfs into image file" -rsync -HPavz -q ${work_dir}/ ${basedir}/root/ +rsync -HPavz -q ${work_dir}/ ${base_dir}/root/ # Unmount partitions sync umount ${rootp} -dd if="${basedir}"/kernel.bin of=${bootp} +dd if="${base_dir}"/kernel.bin of=${bootp} cgpt repair ${loopdevice} @@ -644,16 +644,16 @@ limit_cpu (){ if [ $compress = xz ]; then if [ $(arch) == 'x86_64' ]; then - echo "Compressing ${imagename}.img" + echo "Compressing ${image_name}.img" [ $(nproc) \< 3 ] || cpu_cores=3 # cpu_cores = Number of cores to use - limit_cpu pixz -p ${cpu_cores:-2} ${current_dir}/${imagename}.img # -p Nº cpu cores use - chmod 0644 ${current_dir}/${imagename}.img.xz + limit_cpu pixz -p ${cpu_cores:-2} ${current_dir}/${image_name}.img # -p Nº cpu cores use + chmod 0644 ${current_dir}/${image_name}.img.xz fi else - chmod 0644 ${current_dir}/${imagename}.img + chmod 0644 ${current_dir}/${image_name}.img fi # Clean up all the temporary build stuff and remove the directories # Comment this out to keep things around if you want to see what may have gone wrong echo "Removing temporary build files" -rm -rf "${basedir}" +rm -rf "${base_dir}" diff --git a/chromebook-veyron.sh b/chromebook-veyron.sh index 361dbd3..0d59b12 100755 --- a/chromebook-veyron.sh +++ b/chromebook-veyron.sh @@ -25,7 +25,7 @@ machine=$(tr -cd 'A-Za-z0-9' < /dev/urandom | head -c16 ; echo) # Custom hostname variable hostname=${2:-kali} # Custom image file name variable - MUST NOT include .img at the end -imagename=${3:-kali-linux-$1-chromebook-veyron} +image_name=${3:-kali-linux-$1-chromebook-veyron} # Suite to use, valid options are: # kali-rolling, kali-dev, kali-bleeding-edge, kali-dev-only, kali-experimental, kali-last-snapshot suite=${suite:-"kali-rolling"} @@ -67,20 +67,20 @@ fi # Current directory current_dir="$(pwd)" # Base directory -basedir=${current_dir}/veyron-"$1" +base_dir=${current_dir}/veyron-"$1" # Working directory -work_dir="${basedir}/kali-${architecture}" +work_dir="${base_dir}/kali-${architecture}" # Check directory build -if [ -e "${basedir}" ]; then - echo "${basedir} directory exists, will not continue" >&2 +if [ -e "${base_dir}" ]; then + echo "${base_dir} directory exists, will not continue" >&2 exit 1 elif [[ ${current_dir} =~ [[:space:]] ]]; then echo "The directory "\"${current_dir}"\" contains whitespace. Not supported." >&2 exit 1 else - echo "The basedir thinks it is: ${basedir}" - mkdir -p ${basedir} + echo "The base_dir thinks it is: ${base_dir}" + mkdir -p ${base_dir} fi components="main,contrib,non-free" @@ -319,7 +319,7 @@ deb ${mirror} ${suite} ${components//,/ } #deb-src ${mirror} ${suite} ${components//,/ } EOF -cd ${basedir} +cd ${base_dir} # Kernel section. If you want to use a custom kernel, or configuration, replace # them in this section @@ -331,17 +331,17 @@ cd ${work_dir}/usr/src/kernel # Check out 4.19.133 which was known to work.. git checkout 17a87580a8856170d59aab302226811a4ae69149 # Mainline kernel config -cp ${basedir}/../kernel-configs/veyron-4.19.config .config +cp ${base_dir}/../kernel-configs/veyron-4.19.config .config # (Currently not working) chromeos-based kernel config -#cp ${basedir}/../kernel-configs/veyron-4.19-cros.config .config +#cp ${base_dir}/../kernel-configs/veyron-4.19-cros.config .config cp .config ${work_dir}/usr/src/veyron.config export ARCH=arm # Edit the CROSS_COMPILE variable as needed export CROSS_COMPILE=arm-linux-gnueabihf- # This allows us to patch the kernel without it adding -dirty to the kernel version touch .scmversion -patch -p1 --no-backup-if-mismatch < ${basedir}/../patches/veyron/4.19/kali-wifi-injection.patch -patch -p1 --no-backup-if-mismatch < ${basedir}/../patches/veyron/4.19/wireless-carl9170-Enable-sniffer-mode-promisc-flag-t.patch +patch -p1 --no-backup-if-mismatch < ${base_dir}/../patches/veyron/4.19/kali-wifi-injection.patch +patch -p1 --no-backup-if-mismatch < ${base_dir}/../patches/veyron/4.19/wireless-carl9170-Enable-sniffer-mode-promisc-flag-t.patch make -j$(grep -c processor /proc/cpuinfo) make dtbs make modules_install INSTALL_MOD_PATH=${work_dir} @@ -475,12 +475,12 @@ echo 'noinitrd console=tty1 quiet root=PARTUUID=%U/PARTNROFF=1 rootwait rw lsm.m # bootloader in the kernel partition on ARM dd if=/dev/zero of=bootloader.bin bs=512 count=1 -vbutil_kernel --arch arm --pack "${basedir}"/kernel.bin --keyblock /usr/share/vboot/devkeys/kernel.keyblock --signprivate /usr/share/vboot/devkeys/kernel_data_key.vbprivk --version 1 --config cmdline --bootloader bootloader.bin --vmlinuz veyron-kernel +vbutil_kernel --arch arm --pack "${base_dir}"/kernel.bin --keyblock /usr/share/vboot/devkeys/kernel.keyblock --signprivate /usr/share/vboot/devkeys/kernel_data_key.vbprivk --version 1 --config cmdline --bootloader bootloader.bin --vmlinuz veyron-kernel cd ${work_dir}/usr/src/kernel make mrproper -cp ${basedir}/../kernel-configs/veyron-4.19.config .config -#cp ${basedir}/../kernel-configs/veyron-4.19-cros.config .config -cd ${basedir} +cp ${base_dir}/../kernel-configs/veyron-4.19.config .config +#cp ${base_dir}/../kernel-configs/veyron-4.19-cros.config .config +cd ${base_dir} # Fix up the symlink for building external modules # kernver is used so we don't need to keep track of what the current compiled @@ -491,7 +491,7 @@ rm build rm source ln -s /usr/src/kernel build ln -s /usr/src/kernel source -cd ${basedir} +cd ${base_dir} # Disable uap0 and p2p0 interfaces in NetworkManager mkdir -p ${work_dir}/etc/NetworkManager/ @@ -499,20 +499,20 @@ echo -e '\n[keyfile]\nunmanaged-devices=interface-name:p2p0\n' >> ${work_dir}/et # Create these if they don't exist, to make sure we have proper audio with pulse mkdir -p ${work_dir}/var/lib/alsa/ -cp ${basedir}/../bsp/audio/veyron/asound.state ${work_dir}/var/lib/alsa/asound.state -cp ${basedir}/../bsp/audio/veyron/default.pa ${work_dir}/etc/pulse/default.pa +cp ${base_dir}/../bsp/audio/veyron/asound.state ${work_dir}/var/lib/alsa/asound.state +cp ${base_dir}/../bsp/audio/veyron/default.pa ${work_dir}/etc/pulse/default.pa # mali rules so users can access the mali0 driver.. -cp ${basedir}/../bsp/udev/50-mali.rules ${work_dir}/etc/udev/rules.d/50-mali.rules -cp ${basedir}/../bsp/udev/50-media.rules ${work_dir}/etc/udev/rules.d/50-media.rules +cp ${base_dir}/../bsp/udev/50-mali.rules ${work_dir}/etc/udev/rules.d/50-mali.rules +cp ${base_dir}/../bsp/udev/50-media.rules ${work_dir}/etc/udev/rules.d/50-media.rules # EHCI is apparently quirky -cp ${basedir}/../bsp/udev/99-rk3288-ehci-persist.rules ${work_dir}/etc/udev/rules.d/99-rk3288-ehci-persist.rules +cp ${base_dir}/../bsp/udev/99-rk3288-ehci-persist.rules ${work_dir}/etc/udev/rules.d/99-rk3288-ehci-persist.rules # Avoid gpio charger wakeup system -cp ${basedir}/../bsp/udev/99-rk3288-gpio-charger.rules ${work_dir}/etc/udev/rules.d/99-rk3288-gpio-charger.rules +cp ${base_dir}/../bsp/udev/99-rk3288-gpio-charger.rules ${work_dir}/etc/udev/rules.d/99-rk3288-gpio-charger.rules # Rule used to kick start the bluetooth/wifi chip -cp ${basedir}/../bsp/udev/80-brcm-sdio-added.rules ${work_dir}/etc/udev/rules.d/80-brcm-sdio-added.rules +cp ${base_dir}/../bsp/udev/80-brcm-sdio-added.rules ${work_dir}/etc/udev/rules.d/80-brcm-sdio-added.rules # Hide the eMMC partitions from udisks -cp ${basedir}/../bsp/udev/99-hide-emmc-partitions.rules ${work_dir}/etc/udev/rules.d/99-hide-emmc-partitions.rules +cp ${base_dir}/../bsp/udev/99-hide-emmc-partitions.rules ${work_dir}/etc/udev/rules.d/99-hide-emmc-partitions.rules # disable btdsio mkdir -p ${work_dir}/etc/modprobe.d/ @@ -522,19 +522,19 @@ EOF # Touchpad configuration mkdir -p ${work_dir}/etc/X11/xorg.conf.d -cp ${basedir}/../bsp/xorg/10-synaptics-chromebook.conf ${work_dir}/etc/X11/xorg.conf.d/ +cp ${base_dir}/../bsp/xorg/10-synaptics-chromebook.conf ${work_dir}/etc/X11/xorg.conf.d/ # Copy the broadcom firmware files in mkdir -p ${work_dir}/lib/firmware/brcm/ -cp ${basedir}/../bsp/firmware/veyron/brcm* ${work_dir}/lib/firmware/brcm/ -cp ${basedir}/../bsp/firmware/veyron/BCM* ${work_dir}/lib/firmware/brcm/ +cp ${base_dir}/../bsp/firmware/veyron/brcm* ${work_dir}/lib/firmware/brcm/ +cp ${base_dir}/../bsp/firmware/veyron/BCM* ${work_dir}/lib/firmware/brcm/ # Copy in the touchpad firmwares - same as above -cp ${basedir}/../bsp/firmware/veyron/elan* ${work_dir}/lib/firmware/ -cp ${basedir}/../bsp/firmware/veyron/max* ${work_dir}/lib/firmware/ -cd ${basedir} +cp ${base_dir}/../bsp/firmware/veyron/elan* ${work_dir}/lib/firmware/ +cp ${base_dir}/../bsp/firmware/veyron/max* ${work_dir}/lib/firmware/ +cd ${base_dir} # We need to kick start the sdio chip to get bluetooth/wifi going -cp ${basedir}/../bsp/firmware/veyron/brcm_patchram_plus ${work_dir}/usr/sbin/ +cp ${base_dir}/../bsp/firmware/veyron/brcm_patchram_plus ${work_dir}/usr/sbin/ # Calculate the space to create the image root_size=$(du -s -B1 ${work_dir} --exclude=${work_dir}/boot | cut -f1) @@ -542,16 +542,16 @@ root_extra=$((${root_size}/1024/1000*5*1024/5)) raw_size=$(($((${free_space}*1024))+${root_extra}+$((${bootsize}*1024))+4096)) # Create the disk and partition it -echo "Creating image file ${imagename}.img" -fallocate -l $(echo ${raw_size}Ki | numfmt --from=iec-i --to=si) ${current_dir}/${imagename}.img -parted -s ${current_dir}/${imagename}.img mklabel gpt -cgpt create -z ${current_dir}/${imagename}.img -cgpt create ${current_dir}/${imagename}.img +echo "Creating image file ${image_name}.img" +fallocate -l $(echo ${raw_size}Ki | numfmt --from=iec-i --to=si) ${current_dir}/${image_name}.img +parted -s ${current_dir}/${image_name}.img mklabel gpt +cgpt create -z ${current_dir}/${image_name}.img +cgpt create ${current_dir}/${image_name}.img -cgpt add -i 1 -t kernel -b 8192 -s 32768 -l kernel -S 1 -T 5 -P 10 ${current_dir}/${imagename}.img -cgpt add -i 2 -t data -b 40960 -s `expr $(cgpt show ${current_dir}/${imagename}.img | grep 'Sec GPT table' | awk '{ print \$1 }') - 40960` -l Root ${current_dir}/${imagename}.img +cgpt add -i 1 -t kernel -b 8192 -s 32768 -l kernel -S 1 -T 5 -P 10 ${current_dir}/${image_name}.img +cgpt add -i 2 -t data -b 40960 -s `expr $(cgpt show ${current_dir}/${image_name}.img | grep 'Sec GPT table' | awk '{ print \$1 }') - 40960` -l Root ${current_dir}/${image_name}.img -loopdevice=`losetup -f --show ${current_dir}/${imagename}.img` +loopdevice=`losetup -f --show ${current_dir}/${image_name}.img` device=`kpartx -va ${loopdevice} | sed 's/.*\(loop[0-9]\+\)p.*/\1/g' | head -1` sleep 5 device="/dev/mapper/${device}" @@ -565,21 +565,21 @@ elif [[ $fstype == ext3 ]]; then fi mkfs $features -t $fstype -L ROOTFS ${rootp} -mkdir -p "${basedir}"/root -mount ${rootp} "${basedir}"/root +mkdir -p "${base_dir}"/root +mount ${rootp} "${base_dir}"/root # Create an fstab so that we don't mount / read-only UUID=$(blkid -s UUID -o value ${rootp}) echo "UUID=$UUID / $fstype errors=remount-ro 0 1" >> ${work_dir}/etc/fstab echo "Rsyncing rootfs into image file" -rsync -HPavz -q ${work_dir}/ ${basedir}/root/ +rsync -HPavz -q ${work_dir}/ ${base_dir}/root/ # Unmount partitions sync umount ${rootp} -dd if=${basedir}/kernel.bin of=${bootp} +dd if=${base_dir}/kernel.bin of=${bootp} cgpt repair ${loopdevice} @@ -610,16 +610,16 @@ limit_cpu (){ if [ $compress = xz ]; then if [ $(arch) == 'x86_64' ]; then - echo "Compressing ${imagename}.img" + echo "Compressing ${image_name}.img" [ $(nproc) \< 3 ] || cpu_cores=3 # cpu_cores = Number of cores to use - limit_cpu pixz -p ${cpu_cores:-2} ${current_dir}/${imagename}.img # -p Nº cpu cores use - chmod 0644 ${current_dir}/${imagename}.img.xz + limit_cpu pixz -p ${cpu_cores:-2} ${current_dir}/${image_name}.img # -p Nº cpu cores use + chmod 0644 ${current_dir}/${image_name}.img.xz fi else - chmod 0644 ${current_dir}/${imagename}.img + chmod 0644 ${current_dir}/${image_name}.img fi # Clean up all the temporary build stuff and remove the directories # Comment this out to keep things around if you want to see what may have gone wrong echo "Removing temporary build files" -rm -rf "${basedir}" +rm -rf "${base_dir}" diff --git a/common.d/check.sh b/common.d/check.sh index e75efb2..e0c6ca3 100644 --- a/common.d/check.sh +++ b/common.d/check.sh @@ -15,15 +15,15 @@ if [ ! -e "bsp" ]; then fi # Check directory build -if [ -e "${basedir}" ]; then - log "${basedir} directory exists, will not continue" red +if [ -e "${base_dir}" ]; then + log "${base_dir} directory exists, will not continue" red exit 1 elif [[ ${current_dir} =~ [[:space:]] ]]; then log "The directory "\"${current_dir}"\" contains whitespace. Not supported." red exit 1 else print_config - mkdir -p ${basedir} + mkdir -p ${base_dir} fi # Detect architecture diff --git a/common.d/compress_img.sh b/common.d/compress_img.sh index f1d2c12..1a89724 100644 --- a/common.d/compress_img.sh +++ b/common.d/compress_img.sh @@ -3,15 +3,15 @@ log "compress image" green if [ "${compress:=}" = xz ]; then - log "Compressing file: $(tput sgr0) ${imagename:=}.img" green + log "Compressing file: $(tput sgr0) ${image_name:=}.img" green if [ "$(arch)" == 'x86_64' ] || [ "$(arch)" == 'aarch64' ]; then - limit_cpu pixz -p "${num_cores:=}" "${image_dir:=}/${imagename:=}.img" # -p Nº cpu cores use + limit_cpu pixz -p "${num_cores:=}" "${image_dir:=}/${image_name:=}.img" # -p Nº cpu cores use else - xz --memlimit-compress=50% -T "$num_cores" "${image_dir:=}/${imagename:=}.img" # -T Nº cpu cores use + xz --memlimit-compress=50% -T "$num_cores" "${image_dir:=}/${image_name:=}.img" # -T Nº cpu cores use fi - chmod 0644 "${image_dir:=}/${imagename:=}.img.xz" - stat "${image_dir:=}/${imagename:=}.img.xz" + chmod 0644 "${image_dir:=}/${image_name:=}.img.xz" + stat "${image_dir:=}/${image_name:=}.img.xz" else - chmod 0644 "${image_dir:=}/${imagename:=}.img" - stat "${image_dir:=}/${imagename:=}.img" + chmod 0644 "${image_dir:=}/${image_name:=}.img" + stat "${image_dir:=}/${image_name:=}.img" fi diff --git a/common.d/functions.sh b/common.d/functions.sh index 196afff..1044740 100644 --- a/common.d/functions.sh +++ b/common.d/functions.sh @@ -225,7 +225,7 @@ function print_config() { log "Hardware model: $(tput sgr0) $hw_model" cyan fi log "Architecture: $(tput sgr0) $architecture" cyan - log "The basedir thinks it is: $(tput sgr0) ${basedir}" cyan + log "The base_dir thinks it is: $(tput sgr0) ${base_dir}" cyan echo -e "\n" sleep 1.5 } @@ -238,16 +238,16 @@ function make_image() { raw_size=$(($((free_space * 1024)) + root_extra + $((bootsize * 1024)) + 4096)) img_size=$(echo "${raw_size}"Ki | numfmt --from=iec-i --to=si) # Create the disk image - log "Creating image file ${imagename}.img (${img_size})" green + log "Creating image file ${image_name}.img (${img_size})" green mkdir -p "${image_dir}/" - fallocate -l "${img_size}" "${image_dir}/${imagename}.img" + fallocate -l "${img_size}" "${image_dir}/${image_name}.img" } # Clean up all the temporary build stuff and remove the directories. function clean_build() { log "Cleaning up the temporary build files..." yellow - rm -rf "${basedir}" + rm -rf "${base_dir}" log "Done." green echo -e "\n" - log "Your image is: $(tput sgr0) $(ls "${imagename}".*)" bold + log "Your image is: $(tput sgr0) $(ls "${image_name}".*)" bold } diff --git a/common.d/rpi_userland.sh b/common.d/rpi_userland.sh index fe27ca3..b4b7747 100644 --- a/common.d/rpi_userland.sh +++ b/common.d/rpi_userland.sh @@ -3,10 +3,10 @@ log "rpi userland" green -git clone https://github.com/raspberrypi/userland.git "${basedir}"/userland +git clone https://github.com/raspberrypi/userland.git "${base_dir}"/userland -cd "${basedir}"/userland && mkdir -p build/ -pushd "${basedir}"/userland/build || exit +cd "${base_dir}"/userland && mkdir -p build/ +pushd "${base_dir}"/userland/build || exit case ${architecture} in arm64) diff --git a/common.d/variables.sh b/common.d/variables.sh index 58e7dab..92b9fce 100644 --- a/common.d/variables.sh +++ b/common.d/variables.sh @@ -4,15 +4,15 @@ # Current directory current_dir="$(pwd)" # Base directory -basedir=${current_dir}/base/${hw_model}-${variant} +base_dir=${current_dir}/base/${hw_model}-${variant} # Working directory -work_dir="${basedir}/working/kali-${architecture}" +work_dir="${base_dir}/working/kali-${architecture}" # Image directory image_dir="${current_dir}/images" # Version Kali release version=${version:-$(cat ${current_dir}/.release)} # Custom image file name variable - MUST NOT include .img at the end -imagename=${imagename:-"kali-linux-${version}-${hw_model}-${variant}"} +image_name=${image_name:-"kali-linux-${version}-${hw_model}-${variant}"} # Generate a random machine name to be used machine=$(dbus-uuidgen) # Custom hostname variable diff --git a/cubieboard2.sh b/cubieboard2.sh index 964ce9b..714f212 100755 --- a/cubieboard2.sh +++ b/cubieboard2.sh @@ -25,7 +25,7 @@ machine=$(tr -cd 'A-Za-z0-9' < /dev/urandom | head -c16 ; echo) # Custom hostname variable hostname=${2:-kali} # Custom image file name variable - MUST NOT include .img at the end -imagename=${3:-kali-linux-$1-cubieboard2} +image_name=${3:-kali-linux-$1-cubieboard2} # Suite to use, valid options are: # kali-rolling, kali-dev, kali-bleeding-edge, kali-dev-only, kali-experimental, kali-last-snapshot suite=${suite:-"kali-rolling"} @@ -67,20 +67,20 @@ fi # Current directory current_dir="$(pwd)" # Base directory -basedir=${current_dir}/cubieboard2-"$1" +base_dir=${current_dir}/cubieboard2-"$1" # Working directory -work_dir="${basedir}/kali-${architecture}" +work_dir="${base_dir}/kali-${architecture}" # Check directory build -if [ -e "${basedir}" ]; then - echo "${basedir} directory exists, will not continue" >&2 +if [ -e "${base_dir}" ]; then + echo "${base_dir} directory exists, will not continue" >&2 exit 1 elif [[ ${current_dir} =~ [[:space:]] ]]; then echo "The directory "\"${current_dir}"\" contains whitespace. Not supported." >&2 exit 1 else - echo "The basedir thinks it is: ${basedir}" - mkdir -p ${basedir} + echo "The base_dir thinks it is: ${base_dir}" + mkdir -p ${base_dir} fi components="main,contrib,non-free" @@ -332,15 +332,15 @@ EOF # Kernel section. If you want to us ea custom kernel, or configuration, replace # them in this section # Get, compile and install kernel -cd ${basedir} +cd ${base_dir} git clone --depth 1 https://github.com/linux-sunxi/u-boot-sunxi git clone --depth 1 https://github.com/linux-sunxi/linux-sunxi -b stage/sunxi-3.4 ${work_dir}/usr/src/kernel git clone --depth 1 https://github.com/linux-sunxi/sunxi-tools git clone --depth 1 https://github.com/linux-sunxi/sunxi-boards -cd "${basedir}"/sunxi-tools +cd "${base_dir}"/sunxi-tools make fex2bin -./fex2bin "${basedir}"/sunxi-boards/sys_config/a20/cubieboard2.fex ${work_dir}/boot/script.bin +./fex2bin "${base_dir}"/sunxi-boards/sys_config/a20/cubieboard2.fex ${work_dir}/boot/script.bin cd ${work_dir}/usr/src/kernel git rev-parse HEAD > ${work_dir}/usr/src/kernel-at-commit @@ -355,7 +355,7 @@ make modules_install INSTALL_MOD_PATH=${work_dir} cp arch/arm/boot/uImage ${work_dir}/boot make mrproper cp ../sun7i.config .config -cd "${basedir}" +cd "${base_dir}" # Fix up the symlink for building external modules # kernver is used so we don't need to keep track of what the current compiled @@ -366,7 +366,7 @@ rm build rm source ln -s /usr/src/kernel build ln -s /usr/src/kernel source -cd "${basedir}" +cd "${base_dir}" # Create boot.txt file cat << EOF > ${work_dir}/boot/boot.cmd @@ -385,14 +385,14 @@ root_extra=$((${root_size}/1024/1000*5*1024/5)) raw_size=$(($((${free_space}*1024))+${root_extra}+$((${bootsize}*1024))+4096)) # Create the disk and partition it -echo "Creating image file ${imagename}.img" -fallocate -l $(echo ${raw_size}Ki | numfmt --from=iec-i --to=si) ${current_dir}/${imagename}.img -parted -s ${current_dir}/${imagename}.img mklabel msdos -parted -s ${current_dir}/${imagename}.img mkpart primary fat32 1MiB ${bootsize}MiB -parted -s -a minimal ${current_dir}/${imagename}.img mkpart primary $fstype ${bootsize}MiB 100% +echo "Creating image file ${image_name}.img" +fallocate -l $(echo ${raw_size}Ki | numfmt --from=iec-i --to=si) ${current_dir}/${image_name}.img +parted -s ${current_dir}/${image_name}.img mklabel msdos +parted -s ${current_dir}/${image_name}.img mkpart primary fat32 1MiB ${bootsize}MiB +parted -s -a minimal ${current_dir}/${image_name}.img mkpart primary $fstype ${bootsize}MiB 100% # Set the partition variables -loopdevice=`losetup -f --show ${current_dir}/${imagename}.img` +loopdevice=`losetup -f --show ${current_dir}/${image_name}.img` device=`kpartx -va ${loopdevice} | sed 's/.*\(loop[0-9]\+\)p.*/\1/g' | head -1` sleep 5 device="/dev/mapper/${device}" @@ -409,10 +409,10 @@ fi mkfs $features -t $fstype -L ROOTFS ${rootp} # Create the dirs for the partitions and mount them -mkdir -p "${basedir}"/root -mount ${rootp} "${basedir}"/root -mkdir -p "${basedir}"/root/boot -mount ${bootp} "${basedir}"/root/boot +mkdir -p "${base_dir}"/root +mount ${rootp} "${base_dir}"/root +mkdir -p "${base_dir}"/root/boot +mount ${bootp} "${base_dir}"/root/boot # We do this down here to get rid of the build system's resolv.conf after running through the build echo "nameserver ${nameserver}" > "${work_dir}"/etc/resolv.conf @@ -422,7 +422,7 @@ UUID=$(blkid -s UUID -o value ${rootp}) echo "UUID=$UUID / $fstype errors=remount-ro 0 1" >> ${work_dir}/etc/fstab echo "Rsyncing rootfs to image file" -rsync -HPavz -q ${work_dir}/ ${basedir}/root/ +rsync -HPavz -q ${work_dir}/ ${base_dir}/root/ # Unmount partitions sync @@ -430,7 +430,7 @@ umount ${bootp} umount ${rootp} kpartx -dv ${loopdevice} -cd "${basedir}"/u-boot-sunxi/ +cd "${base_dir}"/u-boot-sunxi/ # Build u-boot make distclean make Cubieboard2_config @@ -438,7 +438,7 @@ make -j $(nproc) dd if=u-boot-sunxi-with-spl.bin of=${loopdevice} bs=1024 seek=8 -cd "${basedir}" +cd "${base_dir}" losetup -d ${loopdevice} @@ -466,16 +466,16 @@ limit_cpu (){ if [ $compress = xz ]; then if [ $(arch) == 'x86_64' ]; then - echo "Compressing ${imagename}.img" + echo "Compressing ${image_name}.img" [ $(nproc) \< 3 ] || cpu_cores=3 # cpu_cores = Number of cores to use - limit_cpu pixz -p ${cpu_cores:-2} ${current_dir}/${imagename}.img # -p Nº cpu cores use - chmod 0644 ${current_dir}/${imagename}.img.xz + limit_cpu pixz -p ${cpu_cores:-2} ${current_dir}/${image_name}.img # -p Nº cpu cores use + chmod 0644 ${current_dir}/${image_name}.img.xz fi else - chmod 0644 ${current_dir}/${imagename}.img + chmod 0644 ${current_dir}/${image_name}.img fi # Clean up all the temporary build stuff and remove the directories # Comment this out to keep things around if you want to see what may have gone wrong echo "Cleaning up the temporary build files..." -rm -rf "${basedir}" +rm -rf "${base_dir}" diff --git a/cubietruck.sh b/cubietruck.sh index ef82c86..2cde6ec 100755 --- a/cubietruck.sh +++ b/cubietruck.sh @@ -25,7 +25,7 @@ machine=$(tr -cd 'A-Za-z0-9' < /dev/urandom | head -c16 ; echo) # Custom hostname variable hostname=${2:-kali} # Custom image file name variable - MUST NOT include .img at the end -imagename=${3:-kali-linux-$1-cubietruck} +image_name=${3:-kali-linux-$1-cubietruck} # Suite to use, valid options are: # kali-rolling, kali-dev, kali-bleeding-edge, kali-dev-only, kali-experimental, kali-last-snapshot suite=${suite:-"kali-rolling"} @@ -67,20 +67,20 @@ fi # Current directory current_dir="$(pwd)" # Base directory -basedir=${current_dir}/cubietruck-"$1" +base_dir=${current_dir}/cubietruck-"$1" # Working directory -work_dir="${basedir}/kali-${architecture}" +work_dir="${base_dir}/kali-${architecture}" # Check directory build -if [ -e "${basedir}" ]; then - echo "${basedir} directory exists, will not continue" >&2 +if [ -e "${base_dir}" ]; then + echo "${base_dir} directory exists, will not continue" >&2 exit 1 elif [[ ${current_dir} =~ [[:space:]] ]]; then echo "The directory "\"${current_dir}"\" contains whitespace. Not supported." >&2 exit 1 else - echo "The basedir thinks it is: ${basedir}" - mkdir -p ${basedir} + echo "The base_dir thinks it is: ${base_dir}" + mkdir -p ${base_dir} fi components="main,contrib,non-free" @@ -337,9 +337,9 @@ git clone --depth 1 https://github.com/linux-sunxi/linux-sunxi -b stage/sunxi-3. git clone --depth 1 https://github.com/linux-sunxi/sunxi-tools git clone --depth 1 https://github.com/linux-sunxi/sunxi-boards -cd "${basedir}"/sunxi-tools +cd "${base_dir}"/sunxi-tools make fex2bin -./fex2bin "${basedir}"/sunxi-boards/sys_config/a20/cubietruck.fex ${work_dir}/boot/script.bin +./fex2bin "${base_dir}"/sunxi-boards/sys_config/a20/cubietruck.fex ${work_dir}/boot/script.bin cd ${work_dir}/usr/src/kernel git rev-parse HEAD > ../kernel-at-commit @@ -354,7 +354,7 @@ make modules_install INSTALL_MOD_PATH=${work_dir} cp arch/arm/boot/uImage ${work_dir}/boot make mrproper cp ../sun7i.config .config -cd "${basedir}" +cd "${base_dir}" # Fix up the symlink for building external modules # kernver is used so we don't need to keep track of what the current compiled @@ -365,7 +365,7 @@ rm build rm source ln -s /usr/src/kernel build ln -s /usr/src/kernel source -cd "${basedir}" +cd "${base_dir}" # Create boot.txt file cat << EOF > ${work_dir}/boot/boot.cmd @@ -385,14 +385,14 @@ root_extra=$((${root_size}/1024/1000*5*1024/5)) raw_size=$(($((${free_space}*1024))+${root_extra}+$((${bootsize}*1024))+4096)) # Create the disk and partition it -echo "Creating image file ${imagename}.img" -fallocate -l $(echo ${raw_size}Ki | numfmt --from=iec-i --to=si) ${current_dir}/${imagename}.img -parted -s ${current_dir}/${imagename}.img mklabel msdos -parted -s ${current_dir}/${imagename}.img mkpart primary fat32 1MiB ${bootsize}MiB -parted -s -a minimal ${current_dir}/${imagename}.img mkpart primary $fstype ${bootsize}MiB 100% +echo "Creating image file ${image_name}.img" +fallocate -l $(echo ${raw_size}Ki | numfmt --from=iec-i --to=si) ${current_dir}/${image_name}.img +parted -s ${current_dir}/${image_name}.img mklabel msdos +parted -s ${current_dir}/${image_name}.img mkpart primary fat32 1MiB ${bootsize}MiB +parted -s -a minimal ${current_dir}/${image_name}.img mkpart primary $fstype ${bootsize}MiB 100% # Set the partition variables -loopdevice=`losetup -f --show ${current_dir}/${imagename}.img` +loopdevice=`losetup -f --show ${current_dir}/${image_name}.img` device=`kpartx -va ${loopdevice} | sed 's/.*\(loop[0-9]\+\)p.*/\1/g' | head -1` sleep 5 device="/dev/mapper/${device}" @@ -409,10 +409,10 @@ fi mkfs $features -t $fstype -L ROOTFS ${rootp} # Create the dirs for the partitions and mount them -mkdir -p "${basedir}"/root -mount ${rootp} "${basedir}"/root -mkdir -p "${basedir}"/root/boot -mount ${bootp} "${basedir}"/root/boot +mkdir -p "${base_dir}"/root +mount ${rootp} "${base_dir}"/root +mkdir -p "${base_dir}"/root/boot +mount ${bootp} "${base_dir}"/root/boot # We do this down here to get rid of the build system's resolv.conf after running through the build echo "nameserver ${nameserver}" > "${work_dir}"/etc/resolv.conf @@ -422,7 +422,7 @@ UUID=$(blkid -s UUID -o value ${rootp}) echo "UUID=$UUID / $fstype errors=remount-ro 0 1" >> ${work_dir}/etc/fstab echo "Rsyncing rootfs to image file" -rsync -HPavz -q ${work_dir}/ ${basedir}/root/ +rsync -HPavz -q ${work_dir}/ ${base_dir}/root/ # Unmount partitions sync @@ -430,7 +430,7 @@ umount ${bootp} umount ${rootp} kpartx -dv ${loopdevice} -cd "${basedir}"/u-boot-sunxi/ +cd "${base_dir}"/u-boot-sunxi/ # Build u-boot make distclean make Cubietruck_config @@ -464,16 +464,16 @@ limit_cpu (){ if [ $compress = xz ]; then if [ $(arch) == 'x86_64' ]; then - echo "Compressing ${imagename}.img" + echo "Compressing ${image_name}.img" [ $(nproc) \< 3 ] || cpu_cores=3 # cpu_cores = Number of cores to use - limit_cpu pixz -p ${cpu_cores:-2} ${current_dir}/${imagename}.img # -p Nº cpu cores use - chmod 0644 ${current_dir}/${imagename}.img.xz + limit_cpu pixz -p ${cpu_cores:-2} ${current_dir}/${image_name}.img # -p Nº cpu cores use + chmod 0644 ${current_dir}/${image_name}.img.xz fi else - chmod 0644 ${current_dir}/${imagename}.img + chmod 0644 ${current_dir}/${image_name}.img fi # Clean up all the temporary build stuff and remove the directories # Comment this out to keep things around if you want to see what may have gone wrong echo "Cleaning up the temporary build files..." -rm -rf "${basedir}" +rm -rf "${base_dir}" diff --git a/cubox-i4pro.sh b/cubox-i4pro.sh index e00d77c..808e04a 100755 --- a/cubox-i4pro.sh +++ b/cubox-i4pro.sh @@ -25,7 +25,7 @@ machine=$(tr -cd 'A-Za-z0-9' < /dev/urandom | head -c16 ; echo) # Custom hostname variable hostname=${2:-kali} # Custom image file name variable - MUST NOT include .img at the end -imagename=${3:-kali-linux-$1-cubox-i4pro} +image_name=${3:-kali-linux-$1-cubox-i4pro} # Suite to use, valid options are: # kali-rolling, kali-dev, kali-bleeding-edge, kali-dev-only, kali-experimental, kali-last-snapshot suite=${suite:-"kali-rolling"} @@ -67,20 +67,20 @@ fi # Current directory current_dir="$(pwd)" # Base directory -basedir=${current_dir}/cuboxi-"$1" +base_dir=${current_dir}/cuboxi-"$1" # Working directory -work_dir="${basedir}/kali-${architecture}" +work_dir="${base_dir}/kali-${architecture}" # Check directory build -if [ -e "${basedir}" ]; then - echo "${basedir} directory exists, will not continue" >&2 +if [ -e "${base_dir}" ]; then + echo "${base_dir} directory exists, will not continue" >&2 exit 1 elif [[ ${current_dir} =~ [[:space:]] ]]; then echo "The directory "\"${current_dir}"\" contains whitespace. Not supported." >&2 exit 1 else - echo "The basedir thinks it is: ${basedir}" - mkdir -p ${basedir} + echo "The base_dir thinks it is: ${base_dir}" + mkdir -p ${base_dir} fi components="main,contrib,non-free" @@ -334,7 +334,7 @@ EOF # For some reason the brcm firmware doesn't work properly in linux-firmware git # so we grab the ones from OpenELEC -cd ${basedir} +cd ${base_dir} git clone https://github.com/OpenELEC/wlan-firmware cd wlan-firmware rm -rf ${work_dir}/lib/firmware/brcm @@ -349,13 +349,13 @@ root_extra=$((${root_size}/1024/1000*5*1024/5)) raw_size=$(($((${free_space}*1024))+${root_extra}+$((${bootsize}*1024))+4096)) # Create the disk and partition it -echo "Creating image file ${imagename}.img" -fallocate -l $(echo ${raw_size}Ki | numfmt --from=iec-i --to=si) ${current_dir}/${imagename}.img -parted -s ${current_dir}/${imagename}.img mklabel msdos -parted -s -a minimal ${current_dir}/${imagename}.img mkpart primary $fstype 1MiB 100% +echo "Creating image file ${image_name}.img" +fallocate -l $(echo ${raw_size}Ki | numfmt --from=iec-i --to=si) ${current_dir}/${image_name}.img +parted -s ${current_dir}/${image_name}.img mklabel msdos +parted -s -a minimal ${current_dir}/${image_name}.img mkpart primary $fstype 1MiB 100% # Set the partition variables -loopdevice=`losetup -f --show ${current_dir}/${imagename}.img` +loopdevice=`losetup -f --show ${current_dir}/${image_name}.img` device=`kpartx -va ${loopdevice} | sed 's/.*\(loop[0-9]\+\)p.*/\1/g' | head -1` sleep 5 device="/dev/mapper/${device}" @@ -369,8 +369,8 @@ fi mkfs $features -t $fstype -L ROOTFS ${rootp} # Create the dirs for the partitions and mount them -mkdir -p "${basedir}"/root -mount ${rootp} "${basedir}"/root +mkdir -p "${base_dir}"/root +mount ${rootp} "${base_dir}"/root # We do this down here to get rid of the build system's resolv.conf after running through the build echo "nameserver ${nameserver}" > "${work_dir}"/etc/resolv.conf @@ -380,7 +380,7 @@ UUID=$(blkid -s UUID -o value ${rootp}) echo "UUID=$UUID / $fstype errors=remount-ro 0 1" >> ${work_dir}/etc/fstab echo "Rsyncing rootfs into image file" -rsync -HPavz -q ${work_dir}/ ${basedir}/root/ +rsync -HPavz -q ${work_dir}/ ${base_dir}/root/ dd conv=fsync,notrunc if=${work_dir}/usr/lib/u-boot/mx6cuboxi/SPL of=${loopdevice} bs=1k seek=1 dd conv=fsync,notrunc if=${work_dir}/usr/lib/u-boot/mx6cuboxi/u-boot.img of=${loopdevice} bs=1k seek=69 @@ -394,9 +394,9 @@ umount ${rootp} #git clone https://github.com/offensive-security/gcc-arm-linux-gnueabihf-4.7 #git clone https://github.com/SolidRun/u-boot-imx6.git -#cd "${basedir}"/u-boot-imx6 -#make CROSS_COMPILE="${basedir}"/gcc-arm-linux-gnueabihf-4.7/bin/arm-linux-gnueabihf- mx6_cubox-i_config -#make CROSS_COMPILE="${basedir}"/gcc-arm-linux-gnueabihf-4.7/bin/arm-linux-gnueabihf- +#cd "${base_dir}"/u-boot-imx6 +#make CROSS_COMPILE="${base_dir}"/gcc-arm-linux-gnueabihf-4.7/bin/arm-linux-gnueabihf- mx6_cubox-i_config +#make CROSS_COMPILE="${base_dir}"/gcc-arm-linux-gnueabihf-4.7/bin/arm-linux-gnueabihf- #dd if=SPL of=${loopdevice} bs=1K seek=1 #dd if=u-boot.img of=${loopdevice} bs=1K seek=42 @@ -430,16 +430,16 @@ limit_cpu (){ if [ $compress = xz ]; then if [ $(arch) == 'x86_64' ]; then - echo "Compressing ${imagename}.img" + echo "Compressing ${image_name}.img" [ $(nproc) \< 3 ] || cpu_cores=3 # cpu_cores = Number of cores to use - limit_cpu pixz -p ${cpu_cores:-2} ${current_dir}/${imagename}.img # -p Nº cpu cores use - chmod 0644 ${current_dir}/${imagename}.img.xz + limit_cpu pixz -p ${cpu_cores:-2} ${current_dir}/${image_name}.img # -p Nº cpu cores use + chmod 0644 ${current_dir}/${image_name}.img.xz fi else - chmod 0644 ${current_dir}/${imagename}.img + chmod 0644 ${current_dir}/${image_name}.img fi # Clean up all the temporary build stuff and remove the directories # Comment this out to keep things around if you want to see what may have gone wrong echo "Removing temporary build files" -rm -rf "${basedir}" +rm -rf "${base_dir}" diff --git a/cubox.sh b/cubox.sh index f930e49..6db97aa 100755 --- a/cubox.sh +++ b/cubox.sh @@ -25,7 +25,7 @@ machine=$(tr -cd 'A-Za-z0-9' < /dev/urandom | head -c16 ; echo) # Custom hostname variable hostname=${2:-kali} # Custom image file name variable - MUST NOT include .img at the end -imagename=${3:-kali-linux-$1-cubox} +image_name=${3:-kali-linux-$1-cubox} # Suite to use, valid options are: # kali-rolling, kali-dev, kali-bleeding-edge, kali-dev-only, kali-experimental, kali-last-snapshot suite=${suite:-"kali-rolling"} @@ -67,20 +67,20 @@ fi # Current directory current_dir="$(pwd)" # Base directory -basedir=${current_dir}/cubox-"$1" +base_dir=${current_dir}/cubox-"$1" # Working directory -work_dir="${basedir}/kali-${architecture}" +work_dir="${base_dir}/kali-${architecture}" # Check directory build -if [ -e "${basedir}" ]; then - echo "${basedir} directory exists, will not continue" >&2 +if [ -e "${base_dir}" ]; then + echo "${base_dir} directory exists, will not continue" >&2 exit 1 elif [[ ${current_dir} =~ [[:space:]] ]]; then echo "The directory "\"${current_dir}"\" contains whitespace. Not supported." >&2 exit 1 else - echo "The basedir thinks it is: ${basedir}" - mkdir -p ${basedir} + echo "The base_dir thinks it is: ${base_dir}" + mkdir -p ${base_dir} fi components="main,contrib,non-free" @@ -327,7 +327,7 @@ deb ${mirror} ${suite} ${components//,/ } EOF # We need an older cross compiler due to kernel age -cd "${basedir}" +cd "${base_dir}" git clone --depth 1 https://gitlab.com/kalilinux/packages/gcc-arm-linux-gnueabihf-4-7.git gcc-arm-linux-gnueabihf-4.7 # Kernel section. If you want to use a custom kernel, or configuration, replace @@ -339,7 +339,7 @@ patch -p1 --no-backup-if-mismatch < ${current_dir}/patches/mac80211.patch patch -p1 --no-backup-if-mismatch < ${current_dir}/patches/remove-defined-from-timeconst.patch touch .scmversion export ARCH=arm -export CROSS_COMPILE="${basedir}"/gcc-arm-linux-gnueabihf-4.7/bin/arm-linux-gnueabihf- +export CROSS_COMPILE="${base_dir}"/gcc-arm-linux-gnueabihf-4.7/bin/arm-linux-gnueabihf- make cubox_defconfig cp .config ${work_dir}/usr/src/cubox.config make -j $(grep -c processor /proc/cpuinfo) uImage modules @@ -347,7 +347,7 @@ make modules_install INSTALL_MOD_PATH=${work_dir} cp arch/arm/boot/uImage ${work_dir}/boot make mrproper cp ../cubox.config .config -cd "${basedir}" +cd "${base_dir}" # Fix up the symlink for building external modules # kernver is used so we don't need to keep track of what the current compiled @@ -358,7 +358,7 @@ rm build rm source ln -s /usr/src/kernel build ln -s /usr/src/kernel source -cd "${basedir}" +cd "${base_dir}" # Create boot.txt file cat << EOF > ${work_dir}/boot/boot.txt @@ -396,7 +396,7 @@ EOF # Create u-boot boot script image mkimage -A arm -T script -C none -d ${work_dir}/boot/boot.txt ${work_dir}/boot/boot.scr -cd "${basedir}" +cd "${base_dir}" # Calculate the space to create the image root_size=$(du -s -B1 ${work_dir} --exclude=${work_dir}/boot | cut -f1) @@ -404,13 +404,13 @@ root_extra=$((${root_size}/1024/1000*5*1024/5)) raw_size=$(($((${free_space}*1024))+${root_extra}+$((${bootsize}*1024))+4096)) # Create the disk and partition it -echo "Creating image file ${imagename}.img" -fallocate -l $(echo ${raw_size}Ki | numfmt --from=iec-i --to=si) ${current_dir}/${imagename}.img -parted -s ${current_dir}/${imagename}.img mklabel msdos -parted -s -a minimal ${current_dir}/${imagename}.img mkpart primary $fstype 1MiB 100% +echo "Creating image file ${image_name}.img" +fallocate -l $(echo ${raw_size}Ki | numfmt --from=iec-i --to=si) ${current_dir}/${image_name}.img +parted -s ${current_dir}/${image_name}.img mklabel msdos +parted -s -a minimal ${current_dir}/${image_name}.img mkpart primary $fstype 1MiB 100% # Set the partition variables -loopdevice=`losetup -f --show ${current_dir}/${imagename}.img` +loopdevice=`losetup -f --show ${current_dir}/${image_name}.img` device=`kpartx -va ${loopdevice} | sed 's/.*\(loop[0-9]\+\)p.*/\1/g' | head -1` sleep 5 device="/dev/mapper/${device}" @@ -424,8 +424,8 @@ fi mkfs $features -t $fstype -L ROOTFS ${rootp} # Create the dirs for the partitions and mount them -mkdir -p "${basedir}"/root -mount ${rootp} "${basedir}"/root +mkdir -p "${base_dir}"/root +mount ${rootp} "${base_dir}"/root # We do this down here to get rid of the build system's resolv.conf after running through the build echo "nameserver ${nameserver}" > "${work_dir}"/etc/resolv.conf @@ -435,7 +435,7 @@ UUID=$(blkid -s UUID -o value ${rootp}) echo "UUID=$UUID / $fstype errors=remount-ro 0 1" >> ${work_dir}/etc/fstab echo "Rsyncing rootfs into image file" -rsync -HPavz -q ${work_dir}/ ${basedir}/root/ +rsync -HPavz -q ${work_dir}/ ${base_dir}/root/ # Unmount partitions sync @@ -467,16 +467,16 @@ limit_cpu (){ if [ $compress = xz ]; then if [ $(arch) == 'x86_64' ]; then - echo "Compressing ${imagename}.img" + echo "Compressing ${image_name}.img" [ $(nproc) \< 3 ] || cpu_cores=3 # cpu_cores = Number of cores to use - limit_cpu pixz -p ${cpu_cores:-2} ${current_dir}/${imagename}.img # -p Nº cpu cores use - chmod 0644 ${current_dir}/${imagename}.img.xz + limit_cpu pixz -p ${cpu_cores:-2} ${current_dir}/${image_name}.img # -p Nº cpu cores use + chmod 0644 ${current_dir}/${image_name}.img.xz fi else - chmod 0644 ${current_dir}/${imagename}.img + chmod 0644 ${current_dir}/${image_name}.img fi # Clean up all the temporary build stuff and remove the directories # Comment this out to keep things around if you want to see what may have gone wrong echo "Removing temporary build files" -rm -rf "${basedir}" +rm -rf "${base_dir}" diff --git a/gateworks-newport.sh b/gateworks-newport.sh index a335648..a86eb4a 100755 --- a/gateworks-newport.sh +++ b/gateworks-newport.sh @@ -140,7 +140,7 @@ restore_mirror # Reload sources.list #include sources.list -cd "${basedir}/" +cd "${base_dir}/" # Do the kernel stuff log "Kernel stuff" green @@ -197,14 +197,14 @@ root_extra=$((${root_size}/1024/1000*5*1024/5)) raw_size=$(($((${free_space}*1024))+${root_extra})) # Weird Boot Partition -log "Creating image file ${imagename}.img" green -wget http://dev.gateworks.com/newport/boot_firmware/firmware-newport.img -O ${current_dir}/${imagename}.img -fallocate -l $(echo ${raw_size}Ki | numfmt --from=iec-i --to=si) ${base_dir}/${imagename}.img -dd if=${base_dir}/${imagename}.img of=${current_dir}/${imagename}.img bs=16M seek=1 -echo ", +" | sfdisk -N 2 ${current_dir}/${imagename}.img +log "Creating image file ${image_name}.img" green +wget http://dev.gateworks.com/newport/boot_firmware/firmware-newport.img -O ${current_dir}/${image_name}.img +fallocate -l $(echo ${raw_size}Ki | numfmt --from=iec-i --to=si) ${base_dir}/${image_name}.img +dd if=${base_dir}/${image_name}.img of=${current_dir}/${image_name}.img bs=16M seek=1 +echo ", +" | sfdisk -N 2 ${current_dir}/${image_name}.img # Set the partition variables -loopdevice=$(losetup -f --show ${current_dir}/${imagename}.img) +loopdevice=$(losetup -f --show ${current_dir}/${image_name}.img) device=$(kpartx -va ${loopdevice} | sed 's/.*\(loop[0-9]\+\)p.*/\1/g' | head -1) sleep 5 device="/dev/mapper/${device}" @@ -220,8 +220,8 @@ mkfs -O "$features" -t "$fstype" -L ROOTFS "${rootp}" # Create the dirs for the partitions and mount them log "Create the dirs for the partitions and mount them" green -mkdir -p "${basedir}"/root -mount ${rootp} "${basedir}"/root +mkdir -p "${base_dir}"/root +mount ${rootp} "${base_dir}"/root # Create an fstab so that we don't mount / read-only log "/etc/fstab" green @@ -229,7 +229,7 @@ UUID=$(blkid -s UUID -o value ${rootp}) echo "UUID=$UUID / $fstype errors=remount-ro 0 1" >> ${work_dir}/etc/fstab log "Rsyncing rootfs into image file" green -rsync -HPavz -q ${work_dir}/ ${basedir}/root/ +rsync -HPavz -q ${work_dir}/ ${base_dir}/root/ sync # Flush buffers and bytes - this is nicked from the Devuan arm-sdk. blockdev --flushbufs "${loopdevice}" @@ -268,17 +268,17 @@ limit_cpu (){ if [ $compress = xz ]; then if [ $(arch) == 'x86_64' ]; then - log "Compressing ${imagename}.img" green + log "Compressing ${image_name}.img" green [ $(nproc) \< 3 ] || cpu_cores=3 # cpu_cores = Number of cores to use -# limit_cpu pixz -p ${cpu_cores:-2} ${current_dir}/${imagename}.img # -p Nº cpu cores use - pixz -p ${cpu_cores:-2} ${current_dir}/${imagename}.img # -p Nº cpu cores use - chmod 0644 ${current_dir}/${imagename}.img.xz +# limit_cpu pixz -p ${cpu_cores:-2} ${current_dir}/${image_name}.img # -p Nº cpu cores use + pixz -p ${cpu_cores:-2} ${current_dir}/${image_name}.img # -p Nº cpu cores use + chmod 0644 ${current_dir}/${image_name}.img.xz fi else - chmod 0644 ${current_dir}/${imagename}.img + chmod 0644 ${current_dir}/${image_name}.img fi # Clean up all the temporary build stuff and remove the directories # Comment this out to keep things around if you want to see what may have gone wrong log "Removing temporary build files" green -rm -rf "${basedir}" +rm -rf "${base_dir}" diff --git a/gateworks-ventana.sh b/gateworks-ventana.sh index f26a589..052f141 100755 --- a/gateworks-ventana.sh +++ b/gateworks-ventana.sh @@ -166,7 +166,7 @@ sed -i 's/INTERFACESv4=""/INTERFACESv4="usb0"/g' /etc/default/isc-dhcp-server systemctl enable isc-dhcp-server EOF -cd "${basedir}" +cd "${base_dir}" # Do the kernel stuff log "Kernel stuff" green @@ -212,11 +212,11 @@ make_image # Create the disk partitions log "Create the disk partitions" green -parted -s ${current_dir}/${imagename}.img mklabel msdos -parted -s -a minimal ${current_dir}/${imagename}.img mkpart primary $fstype 4MiB 100% +parted -s ${current_dir}/${image_name}.img mklabel msdos +parted -s -a minimal ${current_dir}/${image_name}.img mkpart primary $fstype 4MiB 100% # Set the partition variables -loopdevice=$(losetup --show -fP "${current_dir}/${imagename}.img") +loopdevice=$(losetup --show -fP "${current_dir}/${image_name}.img") rootp="${loopdevice}p1" # Create file systems @@ -230,8 +230,8 @@ mkfs -O "$features" -t "$fstype" -L ROOTFS "${rootp}" # Create the dirs for the partitions and mount them log "Create the dirs for the partitions and mount them" green -mkdir -p "${basedir}"/root/ -mount "${rootp}" "${basedir}"/root +mkdir -p "${base_dir}"/root/ +mount "${rootp}" "${base_dir}"/root # We do this here because we don't want to hardcode the UUID for the partition during creation # systemd doesn't seem to be generating the fstab properly for some people, so let's create one @@ -243,7 +243,7 @@ UUID=$(blkid -s UUID -o value ${rootp}) / $fstype defaults,noa EOF log "Rsyncing rootfs into image file" green -rsync -HPavz -q "${work_dir}"/ "${basedir}"/root/ +rsync -HPavz -q "${work_dir}"/ "${base_dir}"/root/ # Flush buffers and bytes - this is nicked from the Devuan arm-sdk. blockdev --flushbufs "${loopdevice}" diff --git a/mini-x.sh b/mini-x.sh index d05de0c..003e8b3 100755 --- a/mini-x.sh +++ b/mini-x.sh @@ -25,7 +25,7 @@ machine=$(tr -cd 'A-Za-z0-9' < /dev/urandom | head -c16 ; echo) # Custom hostname variable hostname=${2:-kali} # Custom image file name variable - MUST NOT include .img at the end -imagename=${3:-kali-linux-$1-mini-x} +image_name=${3:-kali-linux-$1-mini-x} # Suite to use, valid options are: # kali-rolling, kali-dev, kali-bleeding-edge, kali-dev-only, kali-experimental, kali-last-snapshot suite=${suite:-"kali-rolling"} @@ -67,20 +67,20 @@ fi # Current directory current_dir="$(pwd)" # Base directory -basedir=${current_dir}/minix-"$1" +base_dir=${current_dir}/minix-"$1" # Working directory -work_dir="${basedir}/kali-${architecture}" +work_dir="${base_dir}/kali-${architecture}" # Check directory build -if [ -e "${basedir}" ]; then - echo "${basedir} directory exists, will not continue" >&2 +if [ -e "${base_dir}" ]; then + echo "${base_dir} directory exists, will not continue" >&2 exit 1 elif [[ ${current_dir} =~ [[:space:]] ]]; then echo "The directory "\"${current_dir}"\" contains whitespace. Not supported." >&2 exit 1 else - echo "The basedir thinks it is: ${basedir}" - mkdir -p ${basedir} + echo "The base_dir thinks it is: ${base_dir}" + mkdir -p ${base_dir} fi components="main,contrib,non-free" @@ -342,13 +342,13 @@ root_extra=$((${root_size}/1024/1000*5*1024/5)) raw_size=$(($((${free_space}*1024))+${root_extra}+$((${bootsize}*1024))+4096)) # Create the disk and partition it -echo "Creating image file ${imagename}.img" -fallocate -l $(echo ${raw_size}Ki | numfmt --from=iec-i --to=si) ${current_dir}/${imagename}.img -parted -s ${current_dir}/${imagename}.img mklabel msdos -parted -s -a minimal ${current_dir}/${imagename}.img mkpart primary $fstype 4MiB 100% +echo "Creating image file ${image_name}.img" +fallocate -l $(echo ${raw_size}Ki | numfmt --from=iec-i --to=si) ${current_dir}/${image_name}.img +parted -s ${current_dir}/${image_name}.img mklabel msdos +parted -s -a minimal ${current_dir}/${image_name}.img mkpart primary $fstype 4MiB 100% # Set the partition variables -loopdevice=`losetup -f --show ${current_dir}/${imagename}.img` +loopdevice=`losetup -f --show ${current_dir}/${image_name}.img` device=`kpartx -va ${loopdevice} | sed 's/.*\(loop[0-9]\+\)p.*/\1/g' | head -1` sleep 5 device="/dev/mapper/${device}" @@ -362,8 +362,8 @@ fi mkfs $features -t $fstype -L ROOTFS ${rootp} # Create the dirs for the partitions and mount them -mkdir -p "${basedir}"/root -mount ${rootp} "${basedir}"/root +mkdir -p "${base_dir}"/root +mount ${rootp} "${base_dir}"/root # We do this down here to get rid of the build system's resolv.conf after running through the build echo "nameserver ${nameserver}" > "${work_dir}"/etc/resolv.conf @@ -373,7 +373,7 @@ UUID=$(blkid -s UUID -o value ${rootp}) echo "UUID=$UUID / $fstype errors=remount-ro 0 1" >> ${work_dir}/etc/fstab echo "Rsyncing rootfs into image file" -rsync -HPavz -q ${work_dir}/ ${basedir}/root/ +rsync -HPavz -q ${work_dir}/ ${base_dir}/root/ # Unmount partitions sync @@ -409,16 +409,16 @@ limit_cpu (){ if [ $compress = xz ]; then if [ $(arch) == 'x86_64' ]; then - echo "Compressing ${imagename}.img" + echo "Compressing ${image_name}.img" [ $(nproc) \< 3 ] || cpu_cores=3 # cpu_cores = Number of cores to use - limit_cpu pixz -p ${cpu_cores:-2} ${current_dir}/${imagename}.img # -p Nº cpu cores use - chmod 0644 ${current_dir}/${imagename}.img.xz + limit_cpu pixz -p ${cpu_cores:-2} ${current_dir}/${image_name}.img # -p Nº cpu cores use + chmod 0644 ${current_dir}/${image_name}.img.xz fi else - chmod 0644 ${current_dir}/${imagename}.img + chmod 0644 ${current_dir}/${image_name}.img fi # Clean up all the temporary build stuff and remove the directories # Comment this out to keep things around if you want to see what may have gone wrong echo "Cleaning up temporary build system" -rm -rf "${basedir}" +rm -rf "${base_dir}" diff --git a/nanopc-t.sh b/nanopc-t.sh index 37f7b7d..a339aff 100755 --- a/nanopc-t.sh +++ b/nanopc-t.sh @@ -148,7 +148,7 @@ cd ${work_dir}/usr/src/kernel/ git rev-parse HEAD > ${work_dir}/usr/src/kernel-at-commit touch .scmversion export ARCH=arm64 -#export CROSS_COMPILE="${basedir}"/gcc-arm-linux-gnueabihf-4.7/bin/arm-linux-gnueabihf- +#export CROSS_COMPILE="${base_dir}"/gcc-arm-linux-gnueabihf-4.7/bin/arm-linux-gnueabihf- export CROSS_COMPILE=aarch64-linux-gnu- patch -p1 --no-backup-if-mismatch < ${current_dir}/patches/kali-wifi-injection-4.4.patch make nanopi3_linux_defconfig @@ -192,12 +192,12 @@ make_image # Create the disk partitions log "Create the disk partitions" green -parted -s "${current_dir}"/"${imagename}".img mklabel msdos -parted -s "${current_dir}"/"${imagename}".img mkpart primary ext3 4MiB "${bootsize}"MiB -parted -s -a minimal "${current_dir}"/"${imagename}".img mkpart primary "$fstype" "${bootsize}"MiB 100% +parted -s "${current_dir}"/"${image_name}".img mklabel msdos +parted -s "${current_dir}"/"${image_name}".img mkpart primary ext3 4MiB "${bootsize}"MiB +parted -s -a minimal "${current_dir}"/"${image_name}".img mkpart primary "$fstype" "${bootsize}"MiB 100% # Set the partition variables -loopdevice=$(losetup --show -fP "${current_dir}/${imagename}.img") +loopdevice=$(losetup --show -fP "${current_dir}/${image_name}.img") bootp="${loopdevice}p1" rootp="${loopdevice}p2" @@ -213,10 +213,10 @@ mkfs -O "$features" -t "$fstype" -L ROOTFS "${rootp}" # Create the dirs for the partitions and mount them log "Create the dirs for the partitions and mount them" green -mkdir -p "${basedir}"/root/ -mount "${rootp}" "${basedir}"/root -mkdir -p "${basedir}"/root/boot -mount "${bootp}" "${basedir}"/root/boot +mkdir -p "${base_dir}"/root/ +mount "${rootp}" "${base_dir}"/root +mkdir -p "${base_dir}"/root/boot +mount "${bootp}" "${base_dir}"/root/boot # We do this here because we don't want to hardcode the UUID for the partition during creation # systemd doesn't seem to be generating the fstab properly for some people, so let's create one @@ -228,29 +228,29 @@ UUID=$(blkid -s UUID -o value ${rootp}) / $fstype defaults,noa EOF log "Rsyncing rootfs into image file" green -rsync -HPavz -q "${work_dir}"/ "${basedir}"/root/ +rsync -HPavz -q "${work_dir}"/ "${base_dir}"/root/ sync # Samsung bootloaders must be signed # These are the same steps that are done by # https://github.com/friendlyarm/sd-fuse_nanopi2/blob/master/fusing.sh log "Samsung bootloaders" green -mkdir -p "${basedir}"/bootloader/ -cd "${basedir}"/bootloader/ -wget 'https://github.com/friendlyarm/sd-fuse_s5p6818/blob/master/prebuilt/bl1-mmcboot.bin?raw=true' -O "${basedir}"/bootloader/bl1-mmcboot.bin -wget 'https://github.com/friendlyarm/sd-fuse_s5p6818/blob/master/prebuilt/fip-loader.img?raw=true' -O "${basedir}"/bootloader/fip-loader.img -wget 'https://github.com/friendlyarm/sd-fuse_s5p6818/blob/master/prebuilt/fip-secure.img?raw=true' -O "${basedir}"/bootloader/fip-secure.img -wget 'https://github.com/friendlyarm/sd-fuse_s5p6818/blob/master/prebuilt/fip-nonsecure.img?raw=true' -O "${basedir}"/bootloader/fip-nonsecure.img -wget 'https://github.com/friendlyarm/sd-fuse_s5p6818/blob/master/tools/fw_printenv?raw=true' -O "${basedir}"/bootloader/fw_printenv -chmod 0755 "${basedir}"/bootloader/fw_printenv -ln -s "${basedir}"/bootloader/fw_printenv "${basedir}"/bootloader/fw_setenv +mkdir -p "${base_dir}"/bootloader/ +cd "${base_dir}"/bootloader/ +wget 'https://github.com/friendlyarm/sd-fuse_s5p6818/blob/master/prebuilt/bl1-mmcboot.bin?raw=true' -O "${base_dir}"/bootloader/bl1-mmcboot.bin +wget 'https://github.com/friendlyarm/sd-fuse_s5p6818/blob/master/prebuilt/fip-loader.img?raw=true' -O "${base_dir}"/bootloader/fip-loader.img +wget 'https://github.com/friendlyarm/sd-fuse_s5p6818/blob/master/prebuilt/fip-secure.img?raw=true' -O "${base_dir}"/bootloader/fip-secure.img +wget 'https://github.com/friendlyarm/sd-fuse_s5p6818/blob/master/prebuilt/fip-nonsecure.img?raw=true' -O "${base_dir}"/bootloader/fip-nonsecure.img +wget 'https://github.com/friendlyarm/sd-fuse_s5p6818/blob/master/tools/fw_printenv?raw=true' -O "${base_dir}"/bootloader/fw_printenv +chmod 0755 "${base_dir}"/bootloader/fw_printenv +ln -s "${base_dir}"/bootloader/fw_printenv "${base_dir}"/bootloader/fw_setenv -dd if="${basedir}"/bootloader/bl1-mmcboot.bin of=${loopdevice} bs=512 seek=1 -dd if="${basedir}"/bootloader/fip-loader.img of=${loopdevice} bs=512 seek=129 -dd if="${basedir}"/bootloader/fip-secure.img of=${loopdevice} bs=512 seek=769 -dd if="${basedir}"/bootloader/fip-nonsecure.img of=${loopdevice} bs=512 seek=3841 +dd if="${base_dir}"/bootloader/bl1-mmcboot.bin of=${loopdevice} bs=512 seek=1 +dd if="${base_dir}"/bootloader/fip-loader.img of=${loopdevice} bs=512 seek=129 +dd if="${base_dir}"/bootloader/fip-secure.img of=${loopdevice} bs=512 seek=769 +dd if="${base_dir}"/bootloader/fip-nonsecure.img of=${loopdevice} bs=512 seek=3841 -cat << EOF > "${basedir}"/bootloader/env.conf +cat << EOF > "${base_dir}"/bootloader/env.conf # U-Boot environment for Debian, Ubuntu # # Copyright (C) Guangzhou FriendlyARM Computer Tech. Co., Ltd diff --git a/nanopi-neo-plus2-minimal.sh b/nanopi-neo-plus2-minimal.sh index 085166e..67ef7e3 100755 --- a/nanopi-neo-plus2-minimal.sh +++ b/nanopi-neo-plus2-minimal.sh @@ -330,11 +330,11 @@ make_image # Create the disk partitions log "Create the disk partitions" green -parted -s ${current_dir}/${imagename}.img mklabel msdos -parted -s -a minimal ${current_dir}/${imagename}.img mkpart primary $fstype 32MiB 100% +parted -s ${current_dir}/${image_name}.img mklabel msdos +parted -s -a minimal ${current_dir}/${image_name}.img mkpart primary $fstype 32MiB 100% # Set the partition variables -loopdevice=$(losetup --show -fP "${current_dir}/${imagename}.img") +loopdevice=$(losetup --show -fP "${current_dir}/${image_name}.img") rootp="${loopdevice}p1" # Create file systems @@ -348,8 +348,8 @@ mkfs -O "$features" -t "$fstype" -L ROOTFS "${rootp}" # Create the dirs for the partitions and mount them log "Create the dirs for the partitions and mount them" green -mkdir -p "${basedir}"/root/ -mount "${rootp}" "${basedir}"/root +mkdir -p "${base_dir}"/root/ +mount "${rootp}" "${base_dir}"/root # We do this here because we don't want to hardcode the UUID for the partition during creation # systemd doesn't seem to be generating the fstab properly for some people, so let's create one @@ -361,11 +361,11 @@ UUID=$(blkid -s UUID -o value ${rootp}) / $fstype defaults,noa EOF log "Rsyncing rootfs into image file" green -rsync -HPavz -q "${work_dir}"/ "${basedir}"/root/ +rsync -HPavz -q "${work_dir}"/ "${base_dir}"/root/ sync log "u-Boot" green -cd "${basedir}" +cd "${base_dir}" git clone --depth 1 https://github.com/friendlyarm/u-boot.git cd u-boot git checkout sunxi-v2017.x diff --git a/nanopi-neo-plus2.sh b/nanopi-neo-plus2.sh index 80202d0..b17d509 100755 --- a/nanopi-neo-plus2.sh +++ b/nanopi-neo-plus2.sh @@ -344,11 +344,11 @@ make_image # Create the disk partitions log "Create the disk partitions" green -parted -s ${current_dir}/${imagename}.img mklabel msdos -parted -s -a minimal ${current_dir}/${imagename}.img mkpart primary $fstype 32MiB 100% +parted -s ${current_dir}/${image_name}.img mklabel msdos +parted -s -a minimal ${current_dir}/${image_name}.img mkpart primary $fstype 32MiB 100% # Set the partition variables -loopdevice=$(losetup --show -fP "${current_dir}/${imagename}.img") +loopdevice=$(losetup --show -fP "${current_dir}/${image_name}.img") rootp="${loopdevice}p1" # Create file systems @@ -362,8 +362,8 @@ mkfs -O "$features" -t "$fstype" -L ROOTFS "${rootp}" # Create the dirs for the partitions and mount them log "Create the dirs for the partitions and mount them" green -mkdir -p "${basedir}"/root/ -mount "${rootp}" "${basedir}"/root +mkdir -p "${base_dir}"/root/ +mount "${rootp}" "${base_dir}"/root # We do this here because we don't want to hardcode the UUID for the partition during creation # systemd doesn't seem to be generating the fstab properly for some people, so let's create one @@ -375,11 +375,11 @@ UUID=$(blkid -s UUID -o value ${rootp}) / $fstype defaults,noa EOF log "Rsyncing rootfs into image file" green -rsync -HPavz -q "${work_dir}"/ "${basedir}"/root/ +rsync -HPavz -q "${work_dir}"/ "${base_dir}"/root/ sync log "u-Boot" green -cd "${basedir}" +cd "${base_dir}" git clone --depth 1 https://github.com/friendlyarm/u-boot.git cd u-boot/ git checkout sunxi-v2017.x diff --git a/nanopi2.sh b/nanopi2.sh index 45cae7f..3289bc6 100755 --- a/nanopi2.sh +++ b/nanopi2.sh @@ -25,7 +25,7 @@ machine=$(tr -cd 'A-Za-z0-9' < /dev/urandom | head -c16 ; echo) # Custom hostname variable hostname=${2:-kali} # Custom image file name variable - MUST NOT include .img at the end -imagename=${3:-kali-linux-$1-nanopi2} +image_name=${3:-kali-linux-$1-nanopi2} # Suite to use, valid options are: # kali-rolling, kali-dev, kali-bleeding-edge, kali-dev-only, kali-experimental, kali-last-snapshot suite=${suite:-"kali-rolling"} @@ -67,20 +67,20 @@ fi # Current directory current_dir="$(pwd)" # Base directory -basedir=${current_dir}/nanopi2-"$1" +base_dir=${current_dir}/nanopi2-"$1" # Working directory -work_dir="${basedir}/kali-${architecture}" +work_dir="${base_dir}/kali-${architecture}" # Check directory build -if [ -e "${basedir}" ]; then - echo "${basedir} directory exists, will not continue" >&2 +if [ -e "${base_dir}" ]; then + echo "${base_dir} directory exists, will not continue" >&2 exit 1 elif [[ ${current_dir} =~ [[:space:]] ]]; then echo "The directory "\"${current_dir}"\" contains whitespace. Not supported." >&2 exit 1 else - echo "The basedir thinks it is: ${basedir}" - mkdir -p ${basedir} + echo "The base_dir thinks it is: ${base_dir}" + mkdir -p ${base_dir} fi components="main,contrib,non-free" @@ -336,7 +336,7 @@ deb ${mirror} ${suite} ${components//,/ } EOF # We need an older gcc because of kernel age -cd "${basedir}" +cd "${base_dir}" git clone --depth 1 https://gitlab.com/kalilinux/packages/gcc-arm-linux-gnueabihf-4-7.git gcc-arm-linux-gnueabihf-4.7 # Kernel section. If you want to use a custom kernel, or configuration, replace @@ -346,7 +346,7 @@ cd ${work_dir}/usr/src/kernel git rev-parse HEAD > ${work_dir}/usr/src/kernel-at-commit touch .scmversion export ARCH=arm -export CROSS_COMPILE="${basedir}"/gcc-arm-linux-gnueabihf-4.7/bin/arm-linux-gnueabihf- +export CROSS_COMPILE="${base_dir}"/gcc-arm-linux-gnueabihf-4.7/bin/arm-linux-gnueabihf- patch -p1 --no-backup-if-mismatch < ${current_dir}/patches/mac80211.patch # Ugh, this patch is needed because the ethernet driver uses parts of netdev # from a newer kernel? @@ -382,7 +382,7 @@ cp arch/arm/boot/uImage ${work_dir}/boot/uImage.hdmi #cp arch/arm/boot/uImage ${work_dir}/boot/uImage-s70 #cp arch/arm/boot/uImage ${work_dir}/boot/uImage.lcd #cp arch/arm/boot/uImage ${work_dir}/boot/uImage -cd "${basedir}" +cd "${base_dir}" # FriendlyARM suggest using backports for wifi with their devices, and the # recommended version is the 4.4.2 @@ -399,13 +399,13 @@ cd .. #make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- KLIB_BUILD=${work_dir}/usr/src/kernel KLIB=${work_dir} INSTALL_MOD_PATH=${work_dir} install #make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- KLIB_BUILD=${work_dir}/usr/src/kernel KLIB=${work_dir} mrproper #cp ${current_dir}/kernel-configs/backports.config .config -XCROSS="${basedir}"/gcc-arm-linux-gnueabihf-4.7/bin/arm-linux-gnueabihf- ANDROID=n ./build.sh -k ${work_dir}/usr/src/kernel -c nanopi2 -o ${work_dir} -cd "${basedir}" +XCROSS="${base_dir}"/gcc-arm-linux-gnueabihf-4.7/bin/arm-linux-gnueabihf- ANDROID=n ./build.sh -k ${work_dir}/usr/src/kernel -c nanopi2 -o ${work_dir} +cd "${base_dir}" # Now we clean up the kernel build cd ${work_dir}/usr/src/kernel make mrproper -cd "${basedir}" +cd "${base_dir}" # Copy over the firmware for the nanopi2/3 wifi # At some point, nexmon could work for the device, but the support would need to @@ -419,7 +419,7 @@ wget https://raw.githubusercontent.com/friendlyarm/android_vendor_broadcom_nanop wget https://raw.githubusercontent.com/friendlyarm/android_vendor_broadcom_nanopi2/nanopi2-lollipop-mr1/proprietary/bcm43438a0.hcd -O ${work_dir}/lib/firmware/ap6212/bcm43438a0.hcd wget https://raw.githubusercontent.com/friendlyarm/android_vendor_broadcom_nanopi2/nanopi2-lollipop-mr1/proprietary/bcm43438a1.hcd -O ${work_dir}/lib/firmware/ap6212/bcm43438a1.hcd wget https://raw.githubusercontent.com/friendlyarm/android_vendor_broadcom_nanopi2/nanopi2-lollipop-mr1/proprietary/config_ap6212.txt -O ${work_dir}/lib/firmware/ap6212/config.txt -cd "${basedir}" +cd "${base_dir}" # Fix up the symlink for building external modules # kernver is used so we don't need to keep track of what the current compiled @@ -430,7 +430,7 @@ rm build rm source ln -s /usr/src/kernel build ln -s /usr/src/kernel source -cd "${basedir}" +cd "${base_dir}" # Calculate the space to create the image root_size=$(du -s -B1 ${work_dir} --exclude=${work_dir}/boot | cut -f1) @@ -438,14 +438,14 @@ root_extra=$((${root_size}/1024/1000*5*1024/5)) raw_size=$(($((${free_space}*1024))+${root_extra}+$((${bootsize}*1024))+4096)) # Create the disk and partition it -echo "Creating image file ${imagename}.img" -fallocate -l $(echo ${raw_size}Ki | numfmt --from=iec-i --to=si) ${current_dir}/${imagename}.img -parted -s ${current_dir}/${imagename}.img mklabel msdos -parted -s ${current_dir}/${imagename}.img mkpart primary ext3 1MiB ${bootsize}MiB -parted -s -a minimal ${current_dir}/${imagename}.img mkpart primary $fstype ${bootsize}MiB 100% +echo "Creating image file ${image_name}.img" +fallocate -l $(echo ${raw_size}Ki | numfmt --from=iec-i --to=si) ${current_dir}/${image_name}.img +parted -s ${current_dir}/${image_name}.img mklabel msdos +parted -s ${current_dir}/${image_name}.img mkpart primary ext3 1MiB ${bootsize}MiB +parted -s -a minimal ${current_dir}/${image_name}.img mkpart primary $fstype ${bootsize}MiB 100% # Set the partition variables -loopdevice=`losetup -f --show ${current_dir}/${imagename}.img` +loopdevice=`losetup -f --show ${current_dir}/${image_name}.img` device=`kpartx -va ${loopdevice} | sed 's/.*\(loop[0-9]\+\)p.*/\1/g' | head -1` sleep 5 device="/dev/mapper/${device}" @@ -462,10 +462,10 @@ fi mkfs $features -t $fstype -L ROOTFS ${rootp} # Create the dirs for the partitions and mount them -mkdir -p "${basedir}"/root -mount ${rootp} "${basedir}"/root -mkdir -p "${basedir}"/root/boot -mount ${bootp} "${basedir}"/root/boot +mkdir -p "${base_dir}"/root +mount ${rootp} "${base_dir}"/root +mkdir -p "${base_dir}"/root/boot +mount ${bootp} "${base_dir}"/root/boot # We do this down here to get rid of the build system's resolv.conf after running through the build echo "nameserver ${nameserver}" > "${work_dir}"/etc/resolv.conf @@ -475,7 +475,7 @@ UUID=$(blkid -s UUID -o value ${rootp}) echo "UUID=$UUID / $fstype errors=remount-ro 0 1" >> ${work_dir}/etc/fstab echo "Rsyncing rootfs into image file" -rsync -HPavz -q ${work_dir}/ ${basedir}/root/ +rsync -HPavz -q ${work_dir}/ ${base_dir}/root/ # Unmount partitions sync @@ -488,8 +488,8 @@ kpartx -dv ${loopdevice} # https://github.com/friendlyarm/sd-fuse_nanopi2/blob/master/fusing.sh # Download the latest prebuilt from the above url -mkdir -p "${basedir}"/bootloader -cd "${basedir}"/bootloader +mkdir -p "${base_dir}"/bootloader +cd "${base_dir}"/bootloader wget 'https://github.com/friendlyarm/sd-fuse_nanopi2/blob/96e1ba9603d237d0169485801764c5ce9591bf5e/prebuilt/2ndboot.bin?raw=true' -O 2ndboot.bin wget 'https://github.com/friendlyarm/sd-fuse_nanopi2/blob/96e1ba9603d237d0169485801764c5ce9591bf5e/prebuilt/boot.TBI?raw=true' -O boot.TBI wget 'https://github.com/friendlyarm/sd-fuse_nanopi2/blob/96e1ba9603d237d0169485801764c5ce9591bf5e/prebuilt/bootloader' -O bootloader @@ -505,7 +505,7 @@ dd if=2ndboot.bin of=${loopdevice} bs=512 seek=1 dd if=boot.TBI of=${loopdevice} bs=512 seek=64 count=1 dd if=bootloader of=${loopdevice} bs=512 seek=65 -cat << EOF > ${basedir}/bootloader/env.conf +cat << EOF > ${base_dir}/bootloader/env.conf # U-Boot environment for Debian, Ubuntu # # Copyright (C) Guangzhou FriendlyARM Computer Tech. Co., Ltd @@ -520,7 +520,7 @@ EOF sync -cd "${basedir}" +cd "${base_dir}" losetup -d ${loopdevice} @@ -548,16 +548,16 @@ limit_cpu (){ if [ $compress = xz ]; then if [ $(arch) == 'x86_64' ]; then - echo "Compressing ${imagename}.img" + echo "Compressing ${image_name}.img" [ $(nproc) \< 3 ] || cpu_cores=3 # cpu_cores = Number of cores to use - limit_cpu pixz -p ${cpu_cores:-2} ${current_dir}/${imagename}.img # -p Nº cpu cores use - chmod 0644 ${current_dir}/${imagename}.img.xz + limit_cpu pixz -p ${cpu_cores:-2} ${current_dir}/${image_name}.img # -p Nº cpu cores use + chmod 0644 ${current_dir}/${image_name}.img.xz fi else - chmod 0644 ${current_dir}/${imagename}.img + chmod 0644 ${current_dir}/${image_name}.img fi # Clean up all the temporary build stuff and remove the directories # Comment this out to keep things around if you want to see what may have gone wrong echo "Clean up the build system" -rm -rf "${basedir}" +rm -rf "${base_dir}" diff --git a/odroid-c.sh b/odroid-c.sh index 57f2a89..5e56650 100755 --- a/odroid-c.sh +++ b/odroid-c.sh @@ -25,7 +25,7 @@ machine=$(tr -cd 'A-Za-z0-9' < /dev/urandom | head -c16 ; echo) # Custom hostname variable hostname=${2:-kali} # Custom image file name variable - MUST NOT include .img at the end -imagename=${3:-kali-linux-$1-odroid-c} +image_name=${3:-kali-linux-$1-odroid-c} # Suite to use, valid options are: # kali-rolling, kali-dev, kali-bleeding-edge, kali-dev-only, kali-experimental, kali-last-snapshot suite=${suite:-"kali-rolling"} @@ -67,20 +67,20 @@ fi # Current directory current_dir="$(pwd)" # Base directory -basedir=${current_dir}/odroidc-"$1" +base_dir=${current_dir}/odroidc-"$1" # Working directory -work_dir="${basedir}/kali-${architecture}" +work_dir="${base_dir}/kali-${architecture}" # Check directory build -if [ -e "${basedir}" ]; then - echo "${basedir} directory exists, will not continue" >&2 +if [ -e "${base_dir}" ]; then + echo "${base_dir} directory exists, will not continue" >&2 exit 1 elif [[ ${current_dir} =~ [[:space:]] ]]; then echo "The directory "\"${current_dir}"\" contains whitespace. Not supported." >&2 exit 1 else - echo "The basedir thinks it is: ${basedir}" - mkdir -p ${basedir} + echo "The base_dir thinks it is: ${base_dir}" + mkdir -p ${base_dir} fi components="main,contrib,non-free" @@ -331,7 +331,7 @@ deb ${mirror} ${suite} ${components//,/ } EOF # Clone an older cross compiler to build the older u-boot/kernel -cd "${basedir}" +cd "${base_dir}" git clone --depth 1 https://gitlab.com/kalilinux/packages/gcc-arm-linux-gnueabihf-4-7.git gcc-arm-linux-gnueabihf-4.7 # Kernel section. If you want to use a custom kernel, or configuration, replace @@ -342,7 +342,7 @@ git rev-parse HEAD > ${work_dir}/usr/src/kernel-at-commit touch .scmversion export ARCH=arm # NOTE: 3.8 now works with a 4.8 compiler, 3.4 does not! -export CROSS_COMPILE="${basedir}"/gcc-arm-linux-gnueabihf-4.7/bin/arm-linux-gnueabihf- +export CROSS_COMPILE="${base_dir}"/gcc-arm-linux-gnueabihf-4.7/bin/arm-linux-gnueabihf- patch -p1 --no-backup-if-mismatch < ${current_dir}/patches/mac80211-backports.patch patch -p1 --no-backup-if-mismatch < ${current_dir}/patches/0001-wireless-carl9170-Enable-sniffer-mode-promisc-flag-t.patch make odroidc_defconfig @@ -354,7 +354,7 @@ cp arch/arm/boot/uImage ${work_dir}/boot/ cp arch/arm/boot/dts/meson8b_odroidc.dtb ${work_dir}/boot/ make mrproper cp ../odroidc.config .config -cd "${basedir}" +cd "${base_dir}" # Fix up the symlink for building external modules # kernver is used so we don't need to keep track of what the current compiled @@ -365,7 +365,7 @@ rm build rm source ln -s /usr/src/kernel build ln -s /usr/src/kernel source -cd "${basedir}" +cd "${base_dir}" # Create a boot.ini file with possible options if people want to change them cat << EOF > ${work_dir}/boot/boot.ini @@ -581,14 +581,14 @@ root_extra=$((${root_size}/1024/1000*5*1024/5)) raw_size=$(($((${free_space}*1024))+${root_extra}+$((${bootsize}*1024))+4096)) # Create the disk and partition it -echo "Creating image file ${imagename}.img" -fallocate -l $(echo ${raw_size}Ki | numfmt --from=iec-i --to=si) ${current_dir}/${imagename}.img -parted -s ${current_dir}/${imagename}.img mklabel msdos -parted -s ${current_dir}/${imagename}.img mkpart primary fat32 4MiB ${bootsize}MiB -parted -s -a minimal ${current_dir}/${imagename}.img mkpart primary $fstype ${bootsize}MiB 100% +echo "Creating image file ${image_name}.img" +fallocate -l $(echo ${raw_size}Ki | numfmt --from=iec-i --to=si) ${current_dir}/${image_name}.img +parted -s ${current_dir}/${image_name}.img mklabel msdos +parted -s ${current_dir}/${image_name}.img mkpart primary fat32 4MiB ${bootsize}MiB +parted -s -a minimal ${current_dir}/${image_name}.img mkpart primary $fstype ${bootsize}MiB 100% # Set the partition variables -loopdevice=`losetup -f --show ${current_dir}/${imagename}.img` +loopdevice=`losetup -f --show ${current_dir}/${image_name}.img` device=`kpartx -va ${loopdevice} | sed 's/.*\(loop[0-9]\+\)p.*/\1/g' | head -1` sleep 5 device="/dev/mapper/${device}" @@ -605,10 +605,10 @@ fi mkfs $features -t $fstype -L ROOTFS ${rootp} # Create the dirs for the partitions and mount them -mkdir -p "${basedir}"/root -mount ${rootp} "${basedir}"/root -mkdir -p "${basedir}"/root/boot -mount ${bootp} "${basedir}"/root/boot +mkdir -p "${base_dir}"/root +mount ${rootp} "${base_dir}"/root +mkdir -p "${base_dir}"/root/boot +mount ${bootp} "${base_dir}"/root/boot # We do this down here to get rid of the build system's resolv.conf after running through the build echo "nameserver ${nameserver}" > "${work_dir}"/etc/resolv.conf @@ -618,7 +618,7 @@ UUID=$(blkid -s UUID -o value ${rootp}) echo "UUID=$UUID / $fstype errors=remount-ro 0 1" >> ${work_dir}/etc/fstab echo "Rsyncing rootfs into image file" -rsync -HPavz -q ${work_dir}/ ${basedir}/root/ +rsync -HPavz -q ${work_dir}/ ${base_dir}/root/ # Unmount partitions sync @@ -626,22 +626,22 @@ umount ${bootp} umount ${rootp} kpartx -dv ${loopdevice} -cd ${basedir} +cd ${base_dir} # Build the latest u-boot bootloader, and then use the Hardkernel script to fuse # it to the image. This is required because of a requirement that the # bootloader be signed git clone --depth 1 https://github.com/hardkernel/u-boot -b odroidc-v2011.03 -cd ${basedir}/u-boot +cd ${base_dir}/u-boot # https://code.google.com/p/chromium/issues/detail?id=213120 sed -i -e "s/soft-float/float-abi=hard -mfpu=vfpv3/g" \ arch/arm/cpu/armv7/config.mk -make CROSS_COMPILE="${basedir}"/gcc-arm-linux-gnueabihf-4.7/bin/arm-linux-gnueabihf- odroidc_config -make CROSS_COMPILE="${basedir}"/gcc-arm-linux-gnueabihf-4.7/bin/arm-linux-gnueabihf- -j $(grep -c processor /proc/cpuinfo) +make CROSS_COMPILE="${base_dir}"/gcc-arm-linux-gnueabihf-4.7/bin/arm-linux-gnueabihf- odroidc_config +make CROSS_COMPILE="${base_dir}"/gcc-arm-linux-gnueabihf-4.7/bin/arm-linux-gnueabihf- -j $(grep -c processor /proc/cpuinfo) cd sd_fuse sh sd_fusing.sh ${loopdevice} -cd "${basedir}" +cd "${base_dir}" losetup -d ${loopdevice} @@ -669,16 +669,16 @@ limit_cpu (){ if [ $compress = xz ]; then if [ $(arch) == 'x86_64' ]; then - echo "Compressing ${imagename}.img" + echo "Compressing ${image_name}.img" [ $(nproc) \< 3 ] || cpu_cores=3 # cpu_cores = Number of cores to use - limit_cpu pixz -p ${cpu_cores:-2} ${current_dir}/${imagename}.img # -p Nº cpu cores use - chmod 0644 ${current_dir}/${imagename}.img.xz + limit_cpu pixz -p ${cpu_cores:-2} ${current_dir}/${image_name}.img # -p Nº cpu cores use + chmod 0644 ${current_dir}/${image_name}.img.xz fi else - chmod 0644 ${current_dir}/${imagename}.img + chmod 0644 ${current_dir}/${image_name}.img fi # Clean up all the temporary build stuff and remove the directories # Comment this out to keep things around if you want to see what may have gone wrong echo "Clean up the build system" -rm -rf "${basedir}" +rm -rf "${base_dir}" diff --git a/odroid-c2.sh b/odroid-c2.sh index 2f6d73a..7139da0 100755 --- a/odroid-c2.sh +++ b/odroid-c2.sh @@ -184,11 +184,11 @@ make_image # Create the disk partitions log "Create the disk partitions" green -parted -s ${current_dir}/${imagename}.img mklabel msdos -parted -s -a minimal ${current_dir}/${imagename}.img mkpart primary $fstype 32MiB 100% +parted -s ${current_dir}/${image_name}.img mklabel msdos +parted -s -a minimal ${current_dir}/${image_name}.img mkpart primary $fstype 32MiB 100% # Set the partition variables -loopdevice=$(losetup --show -fP "${current_dir}/${imagename}.img") +loopdevice=$(losetup --show -fP "${current_dir}/${image_name}.img") rootp="${loopdevice}p1" # Create file systems @@ -202,8 +202,8 @@ mkfs -O "$features" -t "$fstype" -L ROOTFS "${rootp}" # Create the dirs for the partitions and mount them log "Create the dirs for the partitions and mount them" green -mkdir -p "${basedir}"/root/ -mount "${rootp}" "${basedir}"/root +mkdir -p "${base_dir}"/root/ +mount "${rootp}" "${base_dir}"/root # We do this here because we don't want to hardcode the UUID for the partition during creation # systemd doesn't seem to be generating the fstab properly for some people, so let's create one @@ -221,7 +221,7 @@ sed -i -e "0,/root=.*/s//root=UUID=$(blkid -s UUID -o value ${rootp}) rootfstype sed -i -e "s/Debian GNU\/Linux/Kali Linux/g" ${work_dir}/boot/extlinux/extlinux.conf log "Rsyncing rootfs into image file" green -rsync -HPavz -q "${work_dir}"/ "${basedir}"/root/ +rsync -HPavz -q "${work_dir}"/ "${base_dir}"/root/ sync # We are gonna use as much open source as we can here, hopefully we end up with a nice @@ -235,20 +235,20 @@ unset ARCH unset CROSS_COMPILE log "Bootloader" green -mkdir -p ${basedir}/bootloader -cd ${basedir}/bootloader +mkdir -p ${base_dir}/bootloader +cd ${base_dir}/bootloader git clone --depth 1 https://github.com/afaerber/meson-tools --depth 1 git clone --depth 1 git://git.denx.de/u-boot git clone --depth 1 https://github.com/hardkernel/u-boot -b odroidc2-v2015.01 u-boot-hk # First things first, let's build the meson-tools, of which, we only really need amlbootsig -cd ${basedir}/bootloader/meson-tools/ +cd ${base_dir}/bootloader/meson-tools/ make # Now we need to build fip_create -cd ${basedir}/bootloader/u-boot-hk/tools/fip_create +cd ${base_dir}/bootloader/u-boot-hk/tools/fip_create HOSTCC=cc HOSTLD=ld make -cd ${basedir}/bootloader/u-boot/ +cd ${base_dir}/bootloader/u-boot/ make ARCH=arm CROSS_COMPILE=aarch64-linux-gnu- odroid-c2_defconfig make ARCH=arm CROSS_COMPILE=aarch64-linux-gnu- @@ -261,7 +261,7 @@ make ARCH=arm CROSS_COMPILE=aarch64-linux-gnu- # for the inspirations for it. Specifically Adrian's posts got us closest # This is funky, but in the end, it should do the right thing -cd ${basedir}/bootloader/ +cd ${base_dir}/bootloader/ # Create the fip.bin ./u-boot-hk/tools/fip_create/fip_create --bl30 ./u-boot-hk/fip/gxb/bl30.bin \ --bl301 ./u-boot-hk/fip/gxb/bl301.bin --bl31 ./u-boot-hk/fip/gxb/bl31.bin \ diff --git a/odroid-u2.sh b/odroid-u2.sh index bb2c8a2..ee3af10 100755 --- a/odroid-u2.sh +++ b/odroid-u2.sh @@ -25,7 +25,7 @@ machine=$(tr -cd 'A-Za-z0-9' < /dev/urandom | head -c16 ; echo) # Custom hostname variable hostname=${2:-kali} # Custom image file name variable - MUST NOT include .img at the end -imagename=${3:-kali-linux-$1-odroid-u} +image_name=${3:-kali-linux-$1-odroid-u} # Suite to use, valid options are: # kali-rolling, kali-dev, kali-bleeding-edge, kali-dev-only, kali-experimental, kali-last-snapshot suite=${suite:-"kali-rolling"} @@ -67,20 +67,20 @@ fi # Current directory current_dir="$(pwd)" # Base directory -basedir=${current_dir}/odroidu2-"$1" +base_dir=${current_dir}/odroidu2-"$1" # Working directory -work_dir="${basedir}/kali-${architecture}" +work_dir="${base_dir}/kali-${architecture}" # Check directory build -if [ -e "${basedir}" ]; then - echo "${basedir} directory exists, will not continue" >&2 +if [ -e "${base_dir}" ]; then + echo "${base_dir} directory exists, will not continue" >&2 exit 1 elif [[ ${current_dir} =~ [[:space:]] ]]; then echo "The directory "\"${current_dir}"\" contains whitespace. Not supported." >&2 exit 1 else - echo "The basedir thinks it is: ${basedir}" - mkdir -p ${basedir} + echo "The base_dir thinks it is: ${base_dir}" + mkdir -p ${base_dir} fi components="main,contrib,non-free" @@ -372,7 +372,7 @@ Mode 0666 EndSection EOF -cd "${basedir}" +cd "${base_dir}" git clone --depth 1 https://gitlab.com/kalilinux/packages/gcc-arm-linux-gnueabihf-4-7.git gcc-arm-linux-gnueabihf-4.7 # Kernel section. If you want to use a custom kernel, or configuration, replace @@ -383,7 +383,7 @@ git rev-parse HEAD > ${work_dir}/usr/src/kernel-at-commit touch .scmversion export ARCH=arm # NOTE: 3.8 now works with a 4.8 compiler, 3.4 does not! -export CROSS_COMPILE="${basedir}"/gcc-arm-linux-gnueabihf-4.7/bin/arm-linux-gnueabihf- +export CROSS_COMPILE="${base_dir}"/gcc-arm-linux-gnueabihf-4.7/bin/arm-linux-gnueabihf- patch -p1 --no-backup-if-mismatch < ${current_dir}/patches/mac80211.patch patch -p1 --no-backup-if-mismatch < ${current_dir}/patches/0001-wireless-carl9170-Enable-sniffer-mode-promisc-flag-t.patch make odroidu_defconfig @@ -393,7 +393,7 @@ make modules_install INSTALL_MOD_PATH=${work_dir} cp arch/arm/boot/zImage ${work_dir}/boot make mrproper cp ../odroidu.config .config -cd "${basedir}" +cd "${base_dir}" # Fix up the symlink for building external modules # kernver is used so we don't need to keep track of what the current compiled @@ -404,7 +404,7 @@ rm build rm source ln -s /usr/src/kernel build ln -s /usr/src/kernel source -cd "${basedir}" +cd "${base_dir}" # Create boot.txt file cat << EOF > ${work_dir}/boot/boot.txt @@ -418,7 +418,7 @@ EOF # Create u-boot boot script image mkimage -A arm -T script -C none -d ${work_dir}/boot/boot.txt ${work_dir}/boot/boot.scr -cd "${basedir}" +cd "${base_dir}" # Calculate the space to create the image root_size=$(du -s -B1 ${work_dir} --exclude=${work_dir}/boot | cut -f1) @@ -426,14 +426,14 @@ root_extra=$((${root_size}/1024/1000*5*1024/5)) raw_size=$(($((${free_space}*1024))+${root_extra}+$((${bootsize}*1024))+4096)) # Create the disk and partition it -echo "Creating image file ${imagename}.img" -fallocate -l $(echo ${raw_size}Ki | numfmt --from=iec-i --to=si) ${current_dir}/${imagename}.img -parted -s ${current_dir}/${imagename}.img mklabel msdos -parted -s ${current_dir}/${imagename}.img mkpart primary fat32 1MiB ${bootsize}MiB -parted -s -a minimal ${current_dir}/${imagename}.img mkpart primary $fstype ${bootsize}MiB 100% +echo "Creating image file ${image_name}.img" +fallocate -l $(echo ${raw_size}Ki | numfmt --from=iec-i --to=si) ${current_dir}/${image_name}.img +parted -s ${current_dir}/${image_name}.img mklabel msdos +parted -s ${current_dir}/${image_name}.img mkpart primary fat32 1MiB ${bootsize}MiB +parted -s -a minimal ${current_dir}/${image_name}.img mkpart primary $fstype ${bootsize}MiB 100% # Set the partition variables -loopdevice=`losetup -f --show ${current_dir}/${imagename}.img` +loopdevice=`losetup -f --show ${current_dir}/${image_name}.img` device=`kpartx -va ${loopdevice} | sed 's/.*\(loop[0-9]\+\)p.*/\1/g' | head -1` sleep 5 device="/dev/mapper/${device}" @@ -451,16 +451,16 @@ fi mkfs $features -t $fstype -L ROOTFS ${rootp} # Create the dirs for the partitions and mount them -mkdir -p "${basedir}"/root -mount ${rootp} "${basedir}"/root -mkdir -p "${basedir}"/root/boot -mount ${bootp} "${basedir}"/root/boot +mkdir -p "${base_dir}"/root +mount ${rootp} "${base_dir}"/root +mkdir -p "${base_dir}"/root/boot +mount ${bootp} "${base_dir}"/root/boot # We do this down here to get rid of the build system's resolv.conf after running through the build echo "nameserver ${nameserver}" > "${work_dir}"/etc/resolv.conf echo "Rsyncing rootfs into image file" -rsync -HPavz -q ${work_dir}/ ${basedir}/root/ +rsync -HPavz -q ${work_dir}/ ${base_dir}/root/ # Unmount partitions sync @@ -468,23 +468,23 @@ umount -l ${bootp} umount -l ${rootp} kpartx -dv ${loopdevice} -cd "${basedir}" +cd "${base_dir}" # Build the latest u-boot bootloader, and then use the Hardkernel script to fuse # it to the image. This is required because of a requirement that the # bootloader be signed git clone --depth 1 https://github.com/hardkernel/u-boot -b odroid-v2010.12 -cd "${basedir}"/u-boot +cd "${base_dir}"/u-boot # https://code.google.com/p/chromium/issues/detail?id=213120 sed -i -e "s/soft-float/float-abi=hard -mfpu=vfpv3/g" \ arch/arm/cpu/armv7/config.mk -export CROSS_COMPILE="${basedir}"/gcc-arm-linux-gnueabihf-4.7/bin/arm-linux-gnueabihf- +export CROSS_COMPILE="${base_dir}"/gcc-arm-linux-gnueabihf-4.7/bin/arm-linux-gnueabihf- make smdk4412_config make -j $(grep -c processor /proc/cpuinfo) cd sd_fuse sh sd_fusing.sh ${loopdevice} -cd "${basedir}" +cd "${base_dir}" losetup -d ${loopdevice} @@ -512,16 +512,16 @@ limit_cpu (){ if [ $compress = xz ]; then if [ $(arch) == 'x86_64' ]; then - echo "Compressing ${imagename}.img" + echo "Compressing ${image_name}.img" [ $(nproc) \< 3 ] || cpu_cores=3 # cpu_cores = Number of cores to use - limit_cpu pixz -p ${cpu_cores:-2} ${current_dir}/${imagename}.img # -p Nº cpu cores use - chmod 0644 ${current_dir}/${imagename}.img.xz + limit_cpu pixz -p ${cpu_cores:-2} ${current_dir}/${image_name}.img # -p Nº cpu cores use + chmod 0644 ${current_dir}/${image_name}.img.xz fi else - chmod 0644 ${current_dir}/${imagename}.img + chmod 0644 ${current_dir}/${image_name}.img fi # Clean up all the temporary build stuff and remove the directories # Comment this out to keep things around if you want to see what may have gone wrong echo "Clean up the build system" -rm -rf "${basedir}" +rm -rf "${base_dir}" diff --git a/odroid-xu3.sh b/odroid-xu3.sh index 5ee5d38..351819b 100755 --- a/odroid-xu3.sh +++ b/odroid-xu3.sh @@ -180,7 +180,7 @@ cp arch/arm/boot/dts/exynos5422-odroidxu4-kvm.dtb ${work_dir}/boot make mrproper cp ${current_dir}/kernel-configs/odroid-xu3.config .config cp ${current_dir}/kernel-configs/odroid-xu3.config ../odroid-xu3.config -cd "${basedir}" +cd "${base_dir}" # Fix up the symlink for building external modules # kernver is used so we don't need to keep track of what the current compiled @@ -251,13 +251,13 @@ cd "${current_dir}/" make_image # Create the disk and partition it -echo "Creating image file ${imagename}.img" -parted -s ${current_dir}/${imagename}.img mklabel msdos -parted -s ${current_dir}/${imagename}.img mkpart primary fat32 4MiB ${bootsize}MiB -parted -s -a minimal ${current_dir}/${imagename}.img mkpart primary $fstype ${bootsize}MiB 100% +echo "Creating image file ${image_name}.img" +parted -s ${current_dir}/${image_name}.img mklabel msdos +parted -s ${current_dir}/${image_name}.img mkpart primary fat32 4MiB ${bootsize}MiB +parted -s -a minimal ${current_dir}/${image_name}.img mkpart primary $fstype ${bootsize}MiB 100% # Set the partition variables -loopdevice=$(losetup --show -fP "${current_dir}/${imagename}.img") +loopdevice=$(losetup --show -fP "${current_dir}/${image_name}.img") bootp="${loopdevice}p1" rootp="${loopdevice}p2" @@ -273,10 +273,10 @@ mkfs -O "$features" -t "$fstype" -L ROOTFS "${rootp}" # Create the dirs for the partitions and mount them log "Create the dirs for the partitions and mount them" green -mkdir -p "${basedir}"/root/ -mount "${rootp}" "${basedir}"/root -mkdir -p "${basedir}"/root/boot -mount "${bootp}" "${basedir}"/root/boot +mkdir -p "${base_dir}"/root/ +mount "${rootp}" "${base_dir}"/root +mkdir -p "${base_dir}"/root/boot +mount "${bootp}" "${base_dir}"/root/boot # We do this down here to get rid of the build system's resolv.conf after running through the build echo "nameserver ${nameserver}" > "${work_dir}"/etc/resolv.conf @@ -287,14 +287,14 @@ UUID=$(blkid -s UUID -o value ${rootp}) echo "UUID=$UUID / $fstype errors=remount-ro 0 1" >> ${work_dir}/etc/fstab log "Rsyncing rootfs into image file" green -rsync -HPavz -q "${work_dir}"/ "${basedir}"/root/ +rsync -HPavz -q "${work_dir}"/ "${base_dir}"/root/ sync # Write the signed u-boot binary to the image so that it will boot log "u-Boot" green -cd "${basedir}" +cd "${base_dir}" git clone --depth 1 -b odroidxu4-v2017.05 https://github.com/hardkernel/u-boot.git -cd "${basedir}"/u-boot +cd "${base_dir}"/u-boot make odroid-xu4_defconfig make cd sd_fuse diff --git a/pinebook-pro.sh b/pinebook-pro.sh index 4800cd1..b475b1a 100755 --- a/pinebook-pro.sh +++ b/pinebook-pro.sh @@ -284,11 +284,11 @@ make_image # Create the disk partitions log "Create the disk partitions" green -parted -s ${current_dir}/${imagename}.img mklabel msdos -parted -s -a minimal ${current_dir}/${imagename}.img mkpart primary $fstype 32MiB 100% +parted -s ${current_dir}/${image_name}.img mklabel msdos +parted -s -a minimal ${current_dir}/${image_name}.img mkpart primary $fstype 32MiB 100% # Set the partition variables -loopdevice=$(losetup --show -fP "${current_dir}/${imagename}.img") +loopdevice=$(losetup --show -fP "${current_dir}/${image_name}.img") rootp="${loopdevice}p1" # Create file systems @@ -302,8 +302,8 @@ mkfs -O "$features" -t "$fstype" -L ROOTFS "${rootp}" # Create the dirs for the partitions and mount them log "Create the dirs for the partitions and mount them" green -mkdir -p "${basedir}"/root/ -mount "${rootp}" "${basedir}"/root +mkdir -p "${base_dir}"/root/ +mount "${rootp}" "${base_dir}"/root # We do this here because we don't want to hardcode the UUID for the partition during creation # systemd doesn't seem to be generating the fstab properly for some people, so let's create one @@ -320,12 +320,12 @@ EOF #sed -i -e "0,/root=.*/s//root=UUID=$(blkid -s UUID -o value ${rootp}) rootfstype=$fstype console=ttyS0,115200 console=tty1 consoleblank=0 rw quiet rootwait/g" ${work_dir}/boot/extlinux/extlinux.conf log "Rsyncing rootfs into image file" green -rsync -HPavz -q "${work_dir}"/ "${basedir}"/root/ +rsync -HPavz -q "${work_dir}"/ "${base_dir}"/root/ sync ## Nick the u-boot from Manjaro ARM to see if my compilation was somehow ## screwing things up -cp ${current_dir}/bsp/bootloader/pinebook-pro/idbloader.img ${current_dir}/bsp/bootloader/pinebook-pro/trust.img ${current_dir}/bsp/bootloader/pinebook-pro/uboot.img ${basedir}/root/boot/ +cp ${current_dir}/bsp/bootloader/pinebook-pro/idbloader.img ${current_dir}/bsp/bootloader/pinebook-pro/trust.img ${current_dir}/bsp/bootloader/pinebook-pro/uboot.img ${base_dir}/root/boot/ dd if=${current_dir}/bsp/bootloader/pinebook-pro/idbloader.img of=${loopdevice} seek=64 conv=notrunc dd if=${current_dir}/bsp/bootloader/pinebook-pro/uboot.img of=${loopdevice} seek=16384 conv=notrunc dd if=${current_dir}/bsp/bootloader/pinebook-pro/trust.img of=${loopdevice} seek=24576 conv=notrunc diff --git a/pinebook.sh b/pinebook.sh index e57d6f6..f291e9d 100755 --- a/pinebook.sh +++ b/pinebook.sh @@ -237,11 +237,11 @@ make_image # Create the disk partitions log "Create the disk partitions" green -parted -s ${current_dir}/${imagename}.img mklabel msdos -parted -s -a minimal ${current_dir}/${imagename}.img mkpart primary $fstype 32MiB 100% +parted -s ${current_dir}/${image_name}.img mklabel msdos +parted -s -a minimal ${current_dir}/${image_name}.img mkpart primary $fstype 32MiB 100% # Set the partition variables -loopdevice=$(losetup --show -fP "${current_dir}/${imagename}.img") +loopdevice=$(losetup --show -fP "${current_dir}/${image_name}.img") rootp="${loopdevice}p1" # Create file systems @@ -255,8 +255,8 @@ mkfs -O "$features" -t "$fstype" -L ROOTFS "${rootp}" # Create the dirs for the partitions and mount them log "Create the dirs for the partitions and mount them" green -mkdir -p "${basedir}"/root/ -mount "${rootp}" "${basedir}"/root +mkdir -p "${base_dir}"/root/ +mount "${rootp}" "${base_dir}"/root # We do this here because we don't want to hardcode the UUID for the partition during creation # systemd doesn't seem to be generating the fstab properly for some people, so let's create one @@ -274,7 +274,7 @@ sed -i -e "0,/root=.*/s//root=UUID=$(blkid -s UUID -o value ${rootp}) rootfstype sed -i -e "s/Debian GNU\/Linux/Kali Linux/g" ${work_dir}/boot/extlinux/extlinux.conf log "Rsyncing rootfs into image file" green -rsync -HPavz -q "${work_dir}"/ "${basedir}"/root/ +rsync -HPavz -q "${work_dir}"/ "${base_dir}"/root/ sync # Adapted from the u-boot-install-sunxi64 script diff --git a/riotboard.sh b/riotboard.sh index 6437a9a..1ad398c 100755 --- a/riotboard.sh +++ b/riotboard.sh @@ -25,7 +25,7 @@ machine=$(tr -cd 'A-Za-z0-9' < /dev/urandom | head -c16 ; echo) # Custom hostname variable hostname=${2:-kali} # Custom image file name variable - MUST NOT include .img at the end -imagename=${3:-kali-linux-$1-riotboard} +image_name=${3:-kali-linux-$1-riotboard} # Suite to use, valid options are: # kali-rolling, kali-dev, kali-bleeding-edge, kali-dev-only, kali-experimental, kali-last-snapshot suite=${suite:-"kali-rolling"} @@ -67,20 +67,20 @@ fi # Current directory current_dir="$(pwd)" # Base directory -basedir=${current_dir}/riot-"$1" +base_dir=${current_dir}/riot-"$1" # Working directory -work_dir="${basedir}/kali-${architecture}" +work_dir="${base_dir}/kali-${architecture}" # Check directory build -if [ -e "${basedir}" ]; then - echo "${basedir} directory exists, will not continue" >&2 +if [ -e "${base_dir}" ]; then + echo "${base_dir} directory exists, will not continue" >&2 exit 1 elif [[ ${current_dir} =~ [[:space:]] ]]; then echo "The directory "\"${current_dir}"\" contains whitespace. Not supported." >&2 exit 1 else - echo "The basedir thinks it is: ${basedir}" - mkdir -p ${basedir} + echo "The base_dir thinks it is: ${base_dir}" + mkdir -p ${base_dir} fi components="main,contrib,non-free" @@ -376,7 +376,7 @@ deb ${mirror} ${suite} ${components//,/ } #deb-src ${mirror} ${suite} ${components//,/ } EOF -cd "${basedir}" +cd "${base_dir}" # Mainline u-boot with RIoTboard fixes on top #wget ftp://ftp.denx.de/pub/u-boot/u-boot-2018.05.tar.bz2 #tar -xf u-boot-2018.05.tar.bz2 @@ -385,10 +385,10 @@ cd "${basedir}" #make riotboard_config #make -j $(grep -c processor /proc/cpuinfo) #dd if=u-boot.imx of=$loopdevice bs=1024 seek=1 -#cd "${basedir}" +#cd "${base_dir}" # Generate the bootscript so that u-boot knows where everything is.. -#cat << __EOF__ > "${basedir}"/kali-$architecture/boot/bootscript +#cat << __EOF__ > "${base_dir}"/kali-$architecture/boot/bootscript #fdt_high=0xffffffff #initrd_high=0xffffffff @@ -409,14 +409,14 @@ root_extra=$((${root_size}/1024/1000*5*1024/5)) raw_size=$(($((${free_space}*1024))+${root_extra}+$((${bootsize}*1024))+4096)) # Create the disk and partition it -echo "Creating image file ${imagename}.img" -fallocate -l $(echo ${raw_size}Ki | numfmt --from=iec-i --to=si) ${current_dir}/${imagename}.img -parted -s ${current_dir}/${imagename}.img mklabel msdos -parted -s ${current_dir}/${imagename}.img mkpart primary fat32 1MiB ${bootsize}MiB -parted -s -a minimal ${current_dir}/${imagename}.img mkpart primary $fstype ${bootsize}MiB 100% +echo "Creating image file ${image_name}.img" +fallocate -l $(echo ${raw_size}Ki | numfmt --from=iec-i --to=si) ${current_dir}/${image_name}.img +parted -s ${current_dir}/${image_name}.img mklabel msdos +parted -s ${current_dir}/${image_name}.img mkpart primary fat32 1MiB ${bootsize}MiB +parted -s -a minimal ${current_dir}/${image_name}.img mkpart primary $fstype ${bootsize}MiB 100% # Set the partition variables -loopdevice=`losetup -f --show ${current_dir}/${imagename}.img` +loopdevice=`losetup -f --show ${current_dir}/${image_name}.img` device=`kpartx -va ${loopdevice} | sed 's/.*\(loop[0-9]\+\)p.*/\1/g' | head -1` sleep 5 device="/dev/mapper/${device}" @@ -433,10 +433,10 @@ fi mkfs $features -t $fstype -L ROOTFS ${rootp} # Create the dirs for the partitions and mount them -mkdir -p "${basedir}"/root -mount ${rootp} "${basedir}"/root -mkdir -p "${basedir}"/root/boot -mount ${bootp} "${basedir}"/root/boot +mkdir -p "${base_dir}"/root +mount ${rootp} "${base_dir}"/root +mkdir -p "${base_dir}"/root/boot +mount ${bootp} "${base_dir}"/root/boot # We do this down here to get rid of the build system's resolv.conf after running through the build echo "nameserver ${nameserver}" > "${work_dir}"/etc/resolv.conf @@ -446,7 +446,7 @@ UUID=$(blkid -s UUID -o value ${rootp}) echo "UUID=$UUID / $fstype errors=remount-ro 0 1" >> ${work_dir}/etc/fstab echo "Rsyncing rootfs into image file" -rsync -HPavz -q ${work_dir}/ ${basedir}/root/ +rsync -HPavz -q ${work_dir}/ ${base_dir}/root/ # Unmount partitions sync @@ -479,16 +479,16 @@ limit_cpu (){ if [ $compress = xz ]; then if [ $(arch) == 'x86_64' ]; then - echo "Compressing ${imagename}.img" + echo "Compressing ${image_name}.img" [ $(nproc) \< 3 ] || cpu_cores=3 # cpu_cores = Number of cores to use - limit_cpu pixz -p ${cpu_cores:-2} ${current_dir}/${imagename}.img # -p Nº cpu cores use - chmod 0644 ${current_dir}/${imagename}.img.xz + limit_cpu pixz -p ${cpu_cores:-2} ${current_dir}/${image_name}.img # -p Nº cpu cores use + chmod 0644 ${current_dir}/${image_name}.img.xz fi else - chmod 0644 ${current_dir}/${imagename}.img + chmod 0644 ${current_dir}/${image_name}.img fi # Clean up all the temporary build stuff and remove the directories # Comment this out to keep things around if you want to see what may have gone wrong echo "Removing temporary build files" -rm -rf "${basedir}" +rm -rf "${base_dir}" diff --git a/rpi-64bit-minimal.sh b/rpi-64bit-minimal.sh index a6a3751..776ad14 100755 --- a/rpi-64bit-minimal.sh +++ b/rpi-64bit-minimal.sh @@ -171,12 +171,12 @@ make_image # Create the disk partitions log "Create the disk partitions" green -parted -s "${current_dir}"/"${imagename}".img mklabel msdos -parted -s "${current_dir}"/"${imagename}".img mkpart primary fat32 1MiB "${bootsize}"MiB -parted -s -a minimal "${current_dir}"/"${imagename}".img mkpart primary "$fstype" "${bootsize}"MiB 100% +parted -s "${current_dir}"/"${image_name}".img mklabel msdos +parted -s "${current_dir}"/"${image_name}".img mkpart primary fat32 1MiB "${bootsize}"MiB +parted -s -a minimal "${current_dir}"/"${image_name}".img mkpart primary "$fstype" "${bootsize}"MiB 100% # Set the partition variables -loopdevice=$(losetup --show -fP "${current_dir}/${imagename}.img") +loopdevice=$(losetup --show -fP "${current_dir}/${image_name}.img") bootp="${loopdevice}p1" rootp="${loopdevice}p2" @@ -192,15 +192,15 @@ mkfs -O "$features" -t "$fstype" -L ROOTFS "${rootp}" # Create the dirs for the partitions and mount them log "Create the dirs for the partitions and mount them" green -mkdir -p "${basedir}"/root/ -mount "${rootp}" "${basedir}"/root -mkdir -p "${basedir}"/root/boot -mount "${bootp}" "${basedir}"/root/boot +mkdir -p "${base_dir}"/root/ +mount "${rootp}" "${base_dir}"/root +mkdir -p "${base_dir}"/root/boot +mount "${bootp}" "${base_dir}"/root/boot log "Rsyncing rootfs into image file" green -rsync -HPavz -q --exclude boot "${work_dir}"/ "${basedir}"/root/ +rsync -HPavz -q --exclude boot "${work_dir}"/ "${base_dir}"/root/ log "Rsyncing rootfs into image file (/boot)" green -rsync -rtx -q "${work_dir}"/boot "${basedir}"/root +rsync -rtx -q "${work_dir}"/boot "${base_dir}"/root sync # Flush buffers and bytes - this is nicked from the Devuan arm-sdk. diff --git a/rpi-64bit.sh b/rpi-64bit.sh index cbb6a9c..4f7c359 100755 --- a/rpi-64bit.sh +++ b/rpi-64bit.sh @@ -172,12 +172,12 @@ make_image # Create the disk partitions log "Create the disk partitions" green -parted -s "${current_dir}"/"${imagename}".img mklabel msdos -parted -s "${current_dir}"/"${imagename}".img mkpart primary fat32 1MiB "${bootsize}"MiB -parted -s -a minimal "${current_dir}"/"${imagename}".img mkpart primary "$fstype" "${bootsize}"MiB 100% +parted -s "${current_dir}"/"${image_name}".img mklabel msdos +parted -s "${current_dir}"/"${image_name}".img mkpart primary fat32 1MiB "${bootsize}"MiB +parted -s -a minimal "${current_dir}"/"${image_name}".img mkpart primary "$fstype" "${bootsize}"MiB 100% # Set the partition variables -loopdevice=$(losetup --show -fP "${current_dir}/${imagename}.img") +loopdevice=$(losetup --show -fP "${current_dir}/${image_name}.img") bootp="${loopdevice}p1" rootp="${loopdevice}p2" @@ -193,15 +193,15 @@ mkfs -O "$features" -t "$fstype" -L ROOTFS "${rootp}" # Create the dirs for the partitions and mount them log "Create the dirs for the partitions and mount them" green -mkdir -p "${basedir}"/root/ -mount "${rootp}" "${basedir}"/root -mkdir -p "${basedir}"/root/boot -mount "${bootp}" "${basedir}"/root/boot +mkdir -p "${base_dir}"/root/ +mount "${rootp}" "${base_dir}"/root +mkdir -p "${base_dir}"/root/boot +mount "${bootp}" "${base_dir}"/root/boot log "Rsyncing rootfs into image file" green -rsync -HPavz -q --exclude boot "${work_dir}"/ "${basedir}"/root/ +rsync -HPavz -q --exclude boot "${work_dir}"/ "${base_dir}"/root/ log "Rsyncing rootfs into image file (/boot)" green -rsync -rtx -q "${work_dir}"/boot "${basedir}"/root +rsync -rtx -q "${work_dir}"/boot "${base_dir}"/root sync # Flush buffers and bytes - this is nicked from the Devuan arm-sdk. diff --git a/rpi.sh b/rpi.sh index 1f01778..a1ad4de 100755 --- a/rpi.sh +++ b/rpi.sh @@ -59,17 +59,24 @@ cat <"${work_dir}"/third-stage #!/usr/bin/env bash set -e +# Update apt export DEBIAN_FRONTEND=noninteractive eatmydata apt-get update + +# Install core packages eatmydata apt-get -y install ${third_stage_pkgs} +# Install packages eatmydata apt-get install -y ${packages} || eatmydata apt-get install -y --fix-broken + +# Install desktop packages eatmydata apt-get install -y ${desktop_pkgs} ${extra} || eatmydata apt-get install -y --fix-broken + # ntp doesn't always sync the date, but systemd's timesyncd does, so we remove ntp and reinstall it with this eatmydata apt-get install -y systemd-timesyncd --autoremove eatmydata apt-get -y --purge autoremove -# Linux console/Keyboard configuration +# Linux console/keyboard configuration echo 'console-common console-data/keymap/policy select Select keymap from full list' | debconf-set-selections echo 'console-common console-data/keymap/full select en-latin1-nodeadkeys' | debconf-set-selections @@ -89,6 +96,7 @@ eatmydata apt-get install -y kalipi-kernel kalipi-bootloader kalipi-re4son-firmw # Copy script rpi-resizerootfs install -m755 /bsp/scripts/rpi-resizerootfs /usr/sbin/ + # Copy script for handling wpa_supplicant file install -m755 /bsp/scripts/copy-user-wpasupplicant.sh /usr/bin/ @@ -101,16 +109,17 @@ systemctl enable regenerate_ssh_host_keys # Enable copying of user wpa_supplicant.conf file systemctl enable copy-user-wpasupplicant -# Enable... enabling ssh by putting ssh or ssh.txt file in /boot +# Wnabling ssh by putting ssh or ssh.txt file in /boot systemctl enable enable-ssh -# Allow users to use NM over ssh +# Allow users to use NetworkManager over ssh install -m644 /bsp/polkit/10-NetworkManager.pkla /var/lib/polkit-1/localauthority/50-local.d +# Install ca-certificate cd /root apt download -o APT::Sandbox::User=root ca-certificates 2>/dev/null -# Set a REGDOMAIN. This needs to be done or wireless doesn't work correctly on the RPi 3B+ +# Set a REGDOMAIN. This needs to be done or wireless doesnt work correctly on the RPi 3B+ sed -i -e 's/REGDOM.*/REGDOMAIN=00/g' /etc/default/crda # Enable login over serial @@ -142,7 +151,7 @@ chmod 0755 "${work_dir}"/third-stage log "Run third stage" green systemd-nspawn_exec /third-stage -# Configure RaspberryPi firmware (set config.txt to 64bit) +# Configure Raspberry Pi firmware (set config.txt to 64-bit) include rpi_firmware # Choose a locale set_locale "$locale" @@ -172,12 +181,12 @@ make_image # Create the disk partitions log "Create the disk partitions" green -parted -s "${current_dir}"/"${imagename}".img mklabel msdos -parted -s "${current_dir}"/"${imagename}".img mkpart primary fat32 1MiB "${bootsize}"MiB -parted -s -a minimal "${current_dir}"/"${imagename}".img mkpart primary "$fstype" "${bootsize}"MiB 100% +parted -s "${current_dir}"/"${image_name}".img mklabel msdos +parted -s "${current_dir}"/"${image_name}".img mkpart primary fat32 1MiB "${bootsize}"MiB +parted -s -a minimal "${current_dir}"/"${image_name}".img mkpart primary "$fstype" "${bootsize}"MiB 100% # Set the partition variables -loopdevice=$(losetup --show -fP "${current_dir}/${imagename}.img") +loopdevice=$(losetup --show -fP "${current_dir}/${image_name}.img") bootp="${loopdevice}p1" rootp="${loopdevice}p2" @@ -193,18 +202,20 @@ mkfs -O "$features" -t "$fstype" -L ROOTFS "${rootp}" # Create the dirs for the partitions and mount them log "Create the dirs for the partitions and mount them" green -mkdir -p "${basedir}"/root/ -mount "${rootp}" "${basedir}"/root -mkdir -p "${basedir}"/root/boot -mount "${bootp}" "${basedir}"/root/boot +mkdir -p "${base_dir}"/root/ +mount "${rootp}" "${base_dir}"/root +mkdir -p "${base_dir}"/root/boot +mount "${bootp}" "${base_dir}"/root/boot log "Rsyncing rootfs into image file" green -rsync -HPavz -q --exclude boot "${work_dir}"/ "${basedir}"/root/ -log "Rsyncing rootfs into image file (/boot)" green -rsync -rtx -q "${work_dir}"/boot "${basedir}"/root +rsync -HPavz -q --exclude boot "${work_dir}"/ "${base_dir}"/root/ sync -# Flush buffers and bytes - this is nicked from the Devuan arm-sdk. +log "Rsyncing rootfs into image file (/boot)" green +rsync -rtx -q "${work_dir}"/boot "${base_dir}"/root +sync + +# Flush buffers and bytes - this is nicked from the Devuan arm-sdk blockdev --flushbufs "${loopdevice}" python -c 'import os; os.fsync(open("'${loopdevice}'", "r+b"))' diff --git a/rpi0w-minimal.sh b/rpi0w-minimal.sh index bf818db..636c0b5 100755 --- a/rpi0w-minimal.sh +++ b/rpi0w-minimal.sh @@ -168,12 +168,12 @@ make_image # Create the disk partitions log "Create the disk partitions" green -parted -s "${current_dir}"/"${imagename}".img mklabel msdos -parted -s "${current_dir}"/"${imagename}".img mkpart primary fat32 1MiB "${bootsize}"MiB -parted -s -a minimal "${current_dir}"/"${imagename}".img mkpart primary "$fstype" "${bootsize}"MiB 100% +parted -s "${current_dir}"/"${image_name}".img mklabel msdos +parted -s "${current_dir}"/"${image_name}".img mkpart primary fat32 1MiB "${bootsize}"MiB +parted -s -a minimal "${current_dir}"/"${image_name}".img mkpart primary "$fstype" "${bootsize}"MiB 100% # Set the partition variables -loopdevice=$(losetup --show -fP "${current_dir}/${imagename}.img") +loopdevice=$(losetup --show -fP "${current_dir}/${image_name}.img") bootp="${loopdevice}p1" rootp="${loopdevice}p2" @@ -189,15 +189,15 @@ mkfs -O "$features" -t "$fstype" -L ROOTFS "${rootp}" # Create the dirs for the partitions and mount them log "Create the dirs for the partitions and mount them" green -mkdir -p "${basedir}"/root/ -mount "${rootp}" "${basedir}"/root -mkdir -p "${basedir}"/root/boot -mount "${bootp}" "${basedir}"/root/boot +mkdir -p "${base_dir}"/root/ +mount "${rootp}" "${base_dir}"/root +mkdir -p "${base_dir}"/root/boot +mount "${bootp}" "${base_dir}"/root/boot log "Rsyncing rootfs into image file" green -rsync -HPavz -q --exclude boot "${work_dir}"/ "${basedir}"/root/ +rsync -HPavz -q --exclude boot "${work_dir}"/ "${base_dir}"/root/ log "Rsyncing rootfs into image file (/boot)" green -rsync -rtx -q "${work_dir}"/boot "${basedir}"/root +rsync -rtx -q "${work_dir}"/boot "${base_dir}"/root sync # Umount filesystem diff --git a/rpi0w-p4wnp1-aloa.sh b/rpi0w-p4wnp1-aloa.sh index 658b83a..f754933 100755 --- a/rpi0w-p4wnp1-aloa.sh +++ b/rpi0w-p4wnp1-aloa.sh @@ -27,7 +27,7 @@ machine=$(tr -cd 'A-Za-z0-9' < /dev/urandom | head -c16 ; echo) # Custom hostname variable hostname=${2:-kali} # Custom image file name variable - MUST NOT include .img at the end -imagename=${3:-kali-linux-$1-rpi0w-p4wnp1-aloa} +image_name=${3:-kali-linux-$1-rpi0w-p4wnp1-aloa} # Suite to use, valid options are: # kali-rolling, kali-dev, kali-bleeding-edge, kali-dev-only, kali-experimental, kali-last-snapshot suite=${suite:-"kali-rolling"} @@ -71,20 +71,20 @@ fi # Current directory current_dir="$(pwd)" # Base directory -basedir=${current_dir}/rpi0w-p4wnp1-"$1" +base_dir=${current_dir}/rpi0w-p4wnp1-"$1" # Working directory -work_dir="${basedir}/kali-${architecture}" +work_dir="${base_dir}/kali-${architecture}" # Check directory build -if [ -e "${basedir}" ]; then - echo "${basedir} directory exists, will not continue" >&2 +if [ -e "${base_dir}" ]; then + echo "${base_dir} directory exists, will not continue" >&2 exit 1 elif [[ ${current_dir} =~ [[:space:]] ]]; then echo "The directory "\"${current_dir}"\" contains whitespace. Not supported." >&2 exit 1 else - echo "The basedir thinks it is: ${basedir}" - mkdir -p ${basedir} + echo "The base_dir thinks it is: ${base_dir}" + mkdir -p ${base_dir} fi components="main,contrib,non-free" @@ -212,12 +212,12 @@ fi # Copy a default config, with everything commented out so people find it when # they go to add something when they are following instructions on a website -cp "${basedir}"/../bsp/firmware/rpi/config.txt ${work_dir}/boot/config.txt +cp "${base_dir}"/../bsp/firmware/rpi/config.txt ${work_dir}/boot/config.txt # move P4wnP1 in (change to release blob when ready) git clone -b 'master' --single-branch --depth 1 https://github.com/rogandawes/P4wnP1_aloa ${work_dir}/root/P4wnP1 -cat << EOF > ${basedir}/kali-${architecture}/third-stage +cat << EOF > ${base_dir}/kali-${architecture}/third-stage #!/bin/bash set -e dpkg-divert --add --local --divert /usr/sbin/invoke-rc.d.chroot --rename /usr/sbin/invoke-rc.d @@ -335,8 +335,8 @@ dpkg-divert --remove --rename /usr/sbin/invoke-rc.d rm -f /third-stage EOF -chmod 0755 ${basedir}/kali-${architecture}/third-stage -LANG=C systemd-nspawn -M ${machine} -D ${basedir}/kali-${architecture} /third-stage +chmod 0755 ${base_dir}/kali-${architecture}/third-stage +LANG=C systemd-nspawn -M ${machine} -D ${base_dir}/kali-${architecture} /third-stage if [[ $? > 0 ]]; then echo "Third stage failed" exit 1 @@ -410,8 +410,8 @@ cp -rf rpi-firmware/opt/* ${work_dir}/opt/ rm -rf rpi-firmware # Build nexmon firmware outside the build system, if we can (use repository with driver and firmware for P4wnP1) -cd "${basedir}" -git clone https://github.com/mame82/nexmon_wifi_covert_channel.git -b p4wnp1 "${basedir}"/nexmon --depth 1 +cd "${base_dir}" +git clone https://github.com/mame82/nexmon_wifi_covert_channel.git -b p4wnp1 "${base_dir}"/nexmon --depth 1 # Setup build cd ${TOPDIR} @@ -421,7 +421,7 @@ git clone --depth 1 https://github.com/Re4son/re4son-raspberrypi-linux -b rpi-4. cd ${work_dir}/usr/src/kernel # Remove redundant yyloc global declaration -patch -p1 --no-backup-if-mismatch < ${basedir}/../patches/11647f99b4de6bc460e106e876f72fc7af3e54a6.patch +patch -p1 --no-backup-if-mismatch < ${base_dir}/../patches/11647f99b4de6bc460e106e876f72fc7af3e54a6.patch # Note: Compiling the kernel in /usr/src/kernel of the target file system is problematic, as the binaries of the compiling host architecture # get deployed to the /usr/src/kernel/scripts subfolder (in this case linux-x64 binaries), which is symlinked to /usr/src/build later on # This would f.e. hinder rebuilding single modules, like nexmon's brcmfmac driver, on the Pi itself (online compilation) @@ -476,11 +476,11 @@ rm build rm source ln -s /usr/src/kernel build ln -s /usr/src/kernel source -cd "${basedir}" +cd "${base_dir}" # Copy a default config, with everything commented out so people find it when # they go to add something when they are following instructions on a website -cp "${basedir}"/../bsp/firmware/rpi/config.txt ${work_dir}/boot/config.txt +cp "${base_dir}"/../bsp/firmware/rpi/config.txt ${work_dir}/boot/config.txt cat << EOF >> ${work_dir}/boot/config.txt dtoverlay=dwc2 @@ -502,7 +502,7 @@ wget https://raw.github.com/steev/rpiwiggle/master/rpi-wiggle -O ${work_dir}/roo chmod 0755 ${work_dir}/root/scripts/rpi-wiggle.sh # git clone of nexmon moved in front of kernel compilation, to have poper brcmfmac driver ready -cd "${basedir}"/nexmon +cd "${base_dir}"/nexmon # Make sure we're not still using the armel cross compiler unset CROSS_COMPILE @@ -530,9 +530,9 @@ wget https://raw.githubusercontent.com/RPi-Distro/firmware-nonfree/master/brcm/b wget https://raw.githubusercontent.com/RPi-Distro/firmware-nonfree/master/brcm/brcmfmac43430-sdio.bin -O ${work_dir}/lib/firmware/brcm/brcmfmac43430-sdio.rpi.bin #cp ${work_dir}/lib/firmware/brcm/brcmfmac43430-sdio.rpi.bin ${work_dir}/lib/firmware/brcm/brcmfmac43430-sdio.bin -cp "${basedir}"/../bsp/firmware/rpi/BCM43430A1.hcd ${work_dir}/lib/firmware/brcm/BCM43430A1.hcd +cp "${base_dir}"/../bsp/firmware/rpi/BCM43430A1.hcd ${work_dir}/lib/firmware/brcm/BCM43430A1.hcd -cd "${basedir}" +cd "${base_dir}" sed -i -e 's/^#PermitRootLogin.*/PermitRootLogin yes/' ${work_dir}/etc/ssh/sshd_config @@ -542,14 +542,14 @@ root_extra=$((${root_size}/1024/1000*5*1024/5)) raw_size=$(($((${free_space}*1024))+${root_extra}+$((${bootsize}*1024))+4096)) # Create the disk and partition it -echo "Creating image file ${imagename}.img" -fallocate -l $(echo ${raw_size}Ki | numfmt --from=iec-i --to=si) ${current_dir}/${imagename}.img -parted -s ${current_dir}/${imagename}.img mklabel msdos -parted -s ${current_dir}/${imagename}.img mkpart primary fat32 4MiB ${bootsize}MiB -parted -s -a minimal ${current_dir}/${imagename}.img mkpart primary $fstype ${bootsize}MiB 100% +echo "Creating image file ${image_name}.img" +fallocate -l $(echo ${raw_size}Ki | numfmt --from=iec-i --to=si) ${current_dir}/${image_name}.img +parted -s ${current_dir}/${image_name}.img mklabel msdos +parted -s ${current_dir}/${image_name}.img mkpart primary fat32 4MiB ${bootsize}MiB +parted -s -a minimal ${current_dir}/${image_name}.img mkpart primary $fstype ${bootsize}MiB 100% # Set the partition variables -loopdevice=$(losetup --show -fP "${current_dir}/${imagename}.img") +loopdevice=$(losetup --show -fP "${current_dir}/${image_name}.img") bootp="${loopdevice}p1" rootp="${loopdevice}p2" @@ -563,10 +563,10 @@ fi mkfs $features -t $fstype -L ROOTFS ${rootp} # Create the dirs for the partitions and mount them -mkdir -p ${basedir}/root/ -mount ${rootp} ${basedir}/root -mkdir -p ${basedir}/root/boot -mount ${bootp} ${basedir}/root/boot +mkdir -p ${base_dir}/root/ +mount ${rootp} ${base_dir}/root +mkdir -p ${base_dir}/root/boot +mount ${bootp} ${base_dir}/root/boot # We do this down here to get rid of the build system's resolv.conf after running through the build cat << EOF > kali-${architecture}/etc/resolv.conf @@ -588,8 +588,8 @@ ff02::2 ip6-allrouters EOF echo "Rsyncing rootfs into image file" -rsync -HPavz -q --exclude boot ${work_dir}/ ${basedir}/root/ -rsync -rtx -q ${work_dir}/boot ${basedir}/root +rsync -HPavz -q --exclude boot ${work_dir}/ ${base_dir}/root/ +rsync -rtx -q ${work_dir}/boot ${base_dir}/root sync # Flush buffers and bytes - this is nicked from the Devuan arm-sdk. @@ -626,16 +626,16 @@ limit_cpu (){ if [ $compress = xz ]; then if [ $(arch) == 'x86_64' ]; then - echo "Compressing ${imagename}.img" + echo "Compressing ${image_name}.img" [ $(nproc) \< 3 ] || cpu_cores=3 # cpu_cores = Number of cores to use - pixz -p ${cpu_cores:-2} ${current_dir}/${imagename}.img # -p Nº cpu cores use - chmod 0644 ${current_dir}/${imagename}.img.xz + pixz -p ${cpu_cores:-2} ${current_dir}/${image_name}.img # -p Nº cpu cores use + chmod 0644 ${current_dir}/${image_name}.img.xz fi else - chmod 0644 ${current_dir}/${imagename}.img + chmod 0644 ${current_dir}/${image_name}.img fi # Clean up all the temporary build stuff and remove the directories # Comment this out to keep things around if you want to see what may have gone wrong echo "Cleaning up the temporary build files..." -rm -rf "${basedir}" +rm -rf "${base_dir}" diff --git a/rpi0w-pitail.sh b/rpi0w-pitail.sh index fbbf224..1527404 100755 --- a/rpi0w-pitail.sh +++ b/rpi0w-pitail.sh @@ -25,7 +25,7 @@ machine=$(dbus-uuidgen) # Custom hostname variable hostname=pi-tail # Custom image file name variable - MUST NOT include .img at the end -imagename=${3:-kali-linux-$1-rpi0w-pitail} +image_name=${3:-kali-linux-$1-rpi0w-pitail} # Suite to use, valid options are: # kali-rolling, kali-dev, kali-bleeding-edge, kali-dev-only, kali-experimental, kali-last-snapshot suite=${suite:-"kali-rolling"} @@ -69,20 +69,20 @@ fi # Current directory current_dir="$(pwd)" # Base directory -basedir=${current_dir}/rpi0w-pitail-"$1" +base_dir=${current_dir}/rpi0w-pitail-"$1" # Working directory -work_dir="${basedir}/kali-${architecture}" +work_dir="${base_dir}/kali-${architecture}" # Check directory build -if [ -e "${basedir}" ]; then - echo "${basedir} directory exists, will not continue" >&2 +if [ -e "${base_dir}" ]; then + echo "${base_dir} directory exists, will not continue" >&2 exit 1 elif [[ ${current_dir} =~ [[:space:]] ]]; then echo "The directory "\"${current_dir}"\" contains whitespace. Not supported." >&2 exit 1 else - echo "The basedir thinks it is: ${basedir}" - mkdir -p ${basedir} + echo "The base_dir thinks it is: ${base_dir}" + mkdir -p ${base_dir} fi components="main,contrib,non-free" @@ -499,14 +499,14 @@ root_extra=$((${root_size}/1024/1000*5*1024/5)) raw_size=$(($((${free_space}*1024))+${root_extra}+$((${bootsize}*1024))+4096)) # Create the disk and partition it -echo "Creating image file ${imagename}.img" -fallocate -l $(echo ${raw_size}Ki | numfmt --from=iec-i --to=si) ${current_dir}/${imagename}.img -parted -s ${current_dir}/${imagename}.img mklabel msdos -parted -s ${current_dir}/${imagename}.img mkpart primary fat32 1MiB ${bootsize}MiB -parted -s -a minimal ${current_dir}/${imagename}.img mkpart primary $fstype ${bootsize}MiB 100% +echo "Creating image file ${image_name}.img" +fallocate -l $(echo ${raw_size}Ki | numfmt --from=iec-i --to=si) ${current_dir}/${image_name}.img +parted -s ${current_dir}/${image_name}.img mklabel msdos +parted -s ${current_dir}/${image_name}.img mkpart primary fat32 1MiB ${bootsize}MiB +parted -s -a minimal ${current_dir}/${image_name}.img mkpart primary $fstype ${bootsize}MiB 100% # Set the partition variables -loopdevice=$(losetup --show -fP "${current_dir}/${imagename}.img") +loopdevice=$(losetup --show -fP "${current_dir}/${image_name}.img") bootp="${loopdevice}p1" rootp="${loopdevice}p2" @@ -520,14 +520,14 @@ fi mkfs $features -t $fstype -L ROOTFS ${rootp} # Create the dirs for the partitions and mount them -mkdir -p ${basedir}/root/ -mount ${rootp} ${basedir}/root -mkdir -p ${basedir}/root/boot -mount ${bootp} ${basedir}/root/boot +mkdir -p ${base_dir}/root/ +mount ${rootp} ${base_dir}/root +mkdir -p ${base_dir}/root/boot +mount ${bootp} ${base_dir}/root/boot echo "Rsyncing rootfs into image file" -rsync -HPavz -q --exclude boot ${work_dir}/ ${basedir}/root/ -rsync -rtx -q ${work_dir}/boot ${basedir}/root +rsync -HPavz -q --exclude boot ${work_dir}/ ${base_dir}/root/ +rsync -rtx -q ${work_dir}/boot ${base_dir}/root sync # Flush buffers and bytes - this is nicked from the Devuan arm-sdk. @@ -565,16 +565,16 @@ limit_cpu (){ if [ "$compress" == "xz" ]; then if [ $(arch) == 'x86_64' ]; then - echo "Compressing ${imagename}.img" + echo "Compressing ${image_name}.img" [ $(nproc) \< 3 ] || cpu_cores=3 # cpu_cores = Number of cores to use - limit_cpu pixz -p ${cpu_cores:-2} ${current_dir}/${imagename}.img # -p Nº cpu cores use - chmod 0644 ${current_dir}/${imagename}.img.xz + limit_cpu pixz -p ${cpu_cores:-2} ${current_dir}/${image_name}.img # -p Nº cpu cores use + chmod 0644 ${current_dir}/${image_name}.img.xz fi else - chmod 0644 ${current_dir}/${imagename}.img + chmod 0644 ${current_dir}/${image_name}.img fi # Clean up all the temporary build stuff and remove the directories # Comment this out to keep things around if you want to see what may have gone wrong ## echo "Cleaning up the temporary build files..." -## rm -rf "${basedir}" +## rm -rf "${base_dir}" diff --git a/rpi0w.sh b/rpi0w.sh index e5641b2..c8da895 100755 --- a/rpi0w.sh +++ b/rpi0w.sh @@ -173,12 +173,12 @@ make_image # Create the disk partitions log "Create the disk partitions" green -parted -s "${current_dir}"/"${imagename}".img mklabel msdos -parted -s "${current_dir}"/"${imagename}".img mkpart primary fat32 1MiB "${bootsize}"MiB -parted -s -a minimal "${current_dir}"/"${imagename}".img mkpart primary "$fstype" "${bootsize}"MiB 100% +parted -s "${current_dir}"/"${image_name}".img mklabel msdos +parted -s "${current_dir}"/"${image_name}".img mkpart primary fat32 1MiB "${bootsize}"MiB +parted -s -a minimal "${current_dir}"/"${image_name}".img mkpart primary "$fstype" "${bootsize}"MiB 100% # Set the partition variables -loopdevice=$(losetup --show -fP "${current_dir}/${imagename}.img") +loopdevice=$(losetup --show -fP "${current_dir}/${image_name}.img") bootp="${loopdevice}p1" rootp="${loopdevice}p2" @@ -194,15 +194,15 @@ mkfs -O "$features" -t "$fstype" -L ROOTFS "${rootp}" # Create the dirs for the partitions and mount them log "Create the dirs for the partitions and mount them" green -mkdir -p "${basedir}"/root/ -mount "${rootp}" "${basedir}"/root -mkdir -p "${basedir}"/root/boot -mount "${bootp}" "${basedir}"/root/boot +mkdir -p "${base_dir}"/root/ +mount "${rootp}" "${base_dir}"/root +mkdir -p "${base_dir}"/root/boot +mount "${bootp}" "${base_dir}"/root/boot log "Rsyncing rootfs into image file" green -rsync -HPavz -q --exclude boot "${work_dir}"/ "${basedir}"/root/ +rsync -HPavz -q --exclude boot "${work_dir}"/ "${base_dir}"/root/ log "Rsyncing rootfs into image file (/boot)" green -rsync -rtx -q "${work_dir}"/boot "${basedir}"/root +rsync -rtx -q "${work_dir}"/boot "${base_dir}"/root sync # Flush buffers and bytes - this is nicked from the Devuan arm-sdk. diff --git a/rpi1.sh b/rpi1.sh index 2df7e3b..35386ce 100755 --- a/rpi1.sh +++ b/rpi1.sh @@ -171,12 +171,12 @@ make_image # Create the disk partitions log "Create the disk partitions" green -parted -s "${current_dir}"/"${imagename}".img mklabel msdos -parted -s "${current_dir}"/"${imagename}".img mkpart primary fat32 1MiB "${bootsize}"MiB -parted -s -a minimal "${current_dir}"/"${imagename}".img mkpart primary "$fstype" "${bootsize}"MiB 100% +parted -s "${current_dir}"/"${image_name}".img mklabel msdos +parted -s "${current_dir}"/"${image_name}".img mkpart primary fat32 1MiB "${bootsize}"MiB +parted -s -a minimal "${current_dir}"/"${image_name}".img mkpart primary "$fstype" "${bootsize}"MiB 100% # Set the partition variables -loopdevice=$(losetup --show -fP "${current_dir}/${imagename}.img") +loopdevice=$(losetup --show -fP "${current_dir}/${image_name}.img") bootp="${loopdevice}p1" rootp="${loopdevice}p2" @@ -192,15 +192,15 @@ mkfs -O "$features" -t "$fstype" -L ROOTFS "${rootp}" # Create the dirs for the partitions and mount them log "Create the dirs for the partitions and mount them" green -mkdir -p "${basedir}"/root/ -mount "${rootp}" "${basedir}"/root -mkdir -p "${basedir}"/root/boot -mount "${bootp}" "${basedir}"/root/boot +mkdir -p "${base_dir}"/root/ +mount "${rootp}" "${base_dir}"/root +mkdir -p "${base_dir}"/root/boot +mount "${bootp}" "${base_dir}"/root/boot log "Rsyncing rootfs into image file" green -rsync -HPavz -q --exclude boot "${work_dir}"/ "${basedir}"/root/ +rsync -HPavz -q --exclude boot "${work_dir}"/ "${base_dir}"/root/ log "Rsyncing rootfs into image file (/boot)" green -rsync -rtx -q "${work_dir}"/boot "${basedir}"/root +rsync -rtx -q "${work_dir}"/boot "${base_dir}"/root sync # Flush buffers and bytes - this is nicked from the Devuan arm-sdk. diff --git a/trimslice.sh b/trimslice.sh index 83ebada..666c984 100755 --- a/trimslice.sh +++ b/trimslice.sh @@ -25,7 +25,7 @@ machine=$(tr -cd 'A-Za-z0-9' < /dev/urandom | head -c16 ; echo) # Custom hostname variable hostname=${2:-kali} # Custom image file name variable - MUST NOT include .img at the end -imagename=${3:-kali-linux-$1-trimslice} +image_name=${3:-kali-linux-$1-trimslice} # Suite to use, valid options are: # kali-rolling, kali-dev, kali-bleeding-edge, kali-dev-only, kali-experimental, kali-last-snapshot suite=${suite:-"kali-rolling"} @@ -67,20 +67,20 @@ fi # Current directory current_dir="$(pwd)" # Base directory -basedir=${current_dir}/trimslice-"$1" +base_dir=${current_dir}/trimslice-"$1" # Working directory -work_dir="${basedir}/kali-${architecture}" +work_dir="${base_dir}/kali-${architecture}" # Check directory build -if [ -e "${basedir}" ]; then - echo "${basedir} directory exists, will not continue" >&2 +if [ -e "${base_dir}" ]; then + echo "${base_dir} directory exists, will not continue" >&2 exit 1 elif [[ ${current_dir} =~ [[:space:]] ]]; then echo "The directory "\"${current_dir}"\" contains whitespace. Not supported." >&2 exit 1 else - echo "The basedir thinks it is: ${basedir}" - mkdir -p ${basedir} + echo "The base_dir thinks it is: ${base_dir}" + mkdir -p ${base_dir} fi components="main,contrib,non-free" @@ -380,14 +380,14 @@ root_extra=$((${root_size}/1024/1000*5*1024/5)) raw_size=$(($((${free_space}*1024))+${root_extra}+$((${bootsize}*1024))+4096)) # Create the disk and partition it -echo "Creating image file ${imagename}.img" -fallocate -l $(echo ${raw_size}Ki | numfmt --from=iec-i --to=si) ${current_dir}/${imagename}.img -parted -s ${current_dir}/${imagename}.img mklabel msdos -parted -s ${current_dir}/${imagename}.img mkpart primary ext2 1MiB ${bootsize}MiB -parted -s -a minimal ${current_dir}/${imagename}.img mkpart primary $fstype ${bootsize}MiB 100% +echo "Creating image file ${image_name}.img" +fallocate -l $(echo ${raw_size}Ki | numfmt --from=iec-i --to=si) ${current_dir}/${image_name}.img +parted -s ${current_dir}/${image_name}.img mklabel msdos +parted -s ${current_dir}/${image_name}.img mkpart primary ext2 1MiB ${bootsize}MiB +parted -s -a minimal ${current_dir}/${image_name}.img mkpart primary $fstype ${bootsize}MiB 100% # Set the partition variables -loopdevice=`losetup -f --show ${current_dir}/${imagename}.img` +loopdevice=`losetup -f --show ${current_dir}/${image_name}.img` device=`kpartx -va ${loopdevice} | sed 's/.*\(loop[0-9]\+\)p.*/\1/g' | head -1` sleep 5 device="/dev/mapper/${device}" @@ -404,10 +404,10 @@ fi mkfs $features -t $fstype -L ROOTFS ${rootp} # Create the dirs for the partitions and mount them -mkdir -p "${basedir}"/bootp "${basedir}"/root -mount ${rootp} "${basedir}"/root -mkdir -p "${basedir}"/root/boot -mount ${bootp} "${basedir}"/root/boot +mkdir -p "${base_dir}"/bootp "${base_dir}"/root +mount ${rootp} "${base_dir}"/root +mkdir -p "${base_dir}"/root/boot +mount ${bootp} "${base_dir}"/root/boot # We do this down here to get rid of the build system's resolv.conf after running through the build echo "nameserver ${nameserver}" > "${work_dir}"/etc/resolv.conf @@ -417,7 +417,7 @@ UUID=$(blkid -s UUID -o value ${rootp}) echo "UUID=$UUID / $fstype errors=remount-ro 0 1" >> ${work_dir}/etc/fstab echo "Rsyncing rootfs into image file" -rsync -HPavz -q ${work_dir}/ ${basedir}/root/ +rsync -HPavz -q ${work_dir}/ ${base_dir}/root/ # Unmount partitions sync @@ -450,15 +450,15 @@ limit_cpu (){ if [ $compress = xz ]; then if [ $(arch) == 'x86_64' ]; then - echo "Compressing ${imagename}.img" + echo "Compressing ${image_name}.img" [ $(nproc) \< 3 ] || cpu_cores=3 # cpu_cores = Number of cores to use - limit_cpu pixz -p ${cpu_cores:-2} ${current_dir}/${imagename}.img # -p Nº cpu cores use - chmod 0644 ${current_dir}/${imagename}.img.xz + limit_cpu pixz -p ${cpu_cores:-2} ${current_dir}/${image_name}.img # -p Nº cpu cores use + chmod 0644 ${current_dir}/${image_name}.img.xz fi else - chmod 0644 ${current_dir}/${imagename}.img + chmod 0644 ${current_dir}/${image_name}.img fi # Clean up all the temporary build stuff and remove the directories # Comment this out to keep things around if you want to see what may have gone wrong -rm -rf "${basedir}" +rm -rf "${base_dir}" diff --git a/usb-armory-mki.sh b/usb-armory-mki.sh index 16ecb8e..6489411 100755 --- a/usb-armory-mki.sh +++ b/usb-armory-mki.sh @@ -25,7 +25,7 @@ machine=$(tr -cd 'A-Za-z0-9' < /dev/urandom | head -c16 ; echo) # Custom hostname variable hostname=${2:-kali} # Custom image file name variable - MUST NOT include .img at the end -imagename=${3:-kali-linux-$1-usbarmory-mki} +image_name=${3:-kali-linux-$1-usbarmory-mki} # Suite to use, valid options are: # kali-rolling, kali-dev, kali-bleeding-edge, kali-dev-only, kali-experimental, kali-last-snapshot suite=${suite:-"kali-rolling"} @@ -67,20 +67,20 @@ fi # Current directory current_dir="$(pwd)" # Base directory -basedir=${current_dir}/usbarmory-"$1" +base_dir=${current_dir}/usbarmory-"$1" # Working directory -work_dir="${basedir}/kali-${architecture}" +work_dir="${base_dir}/kali-${architecture}" # Check directory build -if [ -e "${basedir}" ]; then - echo "${basedir} directory exists, will not continue" >&2 +if [ -e "${base_dir}" ]; then + echo "${base_dir} directory exists, will not continue" >&2 exit 1 elif [[ ${current_dir} =~ [[:space:]] ]]; then echo "The directory "\"${current_dir}"\" contains whitespace. Not supported." >&2 exit 1 else - echo "The basedir thinks it is: ${basedir}" - mkdir -p ${basedir} + echo "The base_dir thinks it is: ${base_dir}" + mkdir -p ${base_dir} fi components="main,contrib,non-free" @@ -525,13 +525,13 @@ root_extra=$((${root_size}/1024/1000*5*1024/5)) raw_size=$(($((${free_space}*1024))+${root_extra}+$((${bootsize}*1024))+4096)) # Create the disk and partition it -echo "Creating image file ${imagename}.img" -fallocate -l $(echo ${raw_size}Ki | numfmt --from=iec-i --to=si) ${current_dir}/${imagename}.img -parted -s ${current_dir}/${imagename}.img mklabel msdos -parted -s -a minimal ${current_dir}/${imagename}.img mkpart primary ext2 5MiB 100% +echo "Creating image file ${image_name}.img" +fallocate -l $(echo ${raw_size}Ki | numfmt --from=iec-i --to=si) ${current_dir}/${image_name}.img +parted -s ${current_dir}/${image_name}.img mklabel msdos +parted -s -a minimal ${current_dir}/${image_name}.img mkpart primary ext2 5MiB 100% # Set the partition variables -loopdevice=`losetup -f --show ${current_dir}/${imagename}.img` +loopdevice=`losetup -f --show ${current_dir}/${image_name}.img` device=`kpartx -va ${loopdevice} | sed 's/.*\(loop[0-9]\+\)p.*/\1/g' | head -1` sleep 5 device="/dev/mapper/${device}" @@ -541,8 +541,8 @@ rootp=${device}p1 mkfs.ext2 ${rootp} # Create the dirs for the partitions and mount them -mkdir -p "${basedir}"/root -mount ${rootp} "${basedir}"/root +mkdir -p "${base_dir}"/root +mount ${rootp} "${base_dir}"/root # We do this down here to get rid of the build system's resolv.conf after running through the build echo "nameserver ${nameserver}" > "${work_dir}"/etc/resolv.conf @@ -552,14 +552,14 @@ UUID=$(blkid -s UUID -o value ${rootp}) echo "UUID=$UUID / $fstype errors=remount-ro 0 1" >> ${work_dir}/etc/fstab echo "Rsyncing rootfs into image file" -rsync -HPavz -q ${work_dir}/ ${basedir}/root/ +rsync -HPavz -q ${work_dir}/ ${base_dir}/root/ # Unmount partitions sync umount ${rootp} kpartx -dv ${loopdevice} -cd "${basedir}" +cd "${base_dir}" wget ftp://ftp.denx.de/pub/u-boot/u-boot-2018.05.tar.bz2 tar xvf u-boot-2018.05.tar.bz2 && cd u-boot-2018.05 make distclean @@ -593,16 +593,16 @@ limit_cpu (){ if [ $compress = xz ]; then if [ $(arch) == 'x86_64' ]; then - echo "Compressing ${imagename}.img" + echo "Compressing ${image_name}.img" [ $(nproc) \< 3 ] || cpu_cores=3 # cpu_cores = Number of cores to use - limit_cpu pixz -p ${cpu_cores:-2} ${current_dir}/${imagename}.img # -p Nº cpu cores use - chmod 0644 ${current_dir}/${imagename}.img.xz + limit_cpu pixz -p ${cpu_cores:-2} ${current_dir}/${image_name}.img # -p Nº cpu cores use + chmod 0644 ${current_dir}/${image_name}.img.xz fi else - chmod 0644 ${current_dir}/${imagename}.img + chmod 0644 ${current_dir}/${image_name}.img fi # Clean up all the temporary build stuff and remove the directories # Comment this out to keep things around if you want to see what may have gone wrong echo "Removing build directory" -rm -rf "${basedir}" +rm -rf "${base_dir}" diff --git a/usb-armory-mkii.sh b/usb-armory-mkii.sh index 76b8875..def6e7a 100755 --- a/usb-armory-mkii.sh +++ b/usb-armory-mkii.sh @@ -228,11 +228,11 @@ make_image # Create the disk partitions log "Create the disk partitions" green -parted -s ${current_dir}/${imagename}.img mklabel msdos -parted -s -a minimal ${current_dir}/${imagename}.img mkpart primary ext2 5MiB 100% +parted -s ${current_dir}/${image_name}.img mklabel msdos +parted -s -a minimal ${current_dir}/${image_name}.img mkpart primary ext2 5MiB 100% # Set the partition variables -loopdevice=$(losetup --show -fP "${current_dir}/${imagename}.img") +loopdevice=$(losetup --show -fP "${current_dir}/${image_name}.img") rootp="${loopdevice}p1" # Create file systems @@ -241,8 +241,8 @@ mkfs.ext2 ${rootp} # Create the dirs for the partitions and mount them log "Create the dirs for the partitions and mount them" green -mkdir -p "${basedir}"/root -mount ${rootp} "${basedir}"/root +mkdir -p "${base_dir}"/root +mount ${rootp} "${base_dir}"/root # Create an fstab so that we don't mount / read-only log "/etc/fstab" green @@ -250,7 +250,7 @@ UUID=$(blkid -s UUID -o value ${rootp}) echo "UUID=$UUID / $fstype errors=remount-ro 0 1" >> ${work_dir}/etc/fstab log "Rsyncing rootfs into image file" green -rsync -HPavz -q "${work_dir}"/ "${basedir}"/root/ +rsync -HPavz -q "${work_dir}"/ "${base_dir}"/root/ sync log "u-Boot" green diff --git a/utilite-pro.sh b/utilite-pro.sh index 6fd7aca..ae577d4 100755 --- a/utilite-pro.sh +++ b/utilite-pro.sh @@ -25,7 +25,7 @@ machine=$(tr -cd 'A-Za-z0-9' < /dev/urandom | head -c16 ; echo) # Custom hostname variable hostname=${2:-kali} # Custom image file name variable - MUST NOT include .img at the end -imagename=${3:-kali-linux-$1-utilite-pro} +image_name=${3:-kali-linux-$1-utilite-pro} # Suite to use, valid options are: # kali-rolling, kali-dev, kali-bleeding-edge, kali-dev-only, kali-experimental, kali-last-snapshot suite=${suite:-"kali-rolling"} @@ -67,20 +67,20 @@ fi # Current directory current_dir="$(pwd)" # Base directory -basedir=${current_dir}/utilite-"$1" +base_dir=${current_dir}/utilite-"$1" # Working directory -work_dir="${basedir}/kali-${architecture}" +work_dir="${base_dir}/kali-${architecture}" # Check directory build -if [ -e "${basedir}" ]; then - echo "${basedir} directory exists, will not continue" >&2 +if [ -e "${base_dir}" ]; then + echo "${base_dir} directory exists, will not continue" >&2 exit 1 elif [[ ${current_dir} =~ [[:space:]] ]]; then echo "The directory "\"${current_dir}"\" contains whitespace. Not supported." >&2 exit 1 else - echo "The basedir thinks it is: ${basedir}" - mkdir -p ${basedir} + echo "The base_dir thinks it is: ${base_dir}" + mkdir -p ${base_dir} fi components="main,contrib,non-free" @@ -351,7 +351,7 @@ proc /proc proc defaults 0 0 /dev/mmcblk0p1 /boot vfat defaults 0 2 EOF -cd ${basedir} +cd ${base_dir} # Clone a cross compiler to use instead of the Kali one due to kernel age git clone --depth 1 https://gitlab.com/kalilinux/packages/gcc-arm-linux-gnueabihf-4-7.git gcc-arm-linux-gnueabihf-4.7 @@ -372,14 +372,14 @@ cp ${current_dir}/kernel-configs/utilite-3.10.config .config cp ${current_dir}/kernel-configs/utilite-3.10.config ${work_dir}/usr/src/utilite-3.10.config touch .scmversion export ARCH=arm -export CROSS_COMPILE="${basedir}"/gcc-arm-linux-gnueabihf-4.7/bin/arm-linux-gnueabihf- +export CROSS_COMPILE="${base_dir}"/gcc-arm-linux-gnueabihf-4.7/bin/arm-linux-gnueabihf- make -j $(grep -c processor /proc/cpuinfo) make modules_install INSTALL_MOD_PATH=${work_dir} cp arch/arm/boot/zImage ${work_dir}/boot/zImage-cm-fx6 cp arch/arm/boot/dts/imx6q-sbc-fx6m.dtb ${work_dir}/boot/imx6q-sbc-fx6m.dtb make mrproper cp ../utilite-3.10.config .config -cd "${basedir}" +cd "${base_dir}" # Fix up the symlink for building external modules # kernver is used so we don't need to keep track of what the current compiled @@ -390,7 +390,7 @@ rm build rm source ln -s /usr/src/kernel build ln -s /usr/src/kernel source -cd "${basedir}" +cd "${base_dir}" # Create a file to set up our u-boot environment cat << EOF > ${work_dir}/boot/boot.txt @@ -413,7 +413,7 @@ EOF # And generate the boot.scr mkimage -A arm -T script -C none -d ${work_dir}/boot/boot.txt ${work_dir}/boot/boot.scr -cd "${basedir}" +cd "${base_dir}" # Calculate the space to create the image root_size=$(du -s -B1 ${work_dir} --exclude=${work_dir}/boot | cut -f1) @@ -421,14 +421,14 @@ root_extra=$((${root_size}/1024/1000*5*1024/5)) raw_size=$(($((${free_space}*1024))+${root_extra}+$((${bootsize}*1024))+4096)) # Create the disk and partition it -echo "Creating image file ${imagename}.img" -fallocate -l $(echo ${raw_size}Ki | numfmt --from=iec-i --to=si) ${current_dir}/${imagename}.img -parted -s ${current_dir}/${imagename}.img mklabel msdos -parted -s ${current_dir}/${imagename}.img mkpart primary fat32 1MiB ${bootsize}MiB -parted -s -a minimal ${current_dir}/${imagename}.img mkpart primary $fstype ${bootsize}MiB 100% +echo "Creating image file ${image_name}.img" +fallocate -l $(echo ${raw_size}Ki | numfmt --from=iec-i --to=si) ${current_dir}/${image_name}.img +parted -s ${current_dir}/${image_name}.img mklabel msdos +parted -s ${current_dir}/${image_name}.img mkpart primary fat32 1MiB ${bootsize}MiB +parted -s -a minimal ${current_dir}/${image_name}.img mkpart primary $fstype ${bootsize}MiB 100% # Set the partition variables -loopdevice=`losetup -f --show ${current_dir}/${imagename}.img` +loopdevice=`losetup -f --show ${current_dir}/${image_name}.img` device=`kpartx -va ${loopdevice} | sed 's/.*\(loop[0-9]\+\)p.*/\1/g' | head -1` sleep 5 device="/dev/mapper/${device}" @@ -447,10 +447,10 @@ fi mkfs $features -t $fstype -L ROOTFS ${rootp} # Create the dirs for the partitions and mount them -mkdir -p "${basedir}"/root -mount ${rootp} "${basedir}"/root -mkdir -p "${basedir}"/root/boot -mount ${bootp} "${basedir}"/root/boot +mkdir -p "${base_dir}"/root +mount ${rootp} "${base_dir}"/root +mkdir -p "${base_dir}"/root/boot +mount ${bootp} "${base_dir}"/root/boot # We do this down here to get rid of the build system's resolv.conf after running through the build echo "nameserver ${nameserver}" > "${work_dir}"/etc/resolv.conf @@ -460,7 +460,7 @@ UUID=$(blkid -s UUID -o value ${rootp}) echo "UUID=$UUID / $fstype errors=remount-ro 0 1" >> ${work_dir}/etc/fstab echo "Rsyncing rootfs into image file" -rsync -HPavz -q ${work_dir}/ ${basedir}/root/ +rsync -HPavz -q ${work_dir}/ ${base_dir}/root/ # Unmount partitions sync @@ -493,16 +493,16 @@ limit_cpu (){ if [ $compress = xz ]; then if [ $(arch) == 'x86_64' ]; then - echo "Compressing ${imagename}.img" + echo "Compressing ${image_name}.img" [ $(nproc) \< 3 ] || cpu_cores=3 # cpu_cores = Number of cores to use - limit_cpu pixz -p ${cpu_cores:-2} ${current_dir}/${imagename}.img # -p Nº cpu cores use - chmod 0644 ${current_dir}/${imagename}.img.xz + limit_cpu pixz -p ${cpu_cores:-2} ${current_dir}/${image_name}.img # -p Nº cpu cores use + chmod 0644 ${current_dir}/${image_name}.img.xz fi else - chmod 0644 ${current_dir}/${imagename}.img + chmod 0644 ${current_dir}/${image_name}.img fi # Clean up all the temporary build stuff and remove the directories # Comment this out to keep things around if you want to see what may have gone wrong echo "Removing temporary build files" -rm -rf "${basedir}" +rm -rf "${base_dir}"