├── .gitignore ├── firstrun.sh ├── sata-install.sh ├── mmc-install.sh ├── README.md └── novena-image.sh /.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | *.swo 3 | *.deb 4 | -------------------------------------------------------------------------------- /firstrun.sh: -------------------------------------------------------------------------------- 1 | sudo dpkg-reconfigure user-setup console-data locales tzdata 2 | -------------------------------------------------------------------------------- /sata-install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [ -z $1 ] 3 | then 4 | echo "Usage: $0 [device]" 5 | echo "E.g. $0 /dev/mmcblk1" 6 | exit 1 7 | fi 8 | 9 | echo "Constructing a disk image on $1" 10 | exec sudo ./novena-image.sh \ 11 | -d $1 \ 12 | -t sata \ 13 | -s jessie \ 14 | -l "sudo openssh-server ntp ntpdate dosfstools btrfs-tools \ 15 | novena-eeprom xserver-xorg-video-modesetting task-xfce-desktop \ 16 | hicolor-icon-theme gnome-icon-theme tango-icon-theme keychain \ 17 | avahi-daemon avahi-dnsconfd libnss-mdns btrfs-tools \ 18 | parted debootstrap python build-essential xscreensaver vlc vim \ 19 | emacs x11-xserver-utils usbutils unzip apt-file xz-utils \ 20 | subversion make screen tmux read-edid powertop powermgmt-base \ 21 | pavucontrol p7zip-full paprefs pciutils nmap ntfs-3g \ 22 | network-manager-vpnc network-manager-pptp network-manager-openvpn \ 23 | network-manager-iodine mplayer2 libreoffice imagemagick icedove \ 24 | iceweasel gtkwave gnupg2 git git-email git-man fuse freecad \ 25 | enigmail dc curl clang bridge-utils bluez bluez-tools \ 26 | bluez-hcidump bison bc automake autoconf pidgin alsa-utils verilog \ 27 | i2c-tools hwinfo android-tools-adb android-tools-fastboot \ 28 | android-tools-fsutils bash-completion kicad ncurses-dev gdb lzop \ 29 | gawk bison g++ gcc flex pkg-config valgrind lconv netcat wireshark \ 30 | kismet aircrack-ng socat locales \ 31 | pulseaudio-novena irqbalance-imx novena-disable-ssp \ 32 | u-boot-novena linux-image-novena" \ 33 | ${@:2} 34 | -------------------------------------------------------------------------------- /mmc-install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [ -z $1 ] 3 | then 4 | echo "Usage: $0 [device] " 5 | echo "E.g. $0 /dev/mmcblk1" 6 | exit 1 7 | fi 8 | 9 | echo "Constructing a disk image on $1" 10 | time sudo /bin/bash -x ./novena-image.sh \ 11 | -d $1 \ 12 | -t mmc \ 13 | -s jessie \ 14 | -k kosagi.key \ 15 | -l "sudo openssh-server ntp ntpdate dosfstools novena-eeprom \ 16 | xserver-xorg-video-modesetting arandr user-setup vim emacs \ 17 | keychain locales evtest libbluetooth3 \ 18 | avahi-daemon avahi-dnsconfd libnss-mdns debootstrap \ 19 | python build-essential xscreensaver console-data zip tcpdump \ 20 | x11-xserver-utils usbutils unzip xz-utils subversion git make \ 21 | screen tmux read-edid powertop powermgmt-base pavucontrol \ 22 | p7zip-full paprefs pciutils nmap ntfs-3g network-manager-vpnc \ 23 | network-manager-pptp network-manager-openvpn bash-completion \ 24 | network-manager-iodine hexchat icedove iceweasel gnupg2 unp \ 25 | git-email git-man fuse enigmail dc curl clang bridge-utils \ 26 | bluez bluez-tools bluez-hcidump bison bc automake autoconf \ 27 | pidgin alsa-utils i2c-tools hwinfo android-tools-adb unrar-free \ 28 | android-tools-fastboot android-tools-fsutils smartmontools \ 29 | xfce4-goodies xfce4-power-manager xfce4-mixer xfce4-terminal \ 30 | mousepad orage dbus-x11 irssi strace \ 31 | synaptic pkg-config \ 32 | ncurses-dev gdb lzop gawk bison g++ gcc flex \ 33 | pm-utils qalc memtester locate \ 34 | iptraf iperf iotop initramfs-tools gnupg-agent exfat-fuse \ 35 | exfat-utils dict aptitude libqt5core5a libqt5gui5 \ 36 | libqt5widgets5 console-setup lightdm \ 37 | x11-apps x11-session-utils xbitmaps xfce4 xfce4-appfinder \ 38 | xfce4-notifyd xfce4-session xfce4-settings xfdesktop4 \ 39 | xfdesktop4-data xfonts-100dpi xfonts-75dpi xfonts-scalable \ 40 | xfwm4 xfwm4-themes xinit xorg xorg-docs-core \ 41 | u-boot-novena irqbalance-imx libdrm-armada2-dbg \ 42 | novena-usb-hub libetnaviv-dev libetnaviv-dbg \ 43 | linux-headers-novena linux-image-novena novena-disable-ssp novena-eeprom \ 44 | novena-eeprom-gui kosagi-repo novena-firstrun xorg-novena xserver-xorg-video-armada \ 45 | xserver-xorg-video-armada-dbg xserver-xorg-video-armada-etnaviv" \ 46 | ${@:2} 47 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Novena Image 2 | ============ 3 | 4 | Create Debian disk images that can be used to boot Novena systems. 5 | 6 | 7 | Synopsis 8 | -------- 9 | 10 | The script comes with a help screen that can be used to customize the 11 | resulting image. For examples, see wraper scripts such as "mmc-install.sh" 12 | and "sata-install.sh". 13 | 14 | 15 | Cross-Building 16 | -------------- 17 | 18 | novena-image.sh can be run on ARM or non-ARM systems. Running on a 19 | non-ARM system is a "cross-build" and uses qemu-user to complete the 20 | installation. This require the executable `qemu-arm-static` to be 21 | available somewhere on the PATH. The package that supplies 22 | `qemu-arm-static` on Debian is `qemu-user-static`, on Ubuntu it's 23 | `qemu-arm-static`. 24 | 25 | There may be problems when running on armv7l systems that are set up as 26 | soft-float (not tested, not a common configuration). 27 | 28 | Recommended package lists 29 | ------------------------- 30 | 31 | Different board configurations have different suggested package lists. This 32 | is because different boards have different SD sizes installed. 33 | 34 | For the 4 GB "Bare Board" model and laptop recovery partition, we recommend 35 | the following package list: 36 | 37 | -l "sudo openssh-server ntp ntpdate dosfstools novena-eeprom \ 38 | xserver-xorg-video-modesetting arandr user-setup vim emacs \ 39 | hicolor-icon-theme gnome-icon-theme keychain locales evtest \ 40 | avahi-daemon avahi-dnsconfd libnss-mdns debootstrap psutils \ 41 | python build-essential xscreensaver console-data zip tcpdump \ 42 | x11-xserver-utils usbutils unzip xz-utils subversion git make \ 43 | screen tmux read-edid powertop powermgmt-base pavucontrol \ 44 | p7zip-full paprefs pciutils nmap ntfs-3g network-manager-vpnc \ 45 | network-manager-pptp network-manager-openvpn bash-completion \ 46 | network-manager-iodine hexchat icedove iceweasel gnupg2 unp \ 47 | git-email git-man fuse enigmail dc curl clang bridge-utils \ 48 | bluez bluez-tools bluez-hcidump bison bc automake autoconf \ 49 | pidgin alsa-utils i2c-tools hwinfo android-tools-adb unrar-free \ 50 | android-tools-fastboot android-tools-fsutils smartmontools \ 51 | xfce4-goodies xfce4-power-manager xfce4-mixer xfce4-terminal \ 52 | mousepad orage dbus-x11 quodlibet evince-gtk irssi strace \ 53 | tango-icon-theme network-manager-gnome synaptic pkg-config \ 54 | gnome-orca ncurses-dev gdb lzop gawk bison g++ gcc flex \ 55 | pm-utils qalc qalculate-gtk memtester locate mousetweaks \ 56 | iptraf iperf iotop initramfs-tools gnupg-agent exfat-fuse \ 57 | exfat-utils dict aptitude libqt5core5a libqt5gui5 \ 58 | libqt5widgets5 console-setup lightdm" 59 | 60 | For the 16 GB "Desktop" model and the SSD-based "Laptop" models, the following, 61 | more-complete package list is recommended: 62 | 63 | -l "sudo openssh-server ntp ntpdate dosfstools btrfs-tools novena-eeprom \ 64 | xserver-xorg-video-modesetting task-xfce-desktop hicolor-icon-theme \ 65 | gnome-icon-theme tango-icon-theme keychain avahi-daemon avahi-dnsconfd \ 66 | libnss-mdns btrfs-tools dosfstools parted debootstrap python \ 67 | build-essential xscreensaver vlc vim emacs x11-xserver-utils \ 68 | usbutils unzip apt-file xz-utils subversion git make screen tmux \ 69 | read-edid powertop powermgmt-base pavucontrol p7zip-full paprefs \ 70 | pciutils nmap ntfs-3g network-manager-vpnc network-manager-pptp \ 71 | network-manager-openvpn network-manager-iodine mplayer2 libreoffice \ 72 | imagemagick icedove iceweasel gtkwave gnupg2 git git-email git-man \ 73 | fuse freecad enigmail dc curl clang bridge-utils bluez bluez-tools \ 74 | bluez-hcidump bison bc automake autoconf pidgin alsa-utils verilog \ 75 | i2c-tools hwinfo android-tools-adb android-tools-fastboot \ 76 | android-tools-fsutils libcap-ng0 libglib2.0-0" 77 | -------------------------------------------------------------------------------- /novena-image.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # override with -p 4 | rootpass="kosagi" 5 | 6 | version="1.0" 7 | 8 | # override with -m 9 | mirror="http://127.0.0.1:3142/ftp.hk.debian.org/debian" 10 | 11 | # override with -l 12 | packages="" 13 | 14 | # override with -a 15 | debs="" 16 | 17 | # override with -t 18 | disktype="mmc" 19 | 20 | bootsize=+32M 21 | 22 | # Indicates whether we're bootstrapping onto a real disk 23 | realdisk=0 24 | 25 | # Set to 1 once things get mounted to the root 26 | things_mounted=0 27 | 28 | # Set to 1 (using -q) to skip partitioning, formatting, and bootstrapping. 29 | quick=0 30 | 31 | # If creating a disk using loopback, set to 1 32 | loopback=0 33 | 34 | # This is the size of the "4GiB" cards we've worked with. 35 | loopback_size=3965190144 36 | 37 | # Sometimes the SHA1 sum comes out as all zeroes. For reasons why I don't know. 38 | allzeros_shasum="3b71f43ff30f4b15b5cd85dd9e95ebc7e84eb5a3" 39 | 40 | # Add the Novena repo to sources.list.d, override with --novena-repo or disable with -n 41 | novena_repo="http://127.0.0.1:3142/repo.novena.io/repo" 42 | 43 | # novena-image will automatically detect a non-ARM environment 44 | # and enable cross-debootstrapping 45 | cross=0 46 | 47 | checksha1sum() { 48 | local file="$1" 49 | 50 | if [ ! -z ${file} ] 51 | then 52 | checksum=$(dd if="${file}" bs=1M skip=1 count=1 | shasum - | awk '{print $1}') 53 | if [ "x${checksum}" = "x${allzeros_shasum}" ] 54 | then 55 | fail "Checksum failed. File appears to be all zeroes" 56 | fi 57 | else 58 | info "Not checking file sum" 59 | fi 60 | } 61 | 62 | info() { 63 | func="$(echo "${FUNCNAME[1]}" | tr _ ' ')" 64 | if [ "x${func}" = "x" ] 65 | then 66 | func="main" 67 | fi 68 | FG="1;32m" 69 | BG="40m" 70 | echo -e "[\033[${FG}\033[${BG}${func}\033[0m] $*" 71 | } 72 | 73 | warn() { 74 | func="$(echo "${FUNCNAME[1]}" | tr _ ' ')" 75 | if [ "x${func}" = "x" ] 76 | then 77 | func="main" 78 | fi 79 | FG="1;33m" 80 | BG="40m" 81 | echo -e "[\033[${FG}\033[${BG}${func}\033[0m] $*" 82 | } 83 | 84 | fail() { 85 | func="$(echo "${FUNCNAME[1]}" | tr _ ' ')" 86 | if [ "x${func}" = "x" ] 87 | then 88 | func="main" 89 | fi 90 | FG="1;31m" 91 | BG="40m" 92 | echo -en "[\033[${FG}\033[${BG}${func}\033[0m] " 93 | if [ -z "$1" ] 94 | then 95 | echo "Exiting due to error" 96 | else 97 | echo "Error: $*" 98 | fi 99 | exit 1 100 | } 101 | 102 | unmount_in_dir() { 103 | local dir="$1" 104 | for mnt in $(grep "${dir}" /proc/mounts | awk '{print $2}' | sort -r | uniq) 105 | do 106 | umount "${mnt}" 2> /dev/null || warn "Unable to umount ${mnt}" 107 | done 108 | } 109 | 110 | cleanup() { 111 | if [ ${cross} -ne 0 ] && [ -d "${root}" ]; 112 | then 113 | rm -f "${root}/usr/bin/qemu-arm-static" 114 | fi 115 | rm -f "${tmppkgsrc}" 116 | 117 | info "Unmounting devices from chroot" 118 | unmount_in_dir "${root}" 119 | 120 | if [ ${loopback} -ne 0 ] 121 | then 122 | info "Unmounting loopback" 123 | if [ ! -z "${loopname}" ] 124 | then 125 | losetup -d "${loopname}" 126 | unset loopname 127 | fi 128 | kpartx -v -d "${diskname}" 129 | for disk in $(losetup | grep "${diskname}" | awk '{print $1}') 130 | do 131 | losetup -d "${disk}" 132 | done 133 | fi 134 | } 135 | 136 | partition_disk() { 137 | local diskname="$1" 138 | local disktype="$2" 139 | 140 | if [ -z ${diskname} ] 141 | then 142 | fail "Must specify a path to a disk device" 143 | exit 1 144 | fi 145 | 146 | # Come up with the disk signature based on the requested type 147 | if [ "x${disktype}" = "xmmc" ] 148 | then 149 | # "NovM" 150 | disksig=4e6f764d 151 | swapsize=+32M 152 | elif [ "x${disktype}" = "xsata" ] 153 | then 154 | # "NovS" 155 | disksig=4e6f7653 156 | swapsize=+4G 157 | else 158 | fail "Must specify a disk type of either mmc or sata" 159 | exit 1 160 | fi 161 | 162 | fdisk ${diskname} -C32 -H32 < "${root}/usr/sbin/policy-rc.d" 294 | echo 'echo "All runlevel operations denied by policy" >&2' >> "${root}/usr/sbin/policy-rc.d" 295 | echo 'exit 101' >> "${root}/usr/sbin/policy-rc.d" 296 | mkdir -p "${root}/usr/sbin/" 297 | chmod a+x "${root}/usr/sbin/policy-rc.d" || fail "Couldn't make file executable" 298 | 299 | info "Creating a 'first-run' file" 300 | mkdir -p "${root}/var/lib" 301 | touch "${root}/var/lib/firstrun" 302 | } 303 | 304 | reset_password() { 305 | local root="$1" 306 | local rootpass="$2" 307 | 308 | # Reset the root password 309 | info "Resetting root password to '${rootpass}'" 310 | echo "root:${rootpass}" | chroot "${root}" /usr/sbin/chpasswd || fail "Unable to reset root password" 311 | } 312 | 313 | add_key() { 314 | local root="$1" 315 | local key="$2" 316 | 317 | info "Adding key from ${key}" 318 | if ! chroot "${root}" /usr/bin/apt-key add - < "${key}" 319 | then 320 | error "Unable to add key" 321 | fi 322 | } 323 | 324 | apt_install() { 325 | local root="$1" 326 | local packages="$2" 327 | export DEBIAN_FRONTEND=noninteractive 328 | export DEBCONF_NONINTERACTIVE_SEEN=true 329 | 330 | if [ ${cross} -ne 0 ] 331 | then 332 | # "debootstrap --foreign" creates a blank sources.list 333 | info "Seeding sources.list..." 334 | SOURCEFILE="${root}/etc/apt/sources.list" 335 | echo "deb ${mirror} ${suite} main" > "${SOURCEFILE}" 336 | echo "deb-src ${mirror} ${suite} main" >> "${SOURCEFILE}" 337 | fi 338 | 339 | info "Updating package listing" 340 | chroot "${root}" apt-get -y update || fail "Couldn't update packages" 341 | 342 | info "Cleaning up previous apt-get (if any)" 343 | chroot "${root}" apt-get -y -f install || fail "Couldn't clean up" 344 | 345 | if [ -z "${packages}" ] 346 | then 347 | info "No packages were requested to be installed" 348 | else 349 | info "Installing selected packages: ${packages}" 350 | chroot "${root}" apt-get -y install ${packages} || fail "Couldn't install packages" 351 | fi 352 | 353 | info "Cleaning up downloaded debs" 354 | chroot "${root}" apt-get -y clean || fail "Couldn't clean packages" 355 | } 356 | 357 | deb_install() { 358 | local root="$1" 359 | shift 360 | export DEBIAN_FRONTEND=noninteractive 361 | 362 | while (( "$#" )) 363 | do 364 | pkgfile="$1" 365 | base="$(basename ${pkgfile})" 366 | info "Installing ${base} from ${pkgfile}" 367 | cp "${pkgfile}" "${root}" 368 | chroot "${root}" dpkg -i "${base}" || fail "Couldn't install package ${base} from ${pkgfile}" 369 | chroot "${root}" rm -f "${base}" 370 | shift 371 | done 372 | } 373 | 374 | setup_recovery() { 375 | local root="$1" 376 | 377 | if [ -e "${root}/boot/zImage" -a -e "${root}/boot/novena.dtb" ] 378 | then 379 | if [ -e "${root}/boot/zImage.recovery" ] 380 | then 381 | info "Not setting up recovery kernel, one already exists" 382 | return 383 | fi 384 | 385 | info "Setting up recovery kernel" 386 | cp "${root}/boot/zImage" "${root}/boot/zImage.recovery" || fail "Couldn't copy recovery kernel" 387 | cp "${root}/boot/novena.dtb" "${root}/boot/novena.recovery.dtb" || fail "Couldn't copy recovery device tree file" 388 | else 389 | info "No kernel installed, not setting up recovery kernel" 390 | fi 391 | } 392 | 393 | configure_fstab() { 394 | local root="$1" 395 | 396 | if [ "${disktype}" = "mmc" ] 397 | then 398 | rootpath="/dev/disk/by-path/platform-2198000.usdhc-part" 399 | elif [ "${disktype}" = "sata" ] 400 | then 401 | rootpath="/dev/sda" 402 | else 403 | fail "Unrecognized disktype: ${disktype}" 404 | fi 405 | 406 | cat > "${root}/etc/fstab" < "${root}/etc/hostname" 429 | 430 | info "Enabling serial console support" 431 | chroot "${root}" systemctl enable serial-getty@ttymxc1.service || fail "Couldn't enable serial console" 432 | 433 | info "Allowing scripts to start up on boot" 434 | rm -f "${root}/usr/sbin/policy-rc.d" 435 | } 436 | 437 | write_uboot_spl() { 438 | local root="$1" 439 | local spl="$2" 440 | local device="$3" 441 | 442 | if [ ! -e "${root}/${spl}" ] 443 | then 444 | warn "SPL file '${spl}' does not exist, disk won't boot" 445 | return 1 446 | fi 447 | 448 | info "Writing U-Boot SPL file '${spl}' to disk" 449 | dd if="${root}/${spl}" of="${device}" bs=1024 seek=1 conv=notrunc || fail "Unable to write SPL" 450 | } 451 | 452 | usage() { 453 | echo "Novena Image Creator ${version}" 454 | echo "Generate a root filesystem, and optionally write it to an SD card" 455 | echo "or SATA drive. It will install a complete set of packages and" 456 | echo "prepare the system for first boot." 457 | echo "" 458 | echo "An Internet connection is required." 459 | echo "" 460 | echo "Options:" 461 | echo " -m --mirror Specify which Debian mirror to use." 462 | echo " We suggest using apt-cacher-ng." 463 | echo " -n --no-novena-repo Don't search for packages in the" 464 | echo " Kosagi Novena repo." 465 | echo " --novena-repo Set a different URL to the Kosagi Novena" 466 | echo " repo (default is apt-cacher-ng to repo.novena.io)." 467 | echo " -d --disk A path to the block device to partition," 468 | echo " format, and create the image on. Requires" 469 | echo " you specify a --type as well." 470 | echo " -t --type Either 'mmc' or 'sata', the type of disk" 471 | echo " specified by --disk." 472 | echo " -r --root Directory to install files into. If no --disk" 473 | echo " is specified, then this argument is required." 474 | echo " -p --rootpass Which root password to use. If unspecified," 475 | echo " defaults to 'kosagi'." 476 | echo " -l --packages Specify a space-separated list of packages" 477 | echo " to install." 478 | echo " -s --suite Which Debian suite to install. A list" 479 | echo " of supported suites available may be found" 480 | echo " at /usr/share/debootstrap/scripts" 481 | echo " -a --add-deb Specify additional .deb files to include in" 482 | echo " the disk image. You may use --add-deb" 483 | echo " multiple times to install more than one .deb." 484 | echo " -q --quick Don't repartition, reformat, or botstrap." 485 | echo " -h --help Print this help message." 486 | echo "" 487 | } 488 | 489 | 490 | 491 | ########################################################## 492 | 493 | temp=`getopt -o m:nd:t:p:r:l:s:a:k:hq \ 494 | --long key:,quick,mirror:,no-novena-repo,novena-repo:,disk:,type:,rootpass:,root:,packages:,suite:,add-deb:,help \ 495 | -n 'novena-image' -- "$@"` 496 | if [ $? != 0 ] ; then fail "Terminating..." >&2 ; exit 1 ; fi 497 | eval set -- "$temp" 498 | while true ; do 499 | case "$1" in 500 | -m|--mirror) mirror="$2"; shift 2 ;; 501 | -n|--no-novena-repo) novena_repo=""; shift 1 ;; 502 | --novena-repo) novena_repo="$2"; shift 2 ;; 503 | -k|--key) key="$2"; shift 2 ;; 504 | -d|--disk) diskname="$2"; shift 2 ;; 505 | -t|--type) disktype="$2"; shift 2 ;; 506 | -p|--rootpass) rootpass="$2"; shift 2 ;; 507 | -r|--root) root="$2"; shift 2 ;; 508 | -l|--packages) packages="$2"; info "Packages: $2"; shift 2 ;; 509 | -s|--suite) suite="$2"; shift 2 ;; 510 | -a|--add-deb) debs="${debs} $2"; if [ ! -e "$2" ]; then fail "Couldn't locate package: $2"; fi; shift 2 ;; 511 | -q|--quick) quick=1; shift 1 ;; 512 | -h|--help) usage; exit 0 ;; 513 | --) shift ; break ;; 514 | *) fail "Internal getopt error!" ; exit 1 ;; 515 | esac 516 | done 517 | 518 | if [ -z "${suite}" ] 519 | then 520 | fail "Must specify a suite (e.g. jessie) with -s or --suite" 521 | fi 522 | 523 | if [ "$(id -u)" != "0" ]; then 524 | fail "As scary as it is, this script must be run as root" 525 | fi 526 | 527 | # Unmount things, and generally clean up on exit 528 | trap cleanup EXIT 529 | 530 | # Check for armv7l, enable cross-building otherwise. 531 | if ! uname -m | grep -q armv7l > /dev/null 532 | then 533 | if ! which qemu-arm-static > /dev/null 534 | then 535 | fail "Host system is not non-armhf, so qemu-arm-static must be available on PATH for cross-building." 536 | fi 537 | info "Cross-building Novena image using qemu" 538 | cross=1 539 | fi 540 | 541 | info "Creating a ${disktype} image" 542 | 543 | # If a disk path and a type are specified, we're writing to a real disk 544 | if [ ! -z "${diskname}" ] 545 | then 546 | realdisk=1 547 | info "Ensuring disk is unmounted" 548 | unmount_in_dir "${diskname}" 549 | if [ -z "${root}" ] 550 | then 551 | root="/tmp/newroot.$$" 552 | fi 553 | 554 | if [ ! -e "${diskname}" ] || [ "$(stat -L -c '%F' ${diskname})" != "block special file" ] 555 | then 556 | if [ -e "${diskname}" ] 557 | then 558 | warn "Disk exists, overwriting it" 559 | else 560 | info "Disk does not exist. Creating loopback device." 561 | fi 562 | 563 | loopback=1 564 | # prepare_loopback will partition the disk if necessary 565 | prepare_loopback "${diskname}" "${loopback_size}" "${quick}" 566 | else 567 | 568 | # Partition a regular disk here 569 | if [ ${quick} -ne 1 ] 570 | then 571 | partition_disk "${diskname}" "${disktype}" 572 | fi 573 | fi 574 | prepare_disk "${diskname}" "${disktype}" "${root}" "${quick}" 575 | 576 | elif [ -z "${root}" ] 577 | then 578 | fail "Must specify a root directory with -r or --root" 579 | fi 580 | 581 | checksha1sum "${filename}" 582 | 583 | if [ "${quick}" != "1" ] 584 | then 585 | bootstrap "${suite}" "${root}" "${mirror}" 586 | checksha1sum "${filename}" 587 | fi 588 | 589 | prepare_root "${root}" 590 | checksha1sum "${filename}" 591 | 592 | reset_password "${root}" "${rootpass}" 593 | checksha1sum "${filename}" 594 | 595 | if [ ! -z "${key}" ] 596 | then 597 | add_key "${root}" "${key}" 598 | fi 599 | checksha1sum "${filename}" 600 | 601 | if [ ! -z "${novena_repo}" ] 602 | then 603 | # This file kosagi-tmp.list is temporary while the installer runs only, 604 | # add the kosagi-repo package via -a to have a permanent entry. 605 | info "Adding temporary repo.novena.io to package sources" 606 | tmppkgsrc="${root}/etc/apt/sources.list.d/kosagi-tmp.list" 607 | echo "deb ${novena_repo} ${suite} main" > "${tmppkgsrc}" 608 | echo "deb-src ${novena_repo} ${suite} main" >> "${tmppkgsrc}" 609 | fi 610 | 611 | info "Selected packages: '${packages}'" 612 | apt_install "${root}" "${packages}" 613 | checksha1sum "${filename}" 614 | 615 | if [ ! -z "${debs}" ] 616 | then 617 | deb_install "${root}" ${debs} 618 | checksha1sum "${filename}" 619 | else 620 | info "No additional .deb files were requested" 621 | fi 622 | 623 | configure_fstab "${root}" "${disktype}" 624 | checksha1sum "${filename}" 625 | 626 | setup_recovery "${root}" 627 | checksha1sum "${filename}" 628 | 629 | remove_ssh_keys "${root}" 630 | checksha1sum "${filename}" 631 | 632 | finalize_root "${root}" 633 | checksha1sum "${filename}" 634 | 635 | if [ ${realdisk} -ne 0 ] 636 | then 637 | write_uboot_spl "${root}" "/boot/u-boot.spl" "${diskname}" 638 | checksha1sum "${filename}" 639 | fi 640 | 641 | checksha1sum "${filename}" 642 | --------------------------------------------------------------------------------