From 97b219cb13e27b8d3110402c4e0d3faf18bb213d Mon Sep 17 00:00:00 2001 From: timoxa0 Date: Sun, 27 Oct 2024 15:36:30 +0500 Subject: [PATCH] Initial commit --- LICENSE | 65 +++++++++++++ common.d/build_functions.sh | 178 ++++++++++++++++++++++++++++++++++++ common.d/functions.sh | 120 ++++++++++++++++++++++++ common.d/variables.sh | 4 + compress.sh | 32 +++++++ drop/00_image_builder | 2 + drop/fstab | 7 ++ drop/mirrorlist | 59 ++++++++++++ drop/monitors.xml | 28 ++++++ drop/postinstall | 3 + drop/sddm.nabu.Xsetup | 4 + drop/sddm.nabu.conf | 9 ++ drop/simpleinit.uefi.cfg | 36 ++++++++ drop/zram-generator.conf | 3 + makelni | 114 +++++++++++++++++++++++ test.sh | 2 + 16 files changed, 666 insertions(+) create mode 100644 LICENSE create mode 100644 common.d/build_functions.sh create mode 100644 common.d/functions.sh create mode 100644 common.d/variables.sh create mode 100755 compress.sh create mode 100644 drop/00_image_builder create mode 100644 drop/fstab create mode 100644 drop/mirrorlist create mode 100644 drop/monitors.xml create mode 100644 drop/postinstall create mode 100644 drop/sddm.nabu.Xsetup create mode 100644 drop/sddm.nabu.conf create mode 100644 drop/simpleinit.uefi.cfg create mode 100644 drop/zram-generator.conf create mode 100755 makelni create mode 100644 test.sh diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..8f5488f --- /dev/null +++ b/LICENSE @@ -0,0 +1,65 @@ +Copyright (c) 2024 timoxa0 + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Package linux-nabu contains linux kernel redistributed under GPL-2.0 WITH Linux-syscall-note + +Package qcom-services contains software redistributed under BSD-3-Clause license: +qrtr-ns: + Copyright (c) 2015, Sony Mobile Communications Inc. + All rights reserved. + +pd-mapper: + Copyright (c) 2018, Linaro Ltd. + All rights reserved. + + Copyright (c) 2016, Bjorn Andersson + All rights reserved. + +rmtfs: + Copyright (c) 2016, Linaro Ltd + All rights reserved. + +tqftpserv: + Copyright (c) 2018, Linaro Ltd. + All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the organization nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + diff --git a/common.d/build_functions.sh b/common.d/build_functions.sh new file mode 100644 index 0000000..13d9a04 --- /dev/null +++ b/common.d/build_functions.sh @@ -0,0 +1,178 @@ +#!/usr/bin/env bash + +get_image_path() +{ + printf "%s" "$(realpath "./raw/${1}.img")" +} + +setup_inet() +{ + local rootdir="$1" + [ ! -d "$rootdir" ] && { + log "Rootdir [$rootdir] does not exists" ierror + return 2 + } + + echo "nameserver 1.1.1.1" > "$rootdir/etc/resolv.conf" + echo "xiaomi-nabu" > "$rootdir/etc/hostname" + echo "127.0.0.1 localhost + 127.0.1.1 xiaomi-nabu" > "$rootdir/etc/hosts" +} + +create_image() +{ + name="$(get_image_path "$1")" + if [ -z "$2" ]; then + size="$DEFAULT_IMAGE_SIZE" + else + size="${2}GB" + fi + + if [ -f "$name" ]; then + rm "$name" + fi + + truncate --size "$size" "$name" || { + log "Failed to cretae image [$name]" ierror + return 1 + } + mkfs.ext4 "$name" +} + +trim_image() +{ + { + name="$(get_image_path "$1")" + e2fsck -f "$name" + resize2fs -M "$name" + } || { + log "Failed to trim image" ierror + return 1 + } +} + +# shellcheck disable=SC2155 +mount_image() +{ + local rootdir="$1" + [ ! -d "$rootdir" ] && { + log "Rootdir [$rootdir] does not exists" ierror + return 2 + } + local mountdir="$(mktemp --tmpdir=./tmp/ -d)" + local mountdir="$(realpath "$mountdir")" + + mount -o loop "$(get_image_path "$1")" "$mountdir" || { + log "Failed to mount image" ierror + return 1 + } + + mkdir -p "$mountdir/boot/efi" + mkdir -p "$mountdir/boot/simpleinit" + + mount -o size=512M,mode=0755 -t tmpfs nabu_esp "$mountdir/boot/efi" + mount -o size=512M,mode=0755 -t tmpfs nabu_simpleinit "$mountdir/boot/simpleinit" + + sed "s|{cmdline}|$SIMPLEINIT_CMDLINE|g" < ./drop/simpleinit.uefi.cfg > "$mountdir/boot/simpleinit/simpleinit.uefi.cfg" + printf "%s" "$mountdir" +} + +gen_fstab() +{ + local rootdir="$1" + [ ! -d "$rootdir" ] && { + log "Rootdir [$rootdir] does not exists" ierror + return 2 + } + + if [ -d "$rootdir/etc/" ]; then + [ -f "$rootdir/etc/fstab" ] && rm "$rootdir/etc/fstab" + cp ./drop/fstab "$rootdir/etc/fstab" + fi +} + +umount_image() +{ + local rootdir="$1" + [ ! -d "$rootdir" ] && { + log "Rootdir [$rootdir] does not exists" ierror + return 2 + } + + rootdir="$(realpath "${1}")" + mkdir "$rootdir/opt/nabu/" -p + tar -cf "$rootdir/opt/nabu/efi.tar" -C "$rootdir/" boot/ + cp ./drop/postinstall "$rootdir/opt/nabu/postinstall" + chmod +x "$rootdir/opt/nabu/postinstall" + + umount "$rootdir/boot/efi" > /dev/null 2>&1 + umount "$rootdir/boot/simpleinit" > /dev/null 2>&1 + umount "$rootdir" > /dev/null 2>&1 + rm -d "$rootdir" > /dev/null 2>&1 +} + +prepare_chroot() +{ + local rootdir="$1" + [ ! -d "$rootdir" ] && { + log "Rootdir [$rootdir] does not exists" ierror + return 2 + } + + export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:\$PATH + rootdir="$(realpath "$1")" + + mount --bind /proc "$rootdir/proc" > /dev/null 2>&1 + mount --bind /sys "$rootdir/sys" > /dev/null 2>&1 + mount --bind /dev "$rootdir/dev" > /dev/null 2>&1 + mount --bind /dev/pts "$rootdir/dev/pts" > /dev/null 2>&1 + + if uname -m | grep -q aarch64 || [ -f "/proc/sys/fs/binfmt_misc/qemu-aarch64" ]; then + log "Cancel qemu install for arm64" internal + else + wget -N https://github.com/multiarch/qemu-user-static/releases/download/v7.2.0-1/qemu-aarch64-static -O ./cache/qemu-aarch64-static + install -m755 ./cache/qemu-aarch64-static "$rootdir/" + + # shellcheck disable=SC2028 + echo ':aarch64:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/qemu-aarch64-static:' > /proc/sys/fs/binfmt_misc/register + + # shellcheck disable=SC2028 + echo ':aarch64ld:M::\x7fELF\x02\x01\x01\x03\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\xb7:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/qemu-aarch64-static:' > /proc/sys/fs/binfmt_misc/register + + fi +} + +detach_chroot() +{ + local rootdir="$1" + [ ! -d "$rootdir" ] && { + log "Rootdir [$rootdir] does not exists" ierror + return 2 + } + + rootdir=$(realpath "$1") + blocking=$(lsof -t "$rootdir") + if [ -n "$blocking" ]; then + kill -9 "$blocking" + fi + killall gpg-agent > /dev/null 2>&1 + umount "$rootdir/proc" > /dev/null 2>&1 + umount "$rootdir/sys" > /dev/null 2>&1 + umount "$rootdir/dev/pts" > /dev/null 2>&1 + umount "$rootdir/dev" > /dev/null 2>&1 + + if uname -m | grep -q aarch64; then + log "Cancel qemu uninstall for arm64" internal + else + if [ -f "/proc/sys/fs/binfmt_misc/aarch64" ]; then + echo -1 > /proc/sys/fs/binfmt_misc/aarch64 + fi + if [ -f "/proc/sys/fs/binfmt_misc/aarch64ld" ]; then + echo -1 > /proc/sys/fs/binfmt_misc/aarch64ld + fi + if [ -f "$rootdir/qemu-aarch64-static" ]; then + rm "$rootdir/qemu-aarch64-static" + fi + fi +} + diff --git a/common.d/functions.sh b/common.d/functions.sh new file mode 100644 index 0000000..fd26deb --- /dev/null +++ b/common.d/functions.sh @@ -0,0 +1,120 @@ +#!/usr/bin/env bash + +source ./common.d/variables.sh + +log() +{ + case "$2" in + error) + printf "\e[1m\e[31mERROR:\e[0m \e[1m%s\e[0m\n" "$1";; + internal) + printf "\e[1m\e[96m >>\e[0m \e[1m%s\e[0m\n" "$1";; + ierror) + printf "\e[1m\e[31m >>\e[0m \e[1m%s\e[0m\n" "$1";; + *) + printf "\e[1m\e[92m>>>\e[0m \e[1m%s\e[0m\n" "$1";; + esac +} + +mkdir_if_not_exists () +{ + [ -d "$1" ] && return 0 + [ -f "$1" ] && rm -f "$1" + mkdir "$1" +} + +prepare_env() +{ + mkdir_if_not_exists "./cache" + mkdir_if_not_exists "./out" + mkdir_if_not_exists "./raw" + mkdir_if_not_exists "./tmp" +} + +require () +{ + which "$1" > /dev/null 2>&1 || + { + log "$1 not found" error + exit 1 + } +} + +# shellcheck disable=SC2161 +# shellcheck disable=SC2086 +arguments() { + while [[ $# -gt 0 ]]; do + opt="$1" + + shift + + case "$(echo ${opt} | tr '[:upper:]' '[:lower:]')" in + -c | --cleanup) + cleanup ;; + + -h | -help | --help) + usage ;; + + *) + export LNIBUILD="$1" + break 2 ;; + esac + done +} + + +usage() { + log "Usage commands:" + + cat < +EOF + exit 0 +} + +# shellcheck disable=SC2162 +cleanup() +{ + source ./common.d/build_functions.sh + find ./tmp/ -mindepth 1 -maxdepth 1 | read || { + [ -z ${quiet+x} ] && log "Nothing to clean" error + exit 0 + } + + for d in ./tmp/*/; do + log "Unmounting $d" + detach_chroot "$d" + umount "$d/boot/simpleinit" 2> /dev/null + umount "$d/boot/efi" 2> /dev/null + umount ./tmp/tmp.* 2> /dev/null + rm -d "$d" + done + exit 0 +} + +# shellcheck disable=SC2317 +_shutdown() +{ + quiet='' cleanup + if [ -z ${1+x} ]; then + exit 0 + else + exit "$1" + fi +} + +sigterm_handler() +{ + sig=$? + printf "\e[1m\e[31m>>\e[0m \e[1m%s\e[0m\n" "Shutdown signal received." + _shutdown $sig +} + +trap 'trap " " SIGINT SIGTERM SIGHUP; kill 0; wait; sigterm_handler' SIGINT SIGTERM SIGHUP diff --git a/common.d/variables.sh b/common.d/variables.sh new file mode 100644 index 0000000..231f492 --- /dev/null +++ b/common.d/variables.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +export SIMPLEINIT_CMDLINE="root=PARTLABEL=linux loglevel=3 fbcon=rotate:1" +export DEFAULT_IMAGE_SIZE="10GB" + diff --git a/compress.sh b/compress.sh new file mode 100755 index 0000000..a6f5d3c --- /dev/null +++ b/compress.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash +source common.sh + +# Ensure that lon-tool installed +which lon-tool > /dev/null 2>&1 || { + log_err "lon-tool not found" + exit 1 +} + +# shellcheck disable=SC2162 +find ./raw/ -mindepth 1 -maxdepth 1 | read || { + log_err "Nothing to compress" + exit 1 +} + +# Settings +DATE=$(date +"%d-%m-%y") + +# Begin script +log "Start compressing images" +log "Current date: ${DATE}" + +for image in raw/*; do + full_image_path=$(realpath "$image") + image_name=$(basename "$full_image_path") + lni_name="${image_name/.img/""}" + full_lni_path=$(realpath "./out/${image_name/.img/".lni"}") + log "Compressing $lni_name" + lon-tool image create -n "$lni_name" -v "$DATE" "$full_image_path" "$full_lni_path" +done + +log "Stop compressing images" diff --git a/drop/00_image_builder b/drop/00_image_builder new file mode 100644 index 0000000..bf61b34 --- /dev/null +++ b/drop/00_image_builder @@ -0,0 +1,2 @@ +# /etc/sudoers.d/00_image_builder +%wheel ALL=(ALL:ALL) ALL \ No newline at end of file diff --git a/drop/fstab b/drop/fstab new file mode 100644 index 0000000..7458a62 --- /dev/null +++ b/drop/fstab @@ -0,0 +1,7 @@ +# /etc/fstab: static file system information. +# +# +PARTLABEL=linux / ext4 errors=remount-ro,x-systemd.growfs 0 1 +PARTLABEL=esp /boot/efi/ vfat defaults,umask=0022 0 1 +PARTLABEL=logfs /boot/simpleinit/ vfat defaults,umask=0022 0 1 +/dev/zram0 none swap defaults,pri=100,nofail 0 0 diff --git a/drop/mirrorlist b/drop/mirrorlist new file mode 100644 index 0000000..abaca0f --- /dev/null +++ b/drop/mirrorlist @@ -0,0 +1,59 @@ +# /etc/pacman.d/mirrorlist +# ALArm only +# +# Arch Linux ARM repository mirrorlist +# Generated on 2023-02-06 +# + +### Mirrors by country + +### Denmark +## Aalborg +# Server = http://dk.mirror.archlinuxarm.org/$arch/$repo + +### Germany +## Aachen +# Server = http://de3.mirror.archlinuxarm.org/$arch/$repo +## Berlin +# Server = http://de.mirror.archlinuxarm.org/$arch/$repo +## Coburg +# Server = http://de4.mirror.archlinuxarm.org/$arch/$repo +## Falkenstein +Server = http://eu.mirror.archlinuxarm.org/$arch/$repo +# Server = http://de5.mirror.archlinuxarm.org/$arch/$repo + +### Greece +## Athens +# Server = http://gr.mirror.archlinuxarm.org/$arch/$repo + +### Hungary +## Budapest +# Server = http://hu.mirror.archlinuxarm.org/$arch/$repo + +### Japan +## Tokyo +# Server = http://jp.mirror.archlinuxarm.org/$arch/$repo + +### Singapore +# Server = http://sg.mirror.archlinuxarm.org/$arch/$repo + +### Taiwan +## Hsinchu +# Server = http://tw2.mirror.archlinuxarm.org/$arch/$repo +## New Taipei City +# Server = http://tw.mirror.archlinuxarm.org/$arch/$repo + +### United Kingdom +## London +# Server = http://uk.mirror.archlinuxarm.org/$arch/$repo + +### United States +## California +# Server = http://ca.us.mirror.archlinuxarm.org/$arch/$repo +## Florida +# Server = http://fl.us.mirror.archlinuxarm.org/$arch/$repo +## New Jersey +# Server = http://nj.us.mirror.archlinuxarm.org/$arch/$repo + +## Geo-IP based mirror selection and load balancing +Server = http://mirror.archlinuxarm.org/$arch/$repo diff --git a/drop/monitors.xml b/drop/monitors.xml new file mode 100644 index 0000000..d95d229 --- /dev/null +++ b/drop/monitors.xml @@ -0,0 +1,28 @@ + + + + + 0 + 0 + 2 + yes + + right + no + + + + DSI-1 + unknown + unknown + unknown + + + 1600 + 2560 + 104.000 + + + + + diff --git a/drop/postinstall b/drop/postinstall new file mode 100644 index 0000000..17ff1fb --- /dev/null +++ b/drop/postinstall @@ -0,0 +1,3 @@ +#!/bin/bash +# /opt/nabu/postinstall +tar -xf /opt/nabu/efi.tar -C / || true \ No newline at end of file diff --git a/drop/sddm.nabu.Xsetup b/drop/sddm.nabu.Xsetup new file mode 100644 index 0000000..b5928ed --- /dev/null +++ b/drop/sddm.nabu.Xsetup @@ -0,0 +1,4 @@ +#!/bin/sh +# Xsetup - run as root before the login dialog appears +xrandr --output DSI-1 --rotate right +xinput set-prop "NVTCapacitiveTouchScreen" "Coordinate Transformation Matrix" 0 1 0 -1 0 1 0 0 1 diff --git a/drop/sddm.nabu.conf b/drop/sddm.nabu.conf new file mode 100644 index 0000000..e7ea1b4 --- /dev/null +++ b/drop/sddm.nabu.conf @@ -0,0 +1,9 @@ +[General] +DisplayServer=x11 +InputMethod=qtvirtualkeyboard + +[Theme] +Current=breeze + +[X11] +DisplayCommand=/usr/share/sddm/scripts/Xsetup diff --git a/drop/simpleinit.uefi.cfg b/drop/simpleinit.uefi.cfg new file mode 100644 index 0000000..98e35a5 --- /dev/null +++ b/drop/simpleinit.uefi.cfg @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- +## +## Simple Init Configuration Store For UEFI +## + +boot.configs.continue.mode = 10 +boot.configs.continue.show = false +boot.configs.uefi_boot_menu.mode = 12 +boot.configs.uefi_boot_menu.show = false +boot.configs.linux.mode = 8 +boot.configs.linux.desc = "Linux" +boot.configs.linux.show = true +boot.configs.linux.enabled = true +boot.configs.linux.icon = "linux.svg" +boot.configs.linux.extra.use_uefi = true +boot.configs.linux.extra.kernel = "@part_esp:\\vmlinuz-6.1.10-nabu" +boot.configs.linux.extra.dtb = "@part_esp:\\dtb-6.1.10-nabu" +boot.configs.linux.extra.skip_kernel_fdt_cmdline = true +boot.configs.linux.extra.update_splash = false +boot.configs.linux.extra.cmdline = "{cmdline}" +boot.default = "reboot-payload" +boot.second = "simple-init" +boot.uefi_probe = false +boot.title = "Select OS" +boot.timeout_text = "Timeout: %d" +sw = 8 +gui.show_background = true +gui.background = "" +locates.part_logfs.by_disk_label = "gpt" +locates.part_logfs.by_gpt_name = "logfs" +locates.part_esp.by_disk_label = "gpt" +locates.part_esp.by_gpt_name = "esp" +locates.part_boot.by_disk_label = "gpt" +locates.part_boot.by_gpt_name = "boot" + +# vim: ts=8 sw=8 \ No newline at end of file diff --git a/drop/zram-generator.conf b/drop/zram-generator.conf new file mode 100644 index 0000000..42c04fc --- /dev/null +++ b/drop/zram-generator.conf @@ -0,0 +1,3 @@ +# /etc/systemd/zram-generator.conf +[zram0] +zram-size = ram \ No newline at end of file diff --git a/makelni b/makelni new file mode 100755 index 0000000..5187c2a --- /dev/null +++ b/makelni @@ -0,0 +1,114 @@ +#!/usr/bin/env bash +source ./common.d/functions.sh +source ./common.d/variables.sh + +if [ "$(id -u)" != "0" ]; then + log "$0 must be run as root" + exit 3 +fi + +arguments "$@" + +[[ -z $LNIBUILD ]] && { + log "No LNIBUILD specified" error + exit 1 +} + +prepare_env + +lni_path=$(realpath "$LNIBUILD") + +source "$lni_path" + +lnib_has_errors="n" +[ -z ${name+x} ] && { + log "LNIBUILD: missing name" ierror + lnib_has_errors="y" +} + +[ -z ${image_type+x} ] && { + log "LNIBUILD: missing image_type" ierror + lnib_has_errors="y" +} + +[ -z ${zram+x} ] && { + log "LNIBUILD: missing zram" ierror + lnib_has_errors="y" +} + +[ -z ${packages+x} ] && { + log "LNIBUILD: missing packages" ierror + lnib_has_errors="y" +} + +[ ! -f "./common.d/common.${image_type}.sh" ] && { + log "LNIBUILD: unsupported image type" ierror + lnib_has_errors="y" +} + +[ "$lnib_has_errors" == "y" ] && { + log "Incorrect LNIBUILD" error + exit 2 +} + +source "./common.d/common.${image_type}.sh" +log "Making image: $name" +log "Image type: $image_type" + +log "Creating image: $(get_image_path "$name")" +create_image "$name" || _shutdown 1 +imageroot="$(mount_image "$name")" + +log "Fetching base system" +base_system || _shutdown 1 + +log "Preparing chroot" +prepare_chroot "$imageroot" || _shutdown 1 + +[[ $(type -t pre_install) == function ]] && { + log "Running pre install hook" + pre_install || _shutdown 1 +} + +log "Setting up inet" +setup_inet "$imageroot" || _shutdown 1 + +log "Prepare system" +prepare_system "$imageroot" || _shutdown 1 + +if (( ${#packages[@]} )); then + log "Installing packages: ${packages[*]}" + install_packages "$imageroot" "${packages[@]}" || _shutdown 1 +fi + +log "Installing kernel and firmwares" +log "Configuring dynamic linker run-time bindings" +log "Enabling userspace daemons" +install_nabu_packages "$imageroot" || _shutdown 1 + +if [ "$zram" == "y" ]; then + log "Setting up zram" + setup_zram_generator "$imageroot" || _shutdown 1 +fi + +log "Finishing system image" +finish_system "$imageroot" || _shutdown 1 + +log "Generating fstab" +gen_fstab "$imageroot" || _shutdown 1 + +[[ $(type -t post_install) == function ]] && { + log "Running post install hook" + post_install || _shutdown 1 +} + +log "Detaching chroot" +detach_chroot "$imageroot" || _shutdown 1 + +log "Unmounting image" +umount_image "$imageroot" || _shutdown 1 + +log "Trimming image" +trim_image "$name" || _shutdown 1 + +log "Image build finished" diff --git a/test.sh b/test.sh new file mode 100644 index 0000000..0da3f2d --- /dev/null +++ b/test.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +which lon-tool