commit cf0a59cbf55eb066bd679481ce191fbbf0cc5ae6
parent d2089d9a203f79bb5514488dfe6e4dfe26bbb889
Author: parazyd <parazyd@dyne.org>
Date: Tue, 15 Nov 2016 17:11:32 +0100
Merge branch 'next'
Diffstat:
15 files changed, 837 insertions(+), 2 deletions(-)
diff --git a/config b/config
@@ -19,8 +19,8 @@
## libdevuansdk configuration
-vars+=(release version mirror section)
-arrs+=(core_packages base_packages purge_packages)
+vars+=(release version mirror section blend_name)
+arrs+=(core_packages base_packages purge_packages blend_packages)
os="devuan"
release="jessie"
@@ -29,6 +29,7 @@ mirror="http://auto.mirror.devuan.org/merged"
section="main"
image_name="${os}_${release}_${version}_${arch}"
+[[ -n $blend_name ]] && image_name="${image_name}_${blend_name}"
[[ -n $device_name ]] && image_name="${image_name}_${device_name}"
core_packages=(
@@ -59,6 +60,11 @@ base_packages=(
wpasupplicant
wireless-tools
elinks
+ firmware-linux-free
+ btrfs-tools
+ zsh
+ rsync
+ git-core
)
purge_packages=(
diff --git a/doc/Makefile b/doc/Makefile
@@ -0,0 +1,18 @@
+all: clean html man
+
+html:
+ @echo generating html...
+ @./nanodoc html
+
+man:
+ @echo generating manpages...
+ @./nanodoc man
+
+clean:
+ @echo cleaning...
+ @rm -rf html man nav.html
+ @sed -i -e 's:index.html">.*:html">NAME</a>:' static/head.html
+ @sed -i -e 's:Subtitle">.*:Subtitle">DESC</span>:' static/head.html
+ @sed -i -e 's:libdevuansdk-.*:libdevuansdk-VERSION</a>:' static/foot.html
+
+.PHONY: all html man clean
diff --git a/doc/configuration.7.md b/doc/configuration.7.md
@@ -0,0 +1,52 @@
+configuration
+=============
+
+much of the `libdevuansdk` configuration is done in `libdevuansdk/config`. here
+you can edit the defaults if you wish to do something your needs are expressing.
+
+## config file
+
+`vars` and `arrs` are global arrays holding other global variables and arrays.
+this is required for `zuper` and helps a lot with debugging. if you declare new
+variables or arrays, add them to `vars` and `arrs`, respectively.
+
+* `os`
+ holds the name of the distro being worked on.
+
+* `release`
+ holds the release name of the distro. used for apt repos mostly.
+
+* `version`
+ current version of the distro being worked on.
+
+* `mirror`
+ a mirror holding the packages for `debootstrap`.
+
+* `section`
+ sections of the repo. for adding in `/etc/apt/sources.list`. separate them
+ with whitespaces.
+
+* `image_name`
+ output name of the raw image. if you declare `device_name`, it will be added.
+ `arm-sdk` does this.
+
+* `core_packages`
+ this array holds the core packages that will be installed in the bootstrap
+ process.
+
+* `base_packages`
+ this array holds the base packages that will be installed later in the
+ bootstrap process.
+
+* `purge_packages`
+ this array holds the packages that will get purged at the end of the bootstrap
+ process.
+
+
+## overriding things
+
+to be able to override specific unwanted functions of libdevuansdk, consider
+sourcing it earlier in the process of initialization.
+
+it is possible to override default variables, or even functions without the need
+of editing libdevuansdk. share a patch with me if you wish :)
diff --git a/doc/creating_wrappers.7.md b/doc/creating_wrappers.7.md
@@ -0,0 +1,90 @@
+creating wrappers around libdevuansdk
+=====================================
+
+libdevuansdk holds all the helper functions you might need, but it does not
+allow you to simply use it in a completely automated fashion. for that you
+will have to wrap some zsh around libdevuansdk.
+
+there are a few mandatory variables that you are required to declare before
+sourcing libdevuansdk. otherwise libdevuansdk might write to some places of the
+system you wouldn't want to.
+
+## requirements
+
+before sourcing it, libdevuansdk assumes you already loaded and initialized
+the [zuper](https://github.com/dyne/zuper) zsh library.
+
+
+### mandatory variables
+
+* `$R`
+ the root directory of your wrapper. in almost every situation you can set
+ it as `$PWD`
+
+* `$workdir`
+ the working directory of the current "build". a sane default is
+ `$R/tmp/workdir`
+
+* `$strapdir`
+ the bootstrap directory of the current "build". it holds the rootfs when
+ you debootstrap. sane default: `$workdir/rootfs`
+
+* `$arch`
+ the CPU architecture of the current "build". values like: `amd64`, `i386`,
+ `armhf`, etc...
+
+
+### Optional variables
+
+* `$extra_packages`
+ this should hold an array of packages that exist in the devuan package tree.
+ they will get installed as a part of the bootstrap process.
+
+* `$purge_packages`
+ this is an array that holds a list of packages that will get removed at the
+ final steps of the bootstrap process. note that this array is not empty by
+ default, so you should only add to it in your wrapper, not override it.
+ just to be safe.
+
+* `$size`
+ This variable will hold the value in MiB for `dd` to know how many zeroes it
+ should put in the raw image.
+ ex: `size=1337`
+
+* `$parted_type`
+ if you are creating a raw (dd-able) image, this variable will tell
+ libdevuansdk how to partition that image. either `dos` or `gpt`.
+
+* `$parted_boot`
+ used if `$parted_type=dos`. it holds the values for `parted` and the
+ formatting of the `boot` partition.
+ ex: `parted_boot="fat32 2048s 264191s"`.
+ see the `image_partition_raw_dos()` function in `libdevuansdk/zlibs/imaging`
+ for a better understanding on how the variable is used.
+
+* `$parted_root`
+ used if `$parted_type=dos`. it holds the values for `parted` and the
+ formatting of the `root` partition.
+ ex: `parted_root="ext4 264192s 100%"`.
+ see the `image_partition_raw_dos()` function in `libdevuansdk/zlibs/imaging`
+ for a better understanding on how the variable is used.
+
+* `$gpt_boot`
+ used if `$parted_type=gpt`. it is an array holding the start and end values
+ for partitioning the `boot` partition.
+ ex: `gpt_boot=(8192 32768)`
+ see the `image_partition_raw_gpt()` function in `libdevuansdk/zlibs/imaging
+ for a better understanding on how the variable is used.
+
+* `$gpt_root`
+ used if `$parted_type=gpt`. it is an array holding the start value for
+ partitioning the `root` partition.
+ ex: `gpt_root=(40960)`
+ currently libdevuansdk chooses this as a startpoint, and maxes out remaining
+ available space. again, see the `image_partition_raw_gpt()` function for a
+ better understanding.
+
+* `$qemu_bin`
+ declare this if you are bootstrapping for an architecture different than
+ yours. it should hold the path to `qemu-user-static` or a similarly named
+ statically compiled qemu for userspace.
diff --git a/doc/helper_functions.7.md b/doc/helper_functions.7.md
@@ -0,0 +1,54 @@
+helper functions
+================
+
+you can find useful helper functions in `libdevuansdk/zlibs/helpers`. they are
+intended to help you with writing wrappers, as well as making my job easier
+within developing libdevuansdk. some of these functions are required for
+libdevuansdk to properly work as well.
+
+
+## build_image_dist()
+this function is kind of a wrapper function, mostly used in `arm-sdk` to build a
+complete "dd-able" image from start to end. to run, it requires `$arch`,
+`$size`, `$parted_type`, `$workdir`, and `$strapdir` to be declared. as well as
+`$parted_root`, `$parted_boot` if `$parted_type=dos`, or `$gpt_root`,
+`$gpt_boot` if `$parted_type=gpt`. see `creating_wrappers(7)` for insight on
+these variables.
+
+the workflow of this function is bootstrapping a complete rootfs, creating a raw
+image, installing/compiling a kernel, rsyncing everything to the raw image, and
+finally, compressing the raw image.
+
+
+## devprocsys()
+this function is a simple helper function that takes two arguments: `watdo` and
+`werdo`. it mounts or umounts `/sys`, `/dev`, `/dev/pts`, and `procfs` where you
+tell it to. for example:
+
+```
+devprocsys mount $strapdir
+devprocsys umount $strapdir
+```
+
+
+## findloopmapp()
+this functions takes the raw image and finds a free loopdevice for it to be
+mounted. it calls `losetup(8)` and `kpartx(8)`.
+
+
+## qemu_install_user()
+helper function to install the userspace qemu to `$strapdir`.
+
+
+## dpkgdivert()
+this one takes two arguments, `watdo` and `werdo` (much like `devprocsys`). it
+will create a dpkg diversion in the place you tell it to and remove invoke-rc.d
+so that apt doesn't autostart daemons when they are installed.
+
+
+## enablessh()
+this function will allow root login with password in the bootstrapped rootfs.
+
+
+## silly()
+a funny function printing out random messages.
diff --git a/doc/libdevuansdk.7.md b/doc/libdevuansdk.7.md
@@ -0,0 +1,48 @@
+index
+=====
+
+`libdevuansdk` is a shell script library intended to unify the use and creation
+of various functions spread throughout devuan's various sdks.
+
+devuan's sdks are designed to be used interactively from a terminal, as
+well as from shell scripts. libdevuansdk uses the functionality of the
+[zuper](https://github.com/dyne/zuper) zsh library, but it does not include
+it. you are required to include it in your sdk. however, `libdevuansdk`
+requires the following packages to be installed:
+
+```
+zsh debootstrap sudo kpartx cgpt xz-utils
+```
+
+## notes
+
+to support the development, you are welcome to open issues on problems and
+bugs you encounter. open merge requests of patches or simply get involved
+in other tasks evident on <https://git.devuan.org>
+
+## acknowledgments
+
+Devuan's SDK was originally conceived during a period of residency at the
+Schumacher college in Dartington, UK. Greatly inspired by the laborious and
+mindful atmosphere of its wonderful premises.
+
+The Devuan SDK is Copyright (c) 2015-2016 by the Dyne.org Foundation
+
+Devuan SDK components are designed, written and maintained by:
+
+- Ivan J. <parazyd@dyne.org>
+- Denis Roio <jaromil@dyne.org>
+- Enzo Nicosia <katolaz@freaknet.org>
+
+This source code is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the Free
+Software Foundation, either version 3 of the License, or (at your option)
+any later version.
+
+This software is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+more details.
+
+You should have received a copy of the GNU General Public License along
+with this source code. If not, see <http://www.gnu.org/licenses/>.
diff --git a/doc/nanodoc b/doc/nanodoc
@@ -0,0 +1,75 @@
+#!/bin/sh
+# Copyright (c) 2016 parazyd <parazyd@dyne.org>
+# nanodoc is written and maintained by parazyd
+#
+# This file is part of arm-sdk
+#
+# This source code is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This software is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this source code. If not, see <http://www.gnu.org/licenses/>.
+
+org="parazyd <parazyd@dyne.org> | dyne.org"
+name=libdevuansdk
+version=0.2
+desc="common library for devuan's sdks"
+
+pages="
+ libdevuansdk.7
+ configuration.7
+ workflow.7
+ helper_functions.7
+ creating_wrappers.7
+"
+
+generate_manpages() {
+ for page in $pages; do
+ ronn -r --manual="$name" --organization="$org" ${page}.md
+ done
+
+ mkdir -p man/man7
+ mv *.7 man/man7
+}
+
+generate_html() {
+ mkdir -p html
+ sed -i -e 's/NAME/'"$name"'/' -e 's/DESC/'"$desc"'/g' static/head.html
+ sed -i -e 's/VERSION/'$version'/' static/foot.html
+
+ for page in $pages; do
+ pagetitle=$(sed 1q ${page}.md)
+ printf '<li><a href="%s.html" class="notPage">%s</a></li>\n' $page "$pagetitle" >> nav.html
+ done
+
+ printf "</ul></div><div id='main'>\n" >> nav.html
+
+ for page in $pages; do
+ printf "\thtml/%s\n" $page
+ cat static/head.html > html/${page}.html
+ cat nav.html >> html/${page}.html
+ python -m markdown ${page}.md >> html/${page}.html
+ cat static/foot.html >> html/${page}.html
+
+ pagetitle=$(sed 1q ${page}.md)
+ sed -i -e 's/TITLE/'"$pagetitle"'/' html/${page}.html
+ sed -i -e 's/'$page'.html" class="notPage/'$page'.html" class="thisPage/' html/${page}.html
+ done
+
+ ln -sf libdevuansdk.7.html html/index.html
+ #cat nav.html
+ rm -f nav.html
+}
+
+case $1 in
+ man) generate_manpages && exit 0 ;;
+ html) generate_html && exit 0 ;;
+ *) exit 1 ;;
+esac
diff --git a/doc/static/foot.html b/doc/static/foot.html
@@ -0,0 +1,11 @@
+
+ </div>
+ </div>
+
+ <div id="footer">
+ <span class="right">
+ <a href="https://git.devuan.org/sdk/libdevuansdk">libdevuansdk-VERSION</a>
+ </span>
+ </div>
+</body>
+</html>
diff --git a/doc/static/head.html b/doc/static/head.html
@@ -0,0 +1,199 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+ <title>TITLE</title>
+
+ <style type="text/css">
+ /* {{{ stylesheet */
+body {
+ background-color: #eee;
+ color: #222;
+ font-family: sans-serif;
+ -webkit-font-smoothing: antialiased;
+ padding: 0;
+ margin: 0;
+}
+
+hr { margin: 30px 60px; }
+
+code {
+ font-family: monospace;
+ background-color: #ccc;
+ padding: 0.2ex 0.5ex 0.2ex 0.5ex;
+ margin: 0.2ex;
+ border-radius: 5px;
+}
+
+a, a:visited {
+ color: #058;
+ text-decoration: none;
+ -webkit-transition: all 0.2s linear;
+ -moz-transition: all 0.2s linear;
+ -ms-transition: all 0.2s linear;
+ -o-transition: all 0.2s linear;
+ transition: all 0.2s linear;
+}
+
+a:hover {
+ background-color: #eee;
+ text-decoration: none;
+}
+
+#menu {
+ clear: both;
+ overflow: hidden;
+ color: #069;
+ background-color: #333;
+ padding: 0.7ex;
+ font-size: 94%;
+ border-top: 1px solid #333;
+ border-bottom: 1px solid #333;
+}
+
+#menu a {
+ padding: 0.5ex 1ex 0.5ex 1ex;
+ color: #fff;
+}
+
+#menu a:hover {
+ background-color: #333;
+ color: #17a;
+}
+
+#menu a.thisSite {
+ font-weight: bold;
+}
+
+#header {
+ clear: both;
+ color: #666;
+ font-size: 1.78em;
+ padding: 0.7ex 0.7ex 0.7ex 0.7em;
+}
+
+#header img {
+ width: 30px;
+}
+
+#headerLink {
+ color: #666;
+ margin-left: 5px;
+}
+
+h1 {
+ font-family: sans-serif;
+ margin: 1em 1ex 0.5ex 0;
+ font-size: 1.4em;
+}
+
+h2 {
+ font-family: sans-serif;
+ margin: 1em 1ex 0.5ex 0;
+ font-size: 1.3em;
+}
+
+h3 {
+ font-family: sans-serif;
+ margin: 1em 1ex 0.5ex 0;
+ font-size: 1.0em;
+}
+
+h4 {
+ font-family: sans-serif;
+ margin: 1em 1ex 0.5ex 0;
+ font-size: 0.9em;
+}
+
+#headerSubtitle {
+ font-size: 0.75em;
+ font-style: italic;
+ margin-left: 1em;
+}
+
+#content {
+ clear: both;
+ font-size: 0.9em;
+ margin: 0;
+ padding: 0;
+ background-color: #fff;
+ overflow: hidden;
+}
+
+#nav {
+ background-color: #fff;
+ float: left;
+ margin: 0 1px 0 0;
+ padding: 1em 0;
+ border-right: 1px dotted #ccc;
+ width: 200px;
+}
+
+#nav ul {
+ margin: 0;
+ padding: 0;
+}
+
+#nav li {
+ list-style: none;
+ font-size: 0.8em;
+ padding: 0;
+ margin: 0;
+}
+
+#nav li ul {
+ padding-left: 0.6em !important;
+}
+
+#nav li a {
+ display: block;
+ margin: 0;
+ padding: 0.8ex 2em 0.8ex 1em;
+}
+
+#nav li a.thisPage {
+ color: #222; /*#333;*/
+ font-weight: bold;
+ /*font-style: italic;*/
+}
+
+#main {
+ margin: 0 0 0 200px;
+ padding: 1.5em;
+ max-width: 50em;
+}
+
+#footer {
+ clear: both;
+ color: #666;
+ border-top: 1px solid #ccc;
+ font-size: 84%;
+ padding: 1em;
+ margin: 0 0 1.5em 0;
+}
+
+.left {
+ float: left;
+ margin: 0;
+ padding: 0;
+}
+
+.right {
+ float: right;
+ margin: 0;
+ padding: 0;
+}
+ /* }}} */
+ </style>
+</head>
+<body>
+ <div id="header">
+ <a id="headerLink" href="html">libdevuansdk</a>
+ <span id="headerSubtitle">DESC</span>
+ </div>
+ <div id="menu"></div>
+
+ <div id="content">
+ <div id="nav">
+
+ <ul>
diff --git a/doc/workflow.7.md b/doc/workflow.7.md
@@ -0,0 +1,32 @@
+libdevuansdk workflow
+=====================
+
+Working with libdevuansdk splits into categories of what you want to do.
+`zlibs` are files separated into these "categories":
+
+## bootstrap
+
+Contains the functions for the bootstrap process. Creating a minimal debootstrap
+base, and making it into a tarball for later use so you don't have to wait for
+the debootstrap on every build.
+
+## helpers
+
+Contains the helper functions for libdevuansdk that make your and my life a bit
+easier.
+
+## imaging
+
+Contains the functions necessary for creating raw dd-able images.
+
+## kernel
+
+Contains the functions for installing a vanilla kernel.
+
+## rsync
+
+Contains rsync functions
+
+## sysconf
+
+Contains the default system configuration.
diff --git a/libdevuansdk b/libdevuansdk
@@ -24,6 +24,7 @@ source $LIBPATH/config
source $LIBPATH/zlibs/bootstrap
source $LIBPATH/zlibs/helpers
source $LIBPATH/zlibs/imaging
+source $LIBPATH/zlibs/iso
source $LIBPATH/zlibs/kernel
source $LIBPATH/zlibs/rsync
source $LIBPATH/zlibs/sysconf
diff --git a/zlibs/bootstrap b/zlibs/bootstrap
@@ -138,6 +138,7 @@ bootstrap_tar_pack() {
#apt-get --yes --force-yes purge ${extra_packages}
apt-get --yes --force-yes autoremove
apt-get clean
+rm -f /prepack
EOF
sudo chmod +x $strapdir/prepack || zerr
@@ -181,11 +182,14 @@ apt-get --yes --force-yes upgrade
apt-get --yes --force-yes install ${extra_packages}
apt-get --yes --force-yes autoremove
apt-get clean
+rm -f /postunpack
EOF
dpkgdivert on $strapdir
+ devprocsys mount $strapdir
sudo chmod +x $strapdir/postunpack || zerr
sudo -E chroot $strapdir /postunpack || zerr
+ devprocsys umount $strapdir
dpkgdivert off $strapdir
## below typically used in arm-sdk
diff --git a/zlibs/helpers b/zlibs/helpers
@@ -36,13 +36,34 @@ build_image_dist() {
## TODO: add blend_prebuild; blend_midbuild; blend_postbuild
bootstrap_complete_base || zerr
+ [[ $BLEND = 1 ]] && blend_preinst || zerr
image_prepare_raw || zerr
image_partition_raw_${parted_type} || zerr
build_kernel_${arch} || zerr
+ [[ $BLEND = 1 ]] && blend_postinst || zerr
rsync_to_raw_image || zerr
image_pack_dist || zerr
}
+build_iso_dist() {
+ fn build_iso_dist
+ req=(workdir strapdir os arch)
+ ckreq || return 1
+
+ notice "building complete iso image"
+
+ bootstrap_complete_base || zerr
+ [[ $BLEND = 1 ]] && blend_preinst || zerr
+ iso_prepare_strap || zerr
+ build_kernel_${arch} || zerr
+ iso_setup_isolinux || zerr
+ iso_write_isolinux_cfg || zerr
+ [[ $INSTALLER = 1 ]] && iso_setup_installer
+ [[ $BLEND = 1 ]] && blend_postinst || zerr
+ iso_squash_strap || zerr
+ iso_xorriso_build || zerr
+}
+
devprocsys() {
fn devprocsys "$@"
local watdo="$1"
@@ -121,6 +142,38 @@ EOF
sudo -E chroot $werdo /dpkgdivert || zerr
}
+enableserv() {
+ fn enableserv "$@"
+ local service="$1"
+ req=(service strapdir)
+ ckreq || return 1
+
+ cat <<EOF | sudo tee -a ${strapdir}/enserv
+#!/bin/sh
+update-rc.d ${service} enable
+EOF
+
+ notice "enabling $service service"
+ sudo chmod +x $strapdir/enserv
+ sudo -E chroot $strapdir /enserv
+}
+
+disableserv() {
+ fn disableserv "$@"
+ local service="$1"
+ req=(service strapdir)
+ ckreq || return 1
+
+ cat <<EOF | sudo tee -a ${strapdir}/disserv
+#!/bin/sh
+update-rc.d ${service} disable
+EOF
+
+ notice "disabling $service service"
+ sudo chmod +x $strapdir/disserv
+ sudo -E chroot $strapdir /disserv
+}
+
enablessh() {
fn enablessh
req=(strapdir)
@@ -130,6 +183,43 @@ enablessh() {
#!/bin/sh
sed -i -e 's/PermitRootLogin without-password/PermitRootLogin yes/' /etc/ssh/sshd_config
update-rc.d ssh enable
+chmod +x /etc/init.d/regensshkeys
+update-rc.d regensshkeys defaults
+update-rc.d regensshkeys enable
+EOF
+
+ cat <<EOF | sudo tee ${strapdir}/etc/init.d/regensshkeys
+#!/bin/sh
+#
+### BEGIN INIT INFO
+# Provides: something
+# Required-Start: \$syslog
+# Required-Stop: \$syslog
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Regenerate openssh-server keys
+# Description: Regenerate openssh-server keys
+### END INIT INFO
+#
+set -e
+set -u
+
+genkeys() {
+ /usr/sbin/service ssh stop
+ /usr/sbin/dpkg-reconfigure openssh-server
+ /usr/sbin/service ssh start
+ /usr/sbin/update-rc.d regensshkeys disable
+}
+
+case "\$1" in
+ start)
+ genkeys;;
+ stop)
+ ;;
+ *)
+ echo "usage: \$(basename \$0) {start}"
+ ;;
+esac
EOF
dpkgdivert on $strapdir
@@ -138,6 +228,28 @@ EOF
dpkgdivert off $strapdir
}
+install-custdebs() {
+ fn install-custdebs
+ req=(R strapdir)
+ ckreq || return 1
+
+ sudo mkdir -p $strapdir/debs
+ sudo cp $CPVERBOSE -f $R/extra/custom-packages/*.deb $strapdir/debs/
+
+ cat <<EOF | sudo tee ${strapdir}/install-debs
+#!/bin/sh
+for deb in /debs/*.deb; do
+ dpkg -i \$deb
+ apt-get --yes --force-yes -f install
+done
+apt-get autoremove
+apt-get clean
+rm -rf /debs install-debs
+EOF
+ sudo chmod +x $strapdir/install-debs
+ sudo -E chroot $strapdir /install-debs
+}
+
silly() {
fn silly "$@"
local arg1="$1"
diff --git a/zlibs/iso b/zlibs/iso
@@ -0,0 +1,129 @@
+#!/usr/bin/env zsh
+# Copyright (c) 2016 Dyne.org Foundation
+# libdevuansdk is maintained by Ivan J. <parazyd@dyne.org>
+#
+# This file is part of libdevuansdk
+#
+# This source code is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This software is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this source code. If not, see <http://www.gnu.org/licenses/>.
+
+## burn baby
+
+[[ $INSTALLER = 1 ]] && base_packages+=(grub-pc)
+
+iso_prepare_strap() {
+ fn iso_prepare_strap
+ req=(strapdir)
+ ckreq || return 1
+
+ notice "preparing strapdir for livecd"
+
+ cat <<EOF | sudo tee ${strapdir}/isoprep
+#!/bin/sh
+apt-get update
+apt-get --yes --force-yes install dialog live-boot
+apt-get --yes --force-yes autoremove
+apt-get clean
+rm -f /isoprep
+EOF
+ dpkgdivert on $strapdir
+ sudo chmod +x $strapdir/isoprep
+ sudo -E chroot $strapdir /isoprep
+ dpkgdivert off $strapdir
+}
+
+iso_setup_isolinux() {
+ fn iso_setup_isolinux
+ req=(workdir strapdir)
+ ckreq || return 1
+
+ notice "setting up isolinux"
+
+ pushd $workdir
+ sudo mkdir -p binary/{live,isolinux}
+ act "copying kernel and initrd"
+ sudo cp $CPVERBOSE $strapdir/boot/vmlinuz* binary/live/vmlinuz
+ sudo cp $CPVERBOSE $strapdir/boot/initrd* binary/live/initrd
+
+ sudo cp $CPVERBOSE /usr/share/live/build/bootloaders/isolinux/isolinux.bin \
+ binary/isolinux
+ sudo cp $CPVERBOSE /usr/share/live/build/bootloaders/isolinux/*.c32 \
+ binary/isolinux
+ popd
+}
+
+iso_write_isolinux_cfg() {
+ fn iso_write_isolinux_cfg
+ req=(workdir arch os)
+ ckreq || return 1
+
+ notice "writing isolinux configuration"
+ cat <<EOF | sudo tee ${workdir}/binary/isolinux/isolinux.cfg
+ui vesamenu.c32
+prompt 0
+menu title ${os} boot menu
+timeout 300
+
+label live-${arch}
+menu label ^${os} Live (${arch})
+menu default
+linux /live/vmlinuz
+append initrd=/live/initrd boot=live
+
+endtext
+EOF
+}
+
+iso_squash_strap() {
+ fn iso_squash_strap
+ req=(workdir strapdir)
+ ckreq || return 1
+
+ notice "creating squashfs out of strapdir"
+
+ pushd $workdir
+ sudo mksquashfs $strapdir binary/live/filesystem.squashfs -comp xz -e boot
+ popd
+}
+
+iso_xorriso_build() {
+ fn iso_xorriso_build
+ req=(workdir image_name)
+ ckreq || return 1
+
+ notice "building iso..."
+ isoname="${image_name}-live.iso"
+
+ pushd $workdir
+ sudo xorriso -as mkisofs -r -J -joliet-long -l \
+ -isohybrid-mbr /usr/lib/ISOLINUX/isohdpfx.bin \
+ -partition_offset 16 \
+ -A "${os} Live - ${arch}" \
+ -b isolinux/isolinux.bin \
+ -c isolinux/boot.cat \
+ -no-emul-boot \
+ -boot-load-size 4 \
+ -boot-info-table \
+ -o $R/dist/$isoname \
+ binary
+ popd
+}
+
+iso_setup_installer() {
+ fn iso_setup_installer
+
+ notice "setting up devuan-installer"
+ sudo cp $CPVERBOSE $R/extra/installer/* $strapdir/
+
+ ## TODO: init to script
+}
diff --git a/zlibs/kernel b/zlibs/kernel
@@ -30,12 +30,14 @@ build_kernel_amd64() {
notice "installing stock kernel for $arch"
+ dpkgdivert on $strapdir
devprocsys mount $strapdir
sudo chroot $strapdir \
apt-get --yes --force-yes install $kernel
devprocsys umount $strapdir
+ dpkgdivert off $strapdir
}
build_kernel_i386() {
@@ -49,10 +51,12 @@ build_kernel_i386() {
notice "installing stock kernel for $arch"
+ dpkgdivert on $strapdir
devprocsys mount $strapdir
sudo chroot $strapdir \
apt-get --yes --force-yes install $kernel
devprocsys umount $strapdir
+ dpkgdivert off $strapdir
}