begin refactoring

This commit is contained in:
parazyd 2016-09-29 21:19:10 +02:00
parent c61cbfca84
commit a52e018a44
No known key found for this signature in database
GPG Key ID: F0CB28FCF78637DE
22 changed files with 0 additions and 2154 deletions

3
.gitmodules vendored
View File

@ -1,3 +0,0 @@
[submodule "zuper"]
path = zuper
url = https://github.com/dyne/zuper

View File

@ -1,61 +0,0 @@
libdevuansdk
------------
libdevuansdk is a shell script library intended to unify the use and creation of
various functions spread throughout Devuan's various SDKs.
For documentation, refer to the files in the `doc` directory.
=======
# Devuan's Simple Distro Kit - shared library
This is a set of ZSh based scripts shared across other Devuan's SDK components to accomplish common tasks.
All Devuan's SDK components are found here https://git.devuan.org/groups/sdk
## Requirements
Devuan's SDK is designed to be used interactively from a terminal as well
from shell scripts. It requires the following packages to be installed:
```
zsh debootstrap expect sudo
```
# Caveat
This is an early release with limited functionality to facilitate the
import and maintainance of some packages that are core to Devuan.
Some things may change in the immediate future.
To support the development you are welcome to open issues on problems
and bugs you encounter, open merge requests of patches or simply
getting 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 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/>.

39
config
View File

@ -1,39 +0,0 @@
#!/usr/bin/env zsh
#
# Copyright (c) 2016 Dyne.org Foundation
# libdevuansdk is written and maintained by
# Jaromil <jaromil@dyne.org>
# KatolaZ <katolaz@freaknet.org>
# parazyd <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/>.
## Distro-specific settings
# os name
os="devuan"
# release name
release="jessie"
# release version
version="1.0.0-beta2"
# mirror url
mirror="http://packages.devuan.org/merged"
# mirror repo section
section="main"

View File

@ -1,72 +0,0 @@
libdevuansdk
------------
## Strings for translation
To support gettext translation use Zuper's functions for noticing messages to console:
- `notice` (green visible header)
- `act` (bullet point information)
- `warning` (orange warning, non fatal)
- `error` (fatal error) followed by `zerr` and `zshexit`
Each string should not contain any variable, but pointers to
variables, then be followed by actual variables as arguments. So for
instance:
```
notice "Starting to bake files in ::1 directory:: for target ::2 arch::" $dir $arch
```
This will print the string with variables in it, but string will
contain references to them. This is so that gettext translations will
point to the same string even in case of name of variables changing.
## Code style
### Leading whitespace
* Use tabs for indentation
* Use spaces for alignment
* This means no tabs except beginning of line
* Everything will line up independent of tab size
### Variable naming
* Do not name your variables UPPERCASE unless they are environment related.
* All variables local to the project should stay lowercase
### Function naming
* Use underscores, not dashes in naming.
* Declare every function with `fn function_name` for zuper.
* Sort all functions alphabetically in their respective files.
* Write its needed documentation in `doc/README-functions.md`
### Other
* No files chmodded to +x. This is a library.
## Workflow
libdevuansdk is split into three stages. See `doc/WORKFLOW.md` for more info on it.
### Stage 1
* debootstrap (stage 1+2+3)
* gives you a working system
* tarball it for later use
* raw image (dd-ed zeroes)
### Stage 2
* declare entities
* customize system
### Stage 3
* packing
## Submodule administration
To update all submodules use:
```
git submodule foreach git pull --rebase origin master
```
This will cycle through all submodules and update them to the respective latest HEAD. After this the repository needs to be updated with the reference to this new HEAD with a commit.

View File

@ -1,7 +0,0 @@
libdevuansdk configuration
--------------------------
## Variables
### `strapdir`
Path to your bootstrap directory (rootfs)

View File

@ -1,122 +0,0 @@
libdevuansdk functions
----------------------
# zlibs/debootstrap
## bootstrap()
Main function, goes through stages 1, 2, and 3 of debootstrap.
### bootstrap_config_cleanup() ###
Final cleanup of the rootfs.
### bootstrap_config_thirdstage() ###
Shell script for the system's third debootstrap stage.
### bootstrap_tar_pack() ###
Make a tarball of a base working system, ready to be worked on later.
### bootstrap_tar_unpack() ###
Unpack the tarball of a base working system to the strapdir.
# zlibs/imaging
## img_mkimage()
Uses dd to dump zeroes into a raw .img of the preconfigured size.
Goes further and rsyncs strapdir into the image, installs bootloader and a
kernel.
## img_partition_dos() ##
Partitions the raw image into dos format and formats (boot=ext2; root=ext4)
## img_partition_gpt() ##
Partitions the raw image into gpt format and formats (boot=ext2; root=ext4)
## img_rsync_strapdir() ##
rsyncs the strapdir to te mounted rootfs of our raw image.
## img_install_bootloader() ##
calls functions from sysconf: `conf_install_kernel` and `conf_install_grub` to
install the on the image
## img_mount() ##
Mounts the root and boot partitions in `$workdir/rootp` in order to work on it.
## img_umount() ##
Undoes the above function.
# zlibs/helpers
## escalate()
Acts as a wrapper for escalating user privilege when needed. Takes two
arguments, user and command in the style of:
```
escalate root "chroot /somewhere/where/i/want/to"
```
## findloopmapp()
For the raw image. Finds a free loopdevice and makes a /dev/mapper device which
is then kpartx-ed to give us partitions we can mount.
## mountdevprocsys()
Mounts `/sys`, `/dev`, `/dev/pts`, and `/proc` where needed. Takes one argument, which
is the path containing those. ex:
```
mountdevproc /path/to/bootstrapped/chroot
```
## umountdevprocsys()
Does the opposite of `mountdevprocsys`.
## aptautostart()
enables/disables apt to autostart services after their packages are installed.
takes args `on` or `off` as 1st argument, and `/path/to/chroot` as second
argument
## silly()
Because NSA
# zlibs/sysconf
NOTE: everything is printed to stdout. Pipe or redirect if you want to write on
storage.
## conf_install_grub()
Installs `grub-pc` to the target. Arg taken is a path to a chroot
## conf_install_kernel()
Installs `linux-image-$arch` to the target. Arg taken is a path to the chroot.
## conf_print_debconf()
Prints out the config for console-common setup
## conf_print_fstab()
Prints the fstab
## conf_print_hostname()
Prints the hostname. Requires `$os` to be declared.
## conf_print_hosts
Prints default `/etc/hosts`
## conf_print_networkifaces()
Prints the `/etc/network/interfaces` file
## conf_print_resolvconf()
Prints the `/etc/resolv.conf` file.
## conf_print_sourceslist()
Prints default `/etc/apt/sources.list`
# zlibs/customise
## kernel_x86_install_default()
Install the default kernel in the bootstrapped system
## qemu_make_img()
Make a raw/qcow2 qemu image of workdir

View File

@ -1,7 +0,0 @@
# STAGE ONE
Build a basic system ready to be customized/shipped and pack it into a tarball
for later use.
# STAGE TWO
# STAGE THREE

View File

@ -1,24 +0,0 @@
#!/usr/bin/env zsh
#
# Copyright (c) 2016 Dyne.org Foundation
# libdevuansdk is written and maintained by
# Jaromil <jaromil@dyne.org>
# KatolaZ <katolaz@freaknet.org>
# parazyd <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/>.

112
sdk.init
View File

@ -1,112 +0,0 @@
#!/usr/bin/env zsh
#
# Copyright (c) 2016 Dyne.org Foundation
# libdevuansdk is written and maintained by
# Jaromil <jaromil@dyne.org>
# KatolaZ <katolaz@freaknet.org>
# parazyd <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/>.
fn libdevuansdk.init
libdevuansdk_version=0.1
notice "Initializing Devuan SDK library v$libdevuansdk_version"
vars+=(SDK_PREFIX SDK_HOME SDK_CONF SDK_LIB SDK_ARM SDK_VM SDK_LIVE)
vars+=(libdevuansdk_version os release version mirror section arch)
# defaults if less sofisticated dir
SDK_HOME=${SDK_HOME:-$SDK_PREFIX}
SDK_CONF=${SDK_CONF:-$SDK_PREFIX}
# default operational paths
vars+=(R H E)
R=${R:-$SDK_PREFIX}
H=${H:-$SDK_HOME}
E=${E:-$SDK_CONF}
req=(os release version mirror section R H E)
freq=($SDK_LIB/zuper/zuper.init)
ckreq || { error "configuration is missing"; zshexit; return 1 }
# name of target by default, omits arch
vars+=(name_default)
name_default=${os}_${release}_${version}
# For gettext
TEXTDOMAIN=devuan
# setting core, base, and other packages
[[ "$core_packages" = "" ]] && {
# core packages for the system
arrs+=(core_packages)
core_packages=(devuan-keyring debian-keyring)
core_packages+=(initramfs-tools binutils ca-certificates curl)
core_packages+=(console-common less nano vim)
}
[[ "$base_packages" = "" ]] && {
# base packages for the system
arrs+=(base_packages)
base_packages=(bzip2 dialog apt-utils fakeroot e2fsprogs parted)
}
[[ "$system_packages" = "" ]] && {
# other system packages
arrs+=(system_packages)
system_packages=(sysvinit ssh)
}
# default size for an img
vars+=(imgsize)
imgsize=${imgsize:-1337M}
## libdevuansdk-specific settings
vars+=(workdir strapdir outdir)
outdir=${outdir:-$H/builds}
workdir=${workdir:-$H/workdir}
strapdir="${workdir}/${name_default}_${arch}"
# conclude initialization
DEBUG=${DEBUG:-0}
QUIET=${QUIET:-0}
LOG=${LOG:-""}
# config globals
# source $R/zlibs/library
source $SDK_LIB/zlibs/bootstrap
source $SDK_LIB/zlibs/helpers
# source $R/zlibs/imaging
source $SDK_LIB/zlibs/isolinux
source $SDK_LIB/zlibs/kernel
source $SDK_LIB/zlibs/qemu
source $SDK_LIB/zlibs/grub
source $SDK_LIB/zlibs/sysconf
source $SDK_LIB/zlibs/blends
source $SDK_LIB/zlibs/packages
# create mandatory workdirs
# $strapdir
mkdir -p ${strapdir}
# $outdir
mkdir -p ${outdir}
# conclude initialization
source $SDK_LIB/zuper/zuper.init
act "library succesfully loaded"

View File

@ -1,20 +0,0 @@
/* qemu wrapper
* wrapper for executing qemu in build chroots
* pass arguments to qemu binary
*
* ~ parazyd */
#include <string.h>
#include <unistd.h>
int main(int argc, char **argv, char **envp) {
char *newargv[argc + 3];
newargv[0] = argv[0];
newargv[1] = "-cpu";
newargv[2] = "cortex-a8"; /* here you can set the cpu you are building for */
memcpy(&newargv[3], &argv[1], sizeof(*argv) * (argc -1));
newargv[argc + 2] = NULL;
return execve("/usr/bin/qemu-arm", newargv, envp);
}

View File

@ -1,97 +0,0 @@
#!/usr/bin/env zsh
#
# Copyright (c) 2016 Dyne.org Foundation
# libdevuansdk is written and maintained by
# Jaromil <jaromil@dyne.org>
# KatolaZ <katolaz@freaknet.org>
# parazyd <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/>.
## blend-related functions
## Apply a blend, i.e. read the "blend" file and source the
## corresponding *_init and *_run files
##
## FIXME!!!! We need a way to check that the source of init and run
## files were successful, so that we can popd as necessary upon failure
##
blend_apply(){
fn blend_apply $@
blenddir=$1
req=(blenddir strapdir arch)
reqck || return 1
if [[ ! -d $blenddir || ! -f ${blenddir}/blend ]]; then
error "::1 dir:: is not a valid blend" $blenddir
return 1
fi
pushd $blenddir
source blend
## Check if release is among the supported blend_releases
[[ -z ${blend_releases[(r)$release]} ]] && {
error "::1 rel:: is not among the releases supported by blend ::2 dir:: " $rel $blenddir;
popd;
return 1
}
[[ -z ${blend_archs[(r)$arch]} ]] && {
error "::1 arch:: is not among the architectures supported by blend ::2 dir:: " $arch $blenddir;
popd;
return 1
}
notice "Selecting blend architecture ::1 arch:: " $arch
pushd ${arch}
[[ -n ${blend_init} ]] && {
notice "Initialising blend ::1 blend:: " $blenddir
##
[[ ! -f ${blend_init} ]] && {
error "Blend initialisation file \"::1 file::\" not found" ${blend_init}
popd
popd
return 1
}
source ${blend_init}
act "Initialisation successful"
}
[[ -n ${blend_run} ]] && {
notice "Applying blend ::1 blend:: " $blenddir
##
[[ ! -f ${blend_run} ]] && {
error "Blend run file \"::1 file::\" not found" ${blend_run}
popd
popd
return 1
}
source ${blend_run}
act "Application successful"
}
# come back to blend main dir
popd
# come back to working directory before the call to blend_apply
popd
}

View File

@ -1,178 +0,0 @@
#!/usr/bin/env zsh
#
# Copyright (c) 2016 Dyne.org Foundation
# libdevuansdk is written and maintained by
# Jaromil <jaromil@dyne.org>
# KatolaZ <katolaz@freaknet.org>
# parazyd <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/>.
## Debootstrap things
vars+=(bootstrap_tgz)
bootstrap() {
fn bootstrap $@
arch="$1"
req=(os strapdir workdir arch release mirror)
ckreq || return 1
notice "Bootstrapping ::1 OS:: base" ${os}
bootstrap_tgz=$H/builds/${name_default}_${arch}.tgz
strapdir=${workdir}/${name_default}_${arch}
if [[ -f $bootstrap_tgz ]]; then
notice "Using the existing bootstrap tarball found in ::1 tmpdir::" $H/tmp
ls -lh $bootstrap_tgz
bootstrap_tar_unpack ${strapdir}
else
# Debootstrap stage 1
sudo debootstrap --foreign --arch ${arch} ${release} ${strapdir} ${mirror}
qemu_install_user
# Debootstrap stage 2
sudo chroot ${strapdir} /debootstrap/debootstrap --second-stage
# write all system configuration
conf_print_debconf | sudo tee ${strapdir}/debconf.set
conf_print_fstab | sudo tee ${strapdir}/etc/fstab
conf_print_hostname | sudo tee ${strapdir}/etc/hostname
conf_print_hosts | sudo tee ${strapdir}/etc/hosts
conf_print_networkifaces | sudo tee ${strapdir}/etc/network/interfaces
conf_print_resolvconf | sudo tee ${strapdir}/etc/resolv.conf
conf_print_sourceslist | sudo tee ${strapdir}/etc/apt/sources.list
# write third-stage for chroot
bootstrap_config_thirdstage | sudo tee ${strapdir}/thirdstage.sh
bootstrap_config_cleanup | sudo tee ${strapdir}/cleanup.sh
sudo chmod +x ${strapdir}/thirdstage.sh
sudo chmod +x ${strapdir}/cleanup.sh
# chroot into it and configure further
# Debootstrap stage 3
export LC_ALL=C
export DEBIAN_FRONTEND=noninteractive
mountdevprocsys ${strapdir}
sudo chroot ${strapdir} /thirdstage.sh
sudo chroot ${strapdir} /cleanup.sh
umountdevprocsys ${strapdir}
bootstrap_tar_pack
fi
}
bootstrap_config_cleanup() {
fn config_cleanup
cat << EOF
#!/bin/sh
rm -f /debconf.set
rm -f /thirdstage.sh
rm -f /etc/ssh/*key
rm -f /etc/ssh/*.pub
rm -f /root/.bash_history
# our file for which we check the bootstrap is complete
echo "1" > .done
EOF
}
bootstrap_config_thirdstage() {
fn bootstrap_config_thirdstage
req=(core_packages base_packages system_packages)
ckreq || return 1
cat << EOF
#!/bin/sh
dpkg-divert --add --local --divert /usr/sbin/invoke-rc.d.chroot --rename /usr/sbin/invoke-rc.d
cp /bin/true /usr/sbin/invoke-rc.d
echo -e "#!/bin/sh\nexit 101" > /usr/sbin/policy-rc.d
chmod +x /usr/sbin/policy-rc.d
apt-get update
apt-get --yes --force-yes install locales-all
debconf-set-selections /debconf.set
apt-get update
apt-get -y install ${core_packages}
echo "root:devuan" | chpasswd
sed -i -e 's/KERNEL\!=\"eth\*|/KERNEL\!=\"/' /lib/udev/rules.d/75-persistent-net-generator.rules
rm -f /etc/udev/rules.d/70-persistent-net.rules
export DEBIAN_FRONTEND=noninteractive
apt-get --yes --force-yes install ${base_packages} ${system_packages} ${extra_packages}
apt-get --yes --force-yes dist-upgrade
apt-get --yes --force-yes autoremove
apt-get clean
rm -f /usr/sbin/policy-rc.d
rm -f /usr/sbin/invoke-rc.d
dpkg-divert --remove --rename /usr/sbin/invoke-rc.d
EOF
}
bootstrap_tar_pack() {
fn bootstrap_tar_pack
req=(bootstrap_tgz)
ckreq || return 1
local _dest=`dirname $bootstrap_tgz`
if [[ -f $bootstrap_tgz ]]; then
act "tarball found already in ::1 dir::" $_dest
else
notice "Creating boostrap tarball in ::1 tgz::" $bootstrap_tgz
silly
pushd ${strapdir}
mkdir -p ${_dest}
sudo tar czf $bootstrap_tgz \
--exclude={./boot,./dev,./sys,./proc} \
./
popd
fi
ls -lh $bootstrap_tgz
}
bootstrap_tar_unpack() {
fn bootstrap_tar_unpack $@
local unpath="$1"
req=(unpath bootstrap_tgz)
ckreq || return 1
[[ -f ${unpath}/.done ]] && {
warning "bootstrap already unpacked in ::1 dir::" $unpath
return 1
}
mkdir -p ${unpath}
silly
tar xf $bootstrap_tgz -C ${unpath}
sudo mkdir -p ${unpath}/{boot,dev,sys,proc}
}

View File

@ -1,100 +0,0 @@
#!/usr/bin/env tclsh
#
# Copyright (c) 2016 Dyne.org Foundation
# libdevuansdk is written and maintained by
# Jaromil <jaromil@dyne.org>
# KatolaZ <katolaz@freaknet.org>
# parazyd <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/>.
#
package require Expect
proc ssh_run_cmd_ssh {sshuser sshpass sshhost sshport cmdname args} {
set timeout 30
spawn ssh -p $sshport $sshuser@$sshhost
expect "yes/no" {
send "yes\r"
expect "*?assword" { send "$sshpass\r" }
} "*?assword" { send "$sshpass\r" }
expect "$ " { send "${cmdname} ${args}\r" }
expect "$ " { send "exit \r"}
interact
}
proc ssh_scpget {sshuser sshpass sshhost sshport srcfile dstfile} {
set timeout 120
spawn scp -P $sshport $sshuser@$sshhost:${scporig} $scpdest
expect "yes/no" {
send "yes\r"
expect "*?assword" { send "$sshpass\r" }
} "*?assword" { send "$sshpass\r" }
expect "100%"
sleep 1
}
proc ssh_scpput {sshuser sshpass sshhost sshport srcfile dstfile} {
set timeout 120
spawn scp -P $sshport $scporig $sshuser@$sshhost:$scpdest
expect "yes/no" {
send "yes\r"
expect "*?assword" { send "$sshpass\r" }
} "*?assword" { send "$sshpass\r" }
expect "100%"
sleep 1
}
proc expectlib_call { name args } {
puts "name: $name"
puts "args: $args"
switch -- $name {
scpput {
ssh_scpput {*}$args
}
scpget {
ssh_scpget {*}$args
}
sshrun {
ssh_run_cmd_ssh {*}$args
}
}
}
set params [split $argv " "]
expectlib_call {*}$params

View File

@ -1,55 +0,0 @@
#!/usr/bin/env zsh
#
# Copyright (c) 2016 Dyne.org Foundation
# libdevuansdk is written and maintained by
# Jaromil <jaromil@dyne.org>
# KatolaZ <katolaz@freaknet.org>
# parazyd <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/>.
grub_install_target_dev() {
fn grub_install_target_dev $@
root=$1
install_dev=$2
req=(root install_dev)
freq=($root/.done)
ckreq || return 1
# TODO: should we use qemu-chroot here for $arch = arm (parazyd?)
sudo chroot ${root} apt-get install --assume-yes --no-install-recommends grub-common
if [[ ! -d ${root}/boot/grub ]]; then
sudo mkdir ${root}/boot/grub
fi
ztmp
devicemap=$ztmpfile
cat > ${devicemap} <<EOF
(hd0) /dev/loop0
EOF
sudo cp ${devicemap} ${root}/boot/grub/device.map
sudo chroot ${root} grub-mkconfig -o /boot/grub/grub.cfg
## we now tamper with grub.cfg, to remove all references to
## loopback devices...
## FIXME!!! This is a hack...
sudo -- sed -r -i -e 's/.*loop.*//g' ${root}/boot/grub/grub.cfg
sudo grub-install --root-directory=${root} --no-floppy \
--modules="ext2 part_msdos" --target=i386-pc --boot-directory=${root}/boot \
${install_dev}
}

View File

@ -1,178 +0,0 @@
#!/usr/bin/env zsh
#
# Copyright (c) 2016 Dyne.org Foundation
# libdevuansdk is written and maintained by
# Jaromil <jaromil@dyne.org>
# KatolaZ <katolaz@freaknet.org>
# parazyd <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/>.
## Helper functions that make your life easier
escalate() {
fn escalate $@
local user="$1"
local cmnd="$2"
req=(user cmnd)
ckreq || return 1
if isfound sudo; then
sudo -E -u ${user} ${=cmnd}
else
su -c "${=cmnd}" ${user}
fi
}
findloopmapp() {
fn findloopmapp
req=(imgpath imgname workdir)
ckreq || return 1
pushd ${workdir}
loopdevice=`sudo losetup -f --show ${imgname}`
mappdevice=`sudo kpartx -va $loopdevice | sed -E 's/.*(loop[0-9])p.*/\1/g' | head -1`
func "Loop device: ::1 loopdev::" $loopdevice
func "Mapper device: ::1 mappdev::" $mappdevice
silly sleep
mappdevice="/dev/mapper/${mappdevice}"
bootpart=${mappdevice}p1
rootpart=${mappdevice}p2
popd
}
mountdevprocsys() {
fn mountdevprocsys $@
local mntdir="$1"
req=(mntdir)
ckreq || return 1
sudo mount -o bind /sys ${mntdir}/sys && act "mounted /sys in $mntdir"
sudo mount -t proc proc ${mntdir}/proc && act "mounted /proc in $mntdir"
sudo mount -o bind /dev ${mntdir}/dev && act "mounted /dev in $mntdir"
sudo mount -o bind /dev/pts ${mntdir}/dev/pts && act "mounted /dev/pts $mntdir"
}
umountdevprocsys() {
fn umountdevprocsys $@
local mntdir="$1"
req=(mntdir)
ckreq || return 1
sudo umount ${mntdir}/dev/pts && act "unmounted /dev/pts in $mntdir" && sleep 2
sudo umount ${mntdir}/dev && act "unmounted /dev in $mntdir" && sleep 2
sudo umount ${mntdir}/proc && act "unmounted /proc in $mntdir" && sleep 2
sudo umount ${mntdir}/sys && act "unmounted /sys in $mntdir" && sleep 2
}
aptautostart() {
fn aptautostart $@
local watdo="$1"
local wheredo="$2"
req=(watdo wheredo)
case $watdo in
on)
aptautostart printon | sudo tee ${wheredo}/aptautostart.sh
sudo chmod +x ${wheredo}/aptautostart.sh
sudo chroot ${wheredo} /aptautostart.sh
;;
off)
aptautostart printoff | sudo tee ${wheredo}/aptautostart.sh
sudo chmod +x ${wheredo}/aptautostart.sh
sudo chroot ${wheredo} /aptautostart.sh
;;
printon)
cat << EOF
#!/bin/sh
rm -f /usr/sbin/policy-rc.d
rm -f /usr/sbin/invoke-rc.d
dpkg-divert --remove --rename /usr/sbin/invoke-rc.d
rm -f /aptautostart.sh
EOF
;;
printoff)
cat << EOF
#!/bin/sh
dpkg-divert --add --local --divert /usr/sbin/invoke-rc.d.chroot --rename /usr/sbin/invoke-rc.d
cp /bin/true /usr/sbin/invoke-rc.d
echo -e "#!/bin/sh\nexit 101" > /usr/sbin/policy-rc.d
chmod +x /usr/sbin/policy-rc.d
EOF
;;
*)
error "Please pass a correct argument (on/off)"
;;
esac
}
silly() {
fn silly $@
local arg1="$1"
local arg2="$2"
# cheers mailpile!
funneh=("do not think of purple hippos"
"increasing entropy & scrambling bits"
"indexing kittens..."
"patching bugs..."
"spinning violently around the y-axis"
"warming up particle accelerator"
"this server is powered by a lemon and two electrodes"
"becoming self-aware"
"BCC-ing ALL THE SPIES!"
"all of your config settings & passwords are encrypted with AES-256"
"the most common e-mail password is 123456, hopefully yours is different"
"good things come to those who wait"
"Make Free Software and be happy"
"We like volcanos, do you like volcanos?"
"Crossing out swear words..."
"Informing David Cameron of suspicious ac^H^H^H ... naaah :)"
"Abandon all hope, ye who enter here"
"Compiling bullshit bingo grid..."
"Estimating chance of asteroid hitting Earth"
"Applying coupons..."
"Backing up the entire Internet..."
"Making you wait for no reason"
"Doing nothing"
"Pay no attention to the man behind the curtain"
"You are great just the way you are"
"Supplying monkeys with typewriters"
"Swapping time and space"
"Self potato"
"Hey, there is some Nigerian prince here who wants to give you twenty million dollars..."
"A million hamsters are spinning their wheels right now")
local rnd=`shuf -i1-30 -n 1`
act "${funneh[$rnd]}"
[[ arg1 == "sleep" ]] && sleep $arg2
}
check_executable() {
fn check_executable $@
progname=$1
if [[ `which ${progname} | grep "not found" | wc -l` -ge 1 ]]; then
return 0;
else
return 1;
fi
}

View File

@ -1,168 +0,0 @@
#!/usr/bin/env zsh
#
# Copyright (c) 2016 Dyne.org Foundation
# libdevuansdk is written and maintained by
# Jaromil <jaromil@dyne.org>
# KatolaZ <katolaz@freaknet.org>
# parazyd <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/>.
## Imaging
vars+=(imgname imgpath)
img_mkimage() {
fn img_mkimage $@
imgpath=${strapdir}.img
local mbrtype="$1"
local bootfstype="$2"
local rootfstype="$3"
local imgsize="$4"
req=(imgpath imgsize mbrtype bootfstype rootfstype)
ckreq || return 1
imgname=`basename ${imgpath}`
notice "Creating raw image..."
silly
dd if=/dev/zero \
of="${imgpath}" \
bs=1M count=${imgsize}
if [[ $mbrtype == "dos" ]]; then
img_partition_dos $bootfstype $rootfstype
elif [[ $mbrtype == "gpt" ]]; then
img_partition_gpt $bootfstype $rootfstype
else
error "No valid MBR type specified..."
zerr; zshexit
fi
img_mount
img_rsync_strapdir
# [[ -z $override_bootloader ]] && img_install_bootloader
img_umount
}
img_partition_dos() {
fn img_partition_dos $@
local bootfstype="$1"
local rootfstype="$2"
req=(imgname imgpath bootfstype rootfstype)
ckreq || return 1
notice "Partitioning with dos"
silly
parted_boot=${parted_boot:-ext2 0 64}
parted_root=${parted_root:-ext4 64 -1}
pushd ${workdir}
parted ${imgname} --script -- mklabel msdos
parted ${imgname} --script -- mkpart primary ${parted_boot}
parted ${imgname} --script -- mkpart primary ${parted_root}
# setup loopdevice and mappdevice (zlibs/helpers)
findloopmapp
img_format_partitions ${bootfstype} ${rootfstype}
popd
}
img_format_partitions() {
fn img_format_partitions $@
local bootfstype="$1"
local rootfstype="$2"
req=(bootfstype rootfstype bootpart rootpart)
ckreq || return 1
notice "Formatting partitions..."
sudo mkfs.${bootfstype} ${bootpart}
sudo mkfs.${rootfstype} ${rootpart}
}
img_partition_gpt() {
fn img_partition_gpt $@
local bootfstype="$1"
local rootfstype="$2"
req=(imgname imgpath bootfstype rootfstype)
ckreq || return 1
notice "Partitioning with gpt"
silly
pushd ${workdir}
parted ${imgname} --script -- mklabel gpt
cgpt create -z ${imgname}
cgpt create ${imgname}
cgpt add -i 1 -t kernel -b 8192 -s 32768 -l kernel -S 1 -T 5 -P 10 ${imgname}
cgpt add -i 2 -t data -b 40960 -s `expr $(cgpt show ${imgname} \
| awk '/Sec GPT table/ {print \$1}') - 40960` -l Root ${imgname}
# setup loopdevice and mappdevice (zlibs/helpers)
findloopmapp
img_format_partitions ${bootfstype} ${rootfstype}
popd
}
img_rsync_strapdir() {
fn img_rsync_strapdir
req=(workdir strapdir)
ckreq || return 1
notice "Rsyncing strapdir to raw image..."
silly
sudo rsync -HPavz -q ${strapdir}/* ${workdir}/rootp
}
img_install_bootloader() {
fn img_install_bootloader
conf_install_kernel ${workdir}/rootp
conf_install_grub ${workdir}/rootp
}
img_mount() {
fn img_mount
req=(bootpart rootpart workdir)
ckreq || return 1
mkdir -p ${workdir}/rootp
sudo mount ${rootpart} ${workdir}/rootp && act "mounted root partition"
sudo mkdir -p ${workdir}/rootp/{boot,dev,proc,sys}
sudo mount ${bootpart} ${workdir}/rootp/boot && act "mounted boot partition"
mountdevprocsys ${workdir}/rootp
}
img_umount() {
fn img_umount
req=(bootpart rootpart workdir)
ckreq || return 1
umountdevprocsys ${workdir}/rootp
sudo umount ${workdir}/rootp/boot && act "umounted boot partition"
sudo umount ${workdir}/rootp && act "umounted root partition"
}

View File

@ -1,162 +0,0 @@
#!/usr/bin/env zsh
#
# Copyright (c) 2016 Dyne.org Foundation
# libdevuansdk is written and maintained by
# Jaromil <jaromil@dyne.org>
# KatolaZ <katolaz@freaknet.org>
# parazyd <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/>.
vars+=(iso isodir)
isolinux_prepare() {
fn isolinux_prepare $@
req=(strapdir os release version arch)
root=$strapdir
freq=($strapdir/.done)
# freq=($R/chroot/$chroot_arch/$iso/initrd.gz)
reqck || return 1
iso=${os}_${release}_${version}_${arch}.iso
isodir=$workdir/iso_${os}_${release}_${version}_${arch}
notice "Preparing ISO in $isodir"
mkdir -p $isodir
[[ -r /usr/lib/ISOLINUX/isolinux.bin ]] || {
error "Isolinux binary not found"
zerr; zshexit }
[[ -r /usr/lib/ISOLINUX/isohdpfx.bin ]] || {
error "Isolinux binary not found"
zerr; zshexit }
mkdir -p $isodir/isolinux
cp /usr/lib/ISOLINUX/isolinux.bin $isodir/isolinux
cp /usr/lib/syslinux/modules/bios/*.c32 $isodir/isolinux
cat <<EOF > $isodir/isolinux/isolinux.cfg
path
include menu.cfg
default vesamenu.c32
prompt 0
timeout 0
label Shell
com32 rosh.c32
EOF
cat <<EOF > $isodir/isolinux/menu.cfg
menu hshift 7
menu width 61
menu title Devuan GNU+Linux
include stdmenu.cfg
include txt.cfg
EOF
cat <<EOF > $isodir/isolinux/stdmenu.cfg
menu color title * #FFFFFFFF *
menu color border * #00000000 #00000000 none
menu color sel * #ffffffff #76a1d0ff *
menu color hotsel 1;7;37;40 #ffffffff #76a1d0ff *
menu color tabmsg * #ffffffff #00000000 *
menu color help 37;40 #ffdddd00 #00000000 none
# XXX When adjusting vshift, take care that rows is set to a small
# enough value so any possible menu will fit on the screen,
# rather than falling off the bottom.
menu vshift 12
menu rows 10
menu helpmsgrow 15
# The command line must be at least one line from the bottom.
menu cmdlinerow 16
menu timeoutrow 16
menu tabmsgrow 18
menu tabmsg Press ENTER to boot or TAB to edit a menu entry
EOF
cat <<EOF > $isodir/isolinux/txt.cfg
label default
menu label ^Boot Devuan $release $version $arch
kernel linux
append vga=788 initrd=initrd.img boot=live
EOF
#
# append vga=788 initrd=initrd.img boot=live toram=filesystem.squashfs
}
isolinux_mkinitrd() {
fn isolinux_mkinitrd $@
req=(iso isodir arch)
freq=($isodir/isolinux/isolinux.bin)
ckreq || return 1
sudo chroot $strapdir apt-get install -y live-boot live-boot-initramfs-tools extlinux
# sudo chroot $strapdir update-initramfs -u
# sudo chroot $strapdir update-initramfs -c -k all
sudo chroot $strapdir live-update-initramfs -u
# latest kernel
local kernel=""
for i in ${(f)"$(ls -t $strapdir/boot)"}; do
[[ "$i" =~ "vmlinuz" ]] || continue
kernel=$strapdir/boot/$i
done
# latest ramdisk
local initrd=""
for i in ${(f)"$(ls -t $strapdir/boot)"}; do
[[ "$i" =~ "initrd" ]] || continue
initrd=$strapdir/boot/$i
done
cp -v $kernel $isodir/isolinux/linux
cp -v $initrd $isodir/isolinux/initrd.img
}
isolinux_mkusr() {
fn isolinux_mkusr $@
req=(iso isodir)
ckreq || return 1
ztmp
conf_print_usrexcludes > $ztmpfile
usrdir=$workdir/usr_${os}_${release}_${version}_${arch}
mkdir -p $usrdir
rsync -raX $strapdir/ $usrdir --exclude-from=$ztmpfile
mkdir -p $isodir/live
mksquashfs $usrdir/ $isodir/live/filesystem.squashfs -noappend
}
isolinux_make() {
fn isolinux_make $@
req=(iso isodir outdir)
freq=($isodir/isolinux/isolinux.bin)
ckreq || return 1
mkdir -p $outdir
sudo xorriso \
-as mkisofs -r -J -joliet-long -isohybrid-mbr /usr/lib/ISOLINUX/isohdpfx.bin \
-partition_offset 16 -V DEVUAN \
-b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 \
-boot-info-table -o $outdir/$iso $isodir
notice "$iso ready"
ls -lh $outdir/$iso
}

View File

@ -1,56 +0,0 @@
#!/usr/bin/env zsh
#
# Copyright (c) 2016 Dyne.org Foundation
# libdevuansdk is written and maintained by
# Jaromil <jaromil@dyne.org>
# KatolaZ <katolaz@freaknet.org>
# parazyd <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/>.
kernel_x86_install_default(){
fn kernel_x86_install_default $@
req=(strapdir os release version arch)
root=$strapdir
freq=($root/.done)
reqck || return 1
local kernel_base=linux-image
local kernel=""
case $arch in
amd64)
kernel=${kernel_base}-amd64
;;
i386)
kernel=${kernel_base}-586
;;
*)
error "Architecture ::1 arch:: is not supported!!!" ${arch}
zerr; zshexit
;;
esac
notice "Installing stock kernel for ::1 arch:: (::2 kernel::)" $arch $kernel
mountdevprocsys ${root}
sudo chroot ${root} apt-get --yes --force-yes --no-install-recommends install $kernel
umountdevprocsys ${root}
notice "default kernel installed"
}

View File

@ -1,115 +0,0 @@
#!/usr/bin/env zsh
#
# Copyright (c) 2016 Dyne.org Foundation
# libdevuansdk is written and maintained by
# Jaromil <jaromil@dyne.org>
# KatolaZ <katolaz@freaknet.org>
# parazyd <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/>.
pkg_install(){
fn pkg_install $@
pkg_name=$1
root=${2:-$strapdir}
req=(pkg_name root)
reqck || return 1
mountdevprocsys ${root}
sudo chroot ${root} apt-get --yes --force-yes install ${pkg_name}
umountdevprocsys ${root}
}
pkg_install_ssh(){
}
pkg_remove(){
}
pkg_remove_ssh(){
}
pkg_set_list(){
fn pkg_set_list $@
pkglist=$1
root=${2:-$strapdir}
req=(pkglist root)
reqck || return 1
scriptfilebase=set_package_list.sh
scriptfile=${root}/${scriptfilebase}
pkg_config_set_list ${pkglist} | sudo tee ${scriptfile}
sudo chmod u+x ${scriptfile}
sudo cp ${pkglist} ${root}/`basename ${pkglist}`
[[ $? = 0 ]] || {
error "failed: _pkg_config_set_list ${pkglist} ${scriptfile}"
zsherr; zshexit
}
mountdevprocsys ${root}
sudo chroot ${root} ./${scriptfilebase}
umountdevprocsys ${root}
sudo rm ${scriptfile} ${root}/`basename ${pkglist}`
}
pkg_config_set_list() {
fn _pkg_config_set_list $@
pkglist=`basename $1`
req=(pkglist)
reqck || return 1
cat <<EOF
apt-get install dselect
dpkg --get-selections > selections.bak
dpkg --clear-selections
dselect update
dpkg --set-selections < ${pkglist}
dselect install
dselect config
dselect remove
## Now we purge all the packages marked as "deinstall"
apt-get purge `dpkg --get-selections | grep "deinstall$" | cut -f 1`
EOF
}

View File

@ -1,259 +0,0 @@
#!/usr/bin/env zsh
#
# Copyright (c) 2016 Dyne.org Foundation
# libdevuansdk is written and maintained by
# Jaromil <jaromil@dyne.org>
# KatolaZ <katolaz@freaknet.org>
# parazyd <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/>.
qemu_install_user() {
fn qemu_install_user
local cputype="$1"
[[ -n $enable_qemu ]] && {
act "installing qemu-arm-static"
sudo cp -vf /usr/bin/qemu-arm-static $strapdir/usr/bin/
}
[[ -n $cputype ]] && {
act "compiling qemu wrapper"
cp $R/src/qemu-wrapper.c /tmp/qemu-wrapper.c
sed -i -e 's/cortex-a8/'$cputype'/' /tmp/qemu-wrapper.c
gcc -static /tmp/qemu-wrapper.c -O3 -s /tmp/qemu-wrapper
sudo mv -vf /tmp/qemu-wrapper $strapdir/usr/bin/
print ':arm:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/qemu-wrapper:' | sudo tee /proc/sys/fs/binfmt_misc/register
}
}
qemu_make_img() {
fn qemu_make_img $@
local imgfile=${1:-"$H/builds/${name_default}_${arch}.img"}
local imgsize=${2:-2G}
local imgformat=${3:-raw}
req=(strapdir os release version arch imgfile imgsize)
root=$strapdir
freq=($root/.done)
reqck || return 1
local blockskip=2050
## create the qemu image
notice "Creating qemu image: $imgfile"
qemu-img create -f ${imgformat} ${imgfile} ${imgsize}
[[ $? = 0 ]] || {
error "failed: qemu-img create -f ${imgformat} ${imgfile} ${imgsize}"
zsherr; zshexit }
sudo parted ${imgfile} --script -- mklabel msdos &&
sudo parted ${imgfile} --script -- mkpart primary ${blockskip}s -1s &&
sudo parted ${imgfile} --script -- set 1 boot on
[[ $? = 0 ]] || {
error "failed: parted $imgfile scripts (mklabel, mkpart and setboot)"
zsherr; zshexit }
## setup the loop device
loop1=`sudo losetup -f`
sudo losetup ${loop1} ${imgfile}
[[ $? = 0 ]] || {
error "failed: losetup $loop2 $imgfile"
zsherr; zshexit }
loop2=`sudo losetup -f`
sudo losetup -o $((${blockskip} * 512)) ${loop2} ${loop1}
[[ $? = 0 ]] || {
sudo losetup -d ${loop1}
error "failed: losetup -o $((${blockskip} * 512)) ${loop2} ${loop1}"
zsherr; zshexit }
## now we create the fs
act "creating filesystem"
sudo mkfs.ext4 ${loop2}
[[ $? = 0 ]] || {
sudo losetup -d ${loop2}
sudo losetup -d ${loop1}
error "failed: mkfs.ext4 $loop2"
zsherr; zshexit }
## and we loop-mount it
ztmpd
mntdir=$ztmpdir
sudo mount -o loop ${loop2} ${mntdir}
[[ $? = 0 ]] || {
sudo losetup -d ${loop2}
sudo losetup -d ${loop1}
error "failed: mount -o loop ${loop2} ${mntdir}"
zsherr; zshexit }
func "mntdir: $mntdir"
func "strapdir: $strapdir"
# now we rsync everything
notice "Copying filesystem into image"
# ztmp
# excludefile=${ztmp}
# qemu_config_exclude | sudo tee ${excludefile}
# sudo rsync -raX --exclude-from=${excludefile} ${strapdir}/ ${mntdir}
sudo rsync -raX ${strapdir}/ ${mntdir}
[[ $? = 0 ]] || {
umount $mntdir
sudo losetup -d ${loop2}
sudo losetup -d ${loop1}
error "failed: rsync -raX ${strapdir}/ ${mntdir}"
zsherr; zshexit }
# we now install the grub bootloader
mountdevprocsys ${mntdir}
grub_install_target_dev ${mntdir} ${loop1}
umountdevprocsys ${mntdir}
sync
sudo umount ${mntdir}
sudo losetup -d ${loop2}
sudo losetup -d ${loop1}
if [[ ! -z ${imgfile} ]]; then
notice "QEMU image created in ::1 imgfile::" ${imgfile}
else
warning "Unable to create QEMU image file in ::1 imgfile::" ${imgfile}
fi
}
qemu_config_esclude(){
fn qemu_config_exclude
cat <<EOF
- /proc/*
- /sys/*
- /dev/*
- /tmp/*
- /mnt/*
- /live
- /persistence.conf
- /boot/grub/grub.cfg
- /boot/grub/menu.lst
- /boot/grub/device.map
- /boot/*.bak
- /boot/*.old-dkms
- /etc/udev/rules.d/70-persistent-cd.rules
- /etc/udev/rules.d/70-persistent-net.rules
- /etc/fstab
- /etc/fstab.d/*
- /etc/mtab
- /etc/blkid.tab
- /etc/blkid.tab.old
- /etc/apt/sources.list~
- /etc/crypttab
- /etc/initramfs-tools/conf.d/resume # see remove-cryptroot and nocrypt.sh
- /etc/initramfs-tools/conf.d/cryptroot # see remove-cryptroot and nocrypt.sh
- /home/snapshot
- /var/log/*
- /var/log/[a-b,A-Z]*
- /var/log/[d-f]*
- /var/log/[h-z]*
- /var/log/*gz
- /var/cache/apt/archives/*.deb
- /var/cache/apt/pkgcache.bin
- /var/cache/apt/srcpkgcache.bin
- /var/cache/apt/apt-file/*
- /var/cache/debconf/*~old
- /var/lib/apt/lists/*
- /var/lib/apt/*~
- /var/lib/apt/cdroms.list
- /var/lib/aptitude/*.old
- /var/lib/dhcp/*
- /var/lib/dpkg/*~old
- /var/spool/mail/*
- /var/mail/*
- /var/backups/*.gz
#- /var/backups/*.bak
- /var/lib/dbus/machine-id
- /var/lib/live/config/*
- /usr/share/icons/*/icon-theme.cache
- /root/.aptitude
- /root/.bash_history
- /root/.disk-manager.conf
- /root/.fstab.log
- /root/.lesshst
- /root/*/.log
- /root/.local/share/*
- /root/.nano_history
- /root/.synaptic
- /root/.VirtualBox
- /root/.ICEauthority
- /root/.Xauthority
- /root/.links2
- /root/.ssh
- /root/[a-zA-Z0-9]*
- /home/*/.Trash*
- /home/*/.local/share/Trash/*
- /home/*/.mozilla/*/Cache/*
- /home/*/.mozilla/*/urlclassifier3.sqlite
- /home/*/.mozilla/*/places.sqlite
- /home/*/.mozilla/*/cookies.sqlite
- /home/*/.mozilla/*/signons.sqlite
- /home/*/.mozilla/*/formhistory.sqlite
- /home/*/.mozilla/*/downloads.sqlite
- /home/*/.adobe
- /home/*/.aptitude
- /home/*/.bash_history
- /home/*/.cache
- /home/*/.dbus
- /home/*/.gksu*
- /home/*/.gvfs
- /home/*/.lesshst
- /home/*/.log
- /home/*/.macromedia
- /home/*/.nano_history
- /home/*/.pulse*
- /home/*/.recently-used
- /home/*/.recently-used.xbel
- /home/*/.local/share/recently-used.xbel
- /home/*/.thumbnails/large/*
- /home/*/.thumbnails/normal/*
- /home/*/.thumbnails/fail/*
- /home/*/.vbox*
- /home/*/.VirtualBox
- /home/*/VirtualBox\ VMs
#- /home/*/.wine
- /home/*/.xsession-errors*
- /home/*/.ICEauthority
- /home/*/.Xauthority
# You might want to comment these out if you're making a snapshot for
# your own personal use, not to be shared with others.
- /home/*/.gnupg
- /home/*/.ssh
- /home/*/.xchat2
### ignore all non-hidden files in /home/devuan -- KatolaZ -- 2016-05-21
- /home/devuan/[a-zA-Z0-9]*
EOF
}

View File

@ -1,318 +0,0 @@
#!/usr/bin/env zsh
#
# Copyright (c) 2016 Dyne.org Foundation
# libdevuansdk is written and maintained by
# Jaromil <jaromil@dyne.org>
# KatolaZ <katolaz@freaknet.org>
# parazyd <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/>.
## base system configurations
conf_print_debconf() {
fn conf_print_debconf
cat << EOF
console-common console-data/keymap/policy select Select keymap from full list
console-common console-data/keymap/full select en-latin1-nodeadkeys
EOF
}
conf_print_fstab() {
fn conf_print_fstab
cat << EOF
#<file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc nodev,noexec,nosuid 0 0
# rootfs
/dev/sda2 / ext4 errors=remount-ro 0 1
# boot
/dev/sda1 /boot ext2 noauto 0 0
EOF
}
conf_print_hostname() {
fn conf_print_hostname
req=(os)
ckreq || return 1
print ${os}
}
conf_print_hosts() {
fn conf_print_hosts
req=(os)
ckreq || return 1
cat << EOF
127.0.0.1 ${os} localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
fe00::0 ip6-mcastprefix
fe02::1 ip6-allnodes
fe02::1 ip6-allrouters
EOF
}
conf_print_networkifaces() {
fn conf_print_networkifaces
cat << EOF
# interfaces(5) file used by ifup(8) and ifdown(8)
# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
# auto eth0
# iface eth0 inet static
# address 10.0.1.10
# netmask 255.255.255.0
# allow-hotplug wlan0
# iface wlan0 inet manual
# wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
# allow-hotplug wlan1
# iface wlan1 inet manual
# wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
EOF
}
conf_print_resolvconf() {
fn conf_print_resolvconf
cat << EOF
nameserver 8.8.8.8
nameserver 8.8.4.4
EOF
}
conf_print_sourceslist() {
fn conf_print_sourceslist
req=(mirror release section)
ckreq || return 1
cat << EOF
deb ${mirror} ${release} ${section}
deb ${mirror} ${release}-updates ${section}
deb ${mirror} ${release}-security ${section}
deb-src ${mirror} ${release} ${section}
deb-src ${mirror} ${release}-updates ${section}
deb-src ${mirror} ${release}-security ${section}
EOF
}
conf_print_usrexcludes() {
fn conf_print_usrexcludes
cat <<EOF
# rsync excludes file for refractasnapshot and refractasnapshot-gui
# version 9.2.0
# Exclude some system files. These are required, and you probably
# shouldn't change them.
- /dev/*
- /cdrom/*
- /media/*
- /swapfile
- /mnt/*
- /sys/*
- /proc/*
- /tmp/*
- /live
- /persistence.conf
- /boot/grub/grub.cfg
- /boot/grub/menu.lst
- /boot/grub/device.map
- /boot/*.bak
- /boot/*.old-dkms
- /etc/udev/rules.d/70-persistent-cd.rules
- /etc/udev/rules.d/70-persistent-net.rules
- /etc/fstab
- /etc/fstab.d/*
- /etc/mtab
- /etc/blkid.tab
- /etc/blkid.tab.old
- /etc/apt/sources.list~
- /etc/crypttab
- /etc/initramfs-tools/conf.d/resume # see remove-cryptroot and nocrypt.sh
- /etc/initramfs-tools/conf.d/cryptroot # see remove-cryptroot and nocrypt.sh
- /home/snapshot
# Added for newer version of live-config/live-boot in wheezy
# These are only relevant here if you create a snapshot while
# you're running a live-CD or live-usb.
- /lib/live/overlay
- /lib/live/image
- /lib/live/rootfs
- /lib/live/mount
- /run/*
## Entries below are optional. They are included either for privacy
## or to reduce the size of the snapshot. If you have any large
## files or directories, you should exclude them from being copied
## by adding them to this list.
##
## Entries beginning with /home/*/ will affect all users.
# Uncomment this to exclude everything in /var/log/
#- /var/log/*
# As of version 9.2.0, current log files are truncated,
# and archived log files are excluded.
#
# The next three lines exclude everything in /var/log
# except /var/log/clamav/ (or anything else beginning with "c") and
# /var/log/gdm (or anything beginning with "g").
# If clamav log files are excluded, freshclam will give errors at boot.
- /var/log/[a-b,A-Z]*
- /var/log/[d-f]*
- /var/log/[h-z]*
- /var/log/*gz
- /var/cache/apt/archives/*.deb
- /var/cache/apt/pkgcache.bin
- /var/cache/apt/srcpkgcache.bin
- /var/cache/apt/apt-file/*
- /var/cache/debconf/*~old
- /var/lib/apt/lists/*
- /var/lib/apt/*~
- /var/lib/apt/cdroms.list
- /var/lib/aptitude/*.old
- /var/lib/dhcp/*
- /var/lib/dpkg/*~old
- /var/spool/mail/*
- /var/mail/*
- /var/backups/*.gz
#- /var/backups/*.bak
- /var/lib/dbus/machine-id
- /var/lib/live/config/*
- /usr/share/icons/*/icon-theme.cache
- /root/.aptitude
- /root/.bash_history
- /root/.disk-manager.conf
- /root/.fstab.log
- /root/.lesshst
- /root/*/.log
- /root/.local/share/*
- /root/.nano_history
- /root/.synaptic
- /root/.VirtualBox
- /root/.ICEauthority
- /root/.Xauthority
- /root/.links2
- /root/.ssh
- /root/[a-zA-Z0-9]*
- /home/*/.Trash*
- /home/*/.local/share/Trash/*
- /home/*/.mozilla/*/Cache/*
- /home/*/.mozilla/*/urlclassifier3.sqlite
- /home/*/.mozilla/*/places.sqlite
- /home/*/.mozilla/*/cookies.sqlite
- /home/*/.mozilla/*/signons.sqlite
- /home/*/.mozilla/*/formhistory.sqlite
- /home/*/.mozilla/*/downloads.sqlite
- /home/*/.adobe
- /home/*/.aptitude
- /home/*/.bash_history
- /home/*/.cache
- /home/*/.dbus
- /home/*/.gksu*
- /home/*/.gvfs
- /home/*/.lesshst
- /home/*/.log
- /home/*/.macromedia
- /home/*/.nano_history
- /home/*/.pulse*
- /home/*/.recently-used
- /home/*/.recently-used.xbel
- /home/*/.local/share/recently-used.xbel
- /home/*/.thumbnails/large/*
- /home/*/.thumbnails/normal/*
- /home/*/.thumbnails/fail/*
- /home/*/.vbox*
- /home/*/.VirtualBox
- /home/*/VirtualBox\ VMs
#- /home/*/.wine
- /home/*/.xsession-errors*
- /home/*/.ICEauthority
- /home/*/.Xauthority
# You might want to comment these out if you're making a snapshot for
# your own personal use, not to be shared with others.
- /home/*/.gnupg
- /home/*/.ssh
- /home/*/.xchat2
### ignore all non-hidden files in /home/devuan -- KatolaZ -- 2016-05-21
- /home/devuan/[a-zA-Z0-9]*
###
### ignore the symlink /initrd.img -> /boot/initrd.img-`uname -r`
### -- KatolaZ -- 2016-05-21
###
##- /initrd.img
# Exclude ssh_host_keys. New ones will be generated upon live boot.
# This fixes a security hole in all versions before 9.0.9-3.
# If you really want to clone your existing ssh host keys
# in your snapshot, comment out these two lines.
#- /etc/ssh/ssh_host_*_key*
#- /etc/ssh/ssh_host_key*
# Examples of things to exclude in order to keep the image small:
#- /home/fred/Downloads/*
#- /home/*/Music/*
#- /home/user/Pictures/*
#- /home/*/Videos/*
# To exclude all hidden files and directories in your home, uncomment
# the next line. You will lose custom desktop configs if you do.
##- /home/*/.[a-z,A-Z,0-9]*
#### Exclude the large initramfs -- KatolaZ -- 2016-05-16
##- /boot/initrd.img*
#### Exclude inittab backup files -- KatolaZ -- 2016-06-04
##- /etc/inittab.*
EOF
}

1
zuper

@ -1 +0,0 @@
Subproject commit a9b9d76b0d7efdf9ad6f5180ae447b3eabbc09d1