~rbn/buildslack

builds SlackBuilds in clean environments
git log mtime, switch to turn off mtime checking
lsof -Q to not fail on empty result

clone

read-only
https://git.sr.ht/~rbn/buildslack
read/write
git@git.sr.ht:~rbn/buildslack

You can also use your local clone with git send-email.

#buildslack, builds SlackBuilds in clean environments

#usage

buildslack [options] [slackbuild name]
 -db value            database with slackbuild and package index <db.sqlite>
 -envroot value       build environment path <env>
 -slackroot value     slackware install path <slackroot>
 -mirror value        slackware mirror path </mnt/mirror/slackware/slackware64-current>
 -slackbuilds value   slackbuilds path <slackbuilds>
 -custom value        customizations path <custom>
 -sources value       source cache path <sources>
 -packages value      packages directory path <packages>
 -series value        bootstrap these package series <a,ap,d,e,k,l,n,t,tcl,x,xap,y>
 -bootstrap           bootstrap slackware install into slackroot
 -upgraderoot         upgrade slackware install in slackroot
 -initdb              initialize database
 -fkey                enable foreign key checks
 -index               build slackbuilds/patches index
 -build               build a package
 -upgrade             upgrade package / upgrade all packages
 -backup              keep backup of previous build
 -keep                keep environments of broken builds
 -cont                continue upgrade after failed builds
 -debug               print debug output
 -force               force redownload and rebuild
 --                   Forcibly stop option processing
 -help                Print this message
 -?                   Print this message
	

#setup

	

#installation

#requirements

as buildslack is written in TCL, you need it. just install it from the tcl series. it also requires tcllib which can be found on SlackBuilds.org.

#just run the sources

you can put the buildslack and *.tcl files somewhere and run with tclsh buildslack

#install using make

install it somewhere with e.g. make install PREFIX=/usr LIBDIR=lib64 BINDIR=bin (review the Makefile for the variables ;)

#install using SlackBuild

i have prepared a SlackBuild for buildslack. it's not published on slackbuilds.org, but you can find it in my custom repository.

#install using starpack

you can also build a starpack (bundled tcl runtime and sources) with make buildslack.kit. this will download sdx and kitcreator, create a tclkit with the required packages and glue everything together. the result is a binary file buildslack.kit.

#preparing to build packages

#slackware root

you need a seperate slackware installation somewhere, used as lower directory of the overlayfs. this can be done manually or with the -bootstrap option:

buildslack -slackroot ./slackroot -bootstrap -mirror /path/to/slackware64-current

you can select which package series are installed using the -series argument. by default everything except kde is installed.

#indexing slackbuilds

buildslack uses a sqlite database to reason about slackbuilds and their dependencies. this index has to be rebuild after changes to the slackbuilds info files, eg. after pulling from slackbuilds.org repo.

buildslack -index -slackbuilds ./slackbuilds -db ./db.sqlite

this usually takes a few moments as every .info file has to be read and parsed.

#building packages

after these steps you can build a package using

buildslack -build -db ./db.sqlite -slackroot ./slackroot -envroot ./env -sources ./sources -packages ./packages slackbuildname

with -envroot being the directory where the overlayfs will be assembled, -sources giving the directory where downloaded source files will be stored and build packages will be stored into the directory specified by -packages. this will then recursively build (skipping present packages) every dependency and then the requested slackbuild.

#customizations

sometimes it is required to customize the build environment, e.g. adding user and group for a slackbuild. these customizations are stored seperately from the slackbuilds in a directory structure mirroring the one in which slackbuilds are stored. shell scripts (files with extension .sh) stored in those directories are sourced before the slackbuild is executed. additionally the info file can also be overridden by placing a modified copy into the respective customization directory.

if a customization for a slackbuild is added, the slackbuilds need to be reindexed.

#global customizations

it is possible to apply customizations to every slackbuild for example to set MAKEFLAGS=-j$(nproc). these global customizations go into the global directory in the customizations directory structure (this assumes that there will be no category "global" and is due to change, but works for now).

customizations of a slackbuild with the same name as a global one replace it.

#examples
#global/makeflags.sh
export MAKEFLAGS="-j$(nproc)"
	
#system/postgresql/usergroup.sh
groupadd -g 209 postgres
useradd -u 209 -g 209 -d /var/lib/pgsql postgres

#helper script

you find a helper script in scripts/build.sh which automatizes pulling slackbuilds from git, reindexing the slackbuilds, building and updating packages and uploading the packages with rsync. it might need some adaptations for your own requirements.

the idea of this script is that you create a "workspace"-folder containing the data for a repository of packages. in said workspace folder you can place a file config containing the configuration of this workspace. the configuration for the workspace used to build packages for my desktop systems looks a bit like this:

# cat desktop/config
workdir="desktop"
repo="slackbuilds"
branch="master"
sources="sources"
custom="custom"
envroot="env"
packages="${workdir}/packages"
db="${workdir}/db.sqlite"
slackroot="slackroot-current"
export RSYNC_RSH="ssh -i $HOME/.ssh/id_ed25519_upload -l filedrop"
rsyncremote="my.remote.server.example.org:packages/"

this results in using slackbuilds from the folder ./slackbuilds, which is a git repository, so the branch master is used. source files are downloaded to ./sources. customizations are taken from the folder custom. the chroot-overlays will be created in ./env. built packages will be moved to ./desktop/packages and the sqlite database is stored in ./desktop/db.sqlite. packages will be built in using ./slackroot-current as slackware install. after building the packages they will be copied to my server using rsync (RSYNC_RSH is described in the rsync man page).

#license

	
buildslack, builds SlackBuilds in clean environments
Copyright (C) 2021  Ruben Schuller <code@rbn.im>
	
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, version 3 of the License.
	
This program 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 Affero General Public License for more details.
	
You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <https://www.gnu.org/licenses/>.