Update for latest libdevuansdk (overhaul).

This commit makes vm-sdk work with latest libdevuansdk. We also drop
fetching blends from http, and dockerfiles. These should be created
beforehand and put in a file for vm-sdk to load.
This commit is contained in:
parazyd 2020-11-13 10:24:42 +01:00
parent 056d2beb40
commit 600591bfbb
No known key found for this signature in database
GPG Key ID: 6B636BF0493EE747
4 changed files with 41 additions and 108 deletions

View File

@ -1,5 +1,5 @@
vm-sdk vm-sdk
======= ======
vm-sdk is simple distro build system aimed at creating Vagrant boxes vm-sdk is simple distro build system aimed at creating Vagrant boxes
and other virtual machines. and other virtual machines.
@ -15,16 +15,13 @@ It requires the following packages to be installed in addition to the
### Devuan ### Devuan
``` ```
virtualbox vagrant qemu qemu-utils qemu qemu-utils
```
* http://download.virtualbox.org/virtualbox/5.1.30/virtualbox-5.1_5.1.30-118389~Debian~stretch_amd64.deb
* http://download.virtualbox.org/virtualbox/5.1.30/virtualbox-5.1_5.1.30-118389~Debian~jessie_amd64.deb
* https://releases.hashicorp.com/vagrant/2.0.0/vagrant_2.0.0_x86_64.deb
### Gentoo ### Gentoo
``` ```
app-emulation/virtualbox app-emulation/vagrant app-emulation/qemu app-emulation/qemu
``` ```
## Initial setup ## Initial setup
@ -68,37 +65,8 @@ to build the image for.
Once initialized, you can run the helper command: Once initialized, you can run the helper command:
``` ```
; build_vagrant_dist ; build_vm_dist
``` ```
The image will automatically be build for you. Once finished, you will be The image will automatically be build for you. Once finished, you will be
able to find it in the `dist/` directory in vm-sdk's root. able to find it in the `dist/` directory in vm-sdk's root.
For more info, see the `doc/` directory.
## 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-2017 by the Dyne.org Foundation
Devuan SDK components were designed, and are 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/>.

37
config
View File

@ -1,5 +1,6 @@
#!/usr/bin/env zsh #!/usr/bin/env zsh
# Copyright (c) 2016-2017 Dyne.org Foundation # shellcheck=bash
# Copyright (c) 2016-2020 Dyne.org Foundation
# vm-sdk is written and maintained by Ivan J. <parazyd@dyne.org> # vm-sdk is written and maintained by Ivan J. <parazyd@dyne.org>
# #
# This file is part of vm-sdk # This file is part of vm-sdk
@ -17,27 +18,29 @@
# You should have received a copy of the GNU General Public License # 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/>. # along with this source code. If not, see <http://www.gnu.org/licenses/>.
arch="amd64"
## vm-sdk configuration
## ---------------------
arch=amd64
size=20479 size=20479
imageformat=qcow2 imageformat="qcow2"
#imageformat=raw #imageformat=raw
parted_type="dos"
dos_boot="ext4 2048s 264191s"
dos_root="ext4 264192s 100%"
bootfs="ext4"
rootfs="ext4"
PATH="$PATH:/usr/sbin:/sbin" PATH="$PATH:/usr/sbin:/sbin"
## options for `make` when building kernel # Comment if you wish to disable stage4 archives for faster rebuilding
MAKEOPTS="-j$(expr $(grep -c 'processor' /proc/cpuinfo) + 1)" CPIO_STAGE4=1
## uncomment if you wish to create stage4 tarballs for faster rebuilding # Comment if you wish to disable image compression
# TAR_STAGE4=true COMPRESS_IMAGE=1
## Comment out if you don't want to create a cloud-based qcow. # extra_packages for all images
vars+=(makecloud) extra_packages+=(fake-hwclock busybox-static ntp grub-pc)
makecloud=true
## extra_packages for all images case "$arch" in
extra_packages+=(fake-hwclock busybox-static ntp) i386) extra_packages+=(linux-image-686) ;;
extra_packages+=(fbterm) amd64) extra_packages+=(linux-image-amd64) ;;
esac

@ -1 +1 @@
Subproject commit 0611dccb1726bb4085bd98c5ddc0bb10930a2e0a Subproject commit aedf124832b7643ab3f215395cb6083a9cf2db7f

68
sdk
View File

@ -1,5 +1,5 @@
#!/usr/bin/env zsh #!/usr/bin/env zsh
# Copyright (c) 2016-2018 Dyne.org Foundation # Copyright (c) 2016-2020 Dyne.org Foundation
# vm-sdk is written and maintained by Ivan J. <parazyd@dyne.org> # vm-sdk is written and maintained by Ivan J. <parazyd@dyne.org>
# #
# This file is part of vm-sdk # This file is part of vm-sdk
@ -17,31 +17,31 @@
# You should have received a copy of the GNU General Public License # 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/>. # along with this source code. If not, see <http://www.gnu.org/licenses/>.
vmsdk_version="0.2" vmsdk_version="1.0"
R=${VM_SDK:-$PWD} R="${VM_SDK:-$PWD}"
DEBUG=0 DEBUG=0
QUIET=0 QUIET=0
source $R/lib/zuper/zuper source "$R/lib/zuper/zuper"
## global vars # Global vars
vars+=(vmsdk_version) vars+=(vmsdk_version)
vars+=(R workdir strapdir) vars+=(R workdir strapdir)
vars+=(os oslib blendlib) vars+=(os oslib blendlib)
vars+=(MAKEOPTS) vars+=(MAKEOPTS)
## global arrs # Global arrs
arrs+=(extra_packages) arrs+=(extra_packages)
## global maps # Global maps
maps+=(board_map os_map blend_map) maps+=(board_map os_map blend_map)
source $R/config source "$R/config"
## conclude zuper initialization # Conclude zuper initialization
source $R/lib/zuper/zuper.init source "$R/lib/zuper/zuper.init"
load() { load() {
fn load "$@" fn load "$@"
@ -51,7 +51,7 @@ load() {
ckreq || return 1 ckreq || return 1
os_map=( os_map=(
"devuan" "$R/lib/libdevuansdk/libdevuansdk" "devuan" "$R/lib/libdevuansdk/libdevuansdk"
) )
blend_map=( blend_map=(
@ -62,49 +62,11 @@ load() {
) )
oslib="${os_map[$os]}" oslib="${os_map[$os]}"
[[ -f $oslib ]] || { die "no valid distro specified"; exit 1 } [[ -f $oslib ]] || { die "no valid distro specified"; exit 1 }
source $oslib source $oslib
blendlib="${blend_map[$blend]}" blendlib="${blend_map[$blend]}"
if [[ -z "$blendlib" ]] && [[ -n "$blend" ]]; then
if [[ "$blend" =~ '^http' ]]; then
notice "grabbing blend from the internetz"
dlpath="$R/extra/blends/$(basename $blend)"
wget -O "$dlpath" "$blend"
sed 1q "$dlpath" | grep -q '^#!/usr/bin/env zsh' && blendlib="$dlpath"
fi
if [[ -z "$blendlib" ]] && [[ -n "$blend" ]]; then
[[ -n "$dlpath" ]] && blend="$dlpath"
act "trying to parse an unknown blend"
# Check if it's a Dockerfile
if grep -qi '^FROM ' "$blend"; then
act "The blend is a Dockerfile"
parsedfile="$($LIBPATH/extra/dockerfile_parse.py "$blend")"
[[ $? = 0 ]] || { die "Could not parse the Dockerfile" ; exit 1}
cat > "$R/$(basename ${blend}).blend" << __EOF__
#!/usr/bin/env zsh
# Parsed with dockerfile_parse.py
#
blend_postinst() {
fn blend_postinst
req=(strapdir blend)
ckreq || return 1
notice "executing blend postinst"
cat << ___EOF___ | sudo tee \$strapdir/blendpostinst >/dev/null
${parsedfile}
___EOF___
chroot-script -d blendpostinst || zerr
}
__EOF__
blendlib="$R/$(basename ${blend}).blend"
fi
fi
fi
[[ -f $blendlib ]] || { act "no blend specified" } [[ -f $blendlib ]] || { act "no blend specified" }
[[ -f $blendlib ]] && { [[ -f $blendlib ]] && {
source $blendlib || zerr source $blendlib || zerr
@ -114,15 +76,15 @@ __EOF__
workdir="$R/tmp/${os}-${arch}-build" workdir="$R/tmp/${os}-${arch}-build"
strapdir="$workdir/bootstrap" strapdir="$workdir/bootstrap"
mkdir -p $strapdir mkdir -p "$strapdir"
export LANG=C export LANG=C
export LC_ALL=C export LC_ALL=C
source $R/lib/zuper/zuper.init source "$R/lib/zuper/zuper.init"
} }
TRAPZERR() { zerr; return $? } TRAPZERR() { zerr; return $? }
notice "vm-sdk loaded" notice "vm-sdk $vmsdk_version loaded"
export PROMPT="%F{yellow}%(?..%? )%{$reset_color%}vmsdk@%{$fg[red]%}%m %{$reset_color%}%3c %# " export PROMPT="%F{yellow}%(?..%? )%{$reset_color%}vmsdk@%{$fg[red]%}%m %{$reset_color%}%3c %# "