renamed files and separated init to fix global scoping

This commit is contained in:
Jaromil 2016-06-15 10:06:49 +02:00
parent 06387033a1
commit 86759f2c02
3 changed files with 139 additions and 137 deletions

View File

@ -1,137 +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/>.
libdevuansdk_version=0.1
setopt pushdsilent
# export PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin"
########################
## Load Zuper extensions
source $SDK_LIB/zuper/zuper
vars+=(SDK_PREFIX SDK_HOME SDK_CONF SDK_LIB SDK_ARM SDK_VM SDK_LIVE)
notice "Loading Devuan SDK library v$devuan_sdk_version"
vars+=(libdevuansdk_version os release version mirror section)
sdk_init(){
fn sdk_init
# 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=${strapdir:-"${workdir}/${os}-${release}-${version}"}
# 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
# create mandatory workdirs
# $strapdir
mkdir -p ${strapdir}
# $outdir
mkdir -p ${outdir}
# conclude initialization
if [[ -r $SDK_LIB/zuper/zuper.init ]]; then
source $SDK_LIB/zuper/zuper.init
else source ./zuper/zuper.init; fi
# add all other binaries to the path
[[ -r $SDK_PREFIX/cli-sdk/sdk ]] &&
path+=($SDK_PREFIX/cli-sdk)
# export PATH=$PATH:$SDK_PREFIX/cli-sdk/sdk
# path+=($SDK_LIB/bin)
rehash
# ...
act "library succesfully loaded"
} # Closes sdk_init

33
sdk Executable file
View File

@ -0,0 +1,33 @@
#!/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/>.
setopt pushdsilent
# export PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin"
########################
## Load Zuper extensions
source $SDK_LIB/zuper/zuper
vars+=(SDK_PREFIX SDK_HOME SDK_CONF SDK_LIB SDK_ARM SDK_VM SDK_LIVE)
notice "Loading Devuan SDK library v$devuan_sdk_version"
vars+=(libdevuansdk_version os release version mirror section)

106
sdk.init Executable file
View File

@ -0,0 +1,106 @@
#!/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
# 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=${strapdir:-"${workdir}/${os}-${release}-${version}"}
# 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
# create mandatory workdirs
# $strapdir
mkdir -p ${strapdir}
# $outdir
mkdir -p ${outdir}
# conclude initialization
source $SDK_LIB/zuper/zuper.init
act "library succesfully loaded"