LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 10-07-2017, 06:08 AM   #1
dchmelik
Member
 
Registered: Nov 2008
Location: Washington state, USA
Distribution: NetBSD, FreeBSD, OpenBSD, OpenSolaris, Slackware, Salix, FreeSlack, Android
Posts: 263

Rep: Reputation: 24
Slackware(64) 14.2 chroot?


I use Slackware64 up-to-date stable 14.2 and would like full chroot setup instructions (just into Slackware(64) 14.2.)

Some things (emulators, emus, virtual machines, VMs) are becoming more popular (and usually recommended on freenode IRC ##slackware & #slackbuilds) but for me, that's normally a stressful, over-complicated hassle overkill (I rarely use VMs and can't paste into AQEMU.)

Sure, I'll be updating SlackBuilds I write, which don't need an entire emu/VM (maybe two, GRX, and KuickShow, would be better in VM, but KuickShow has no new version in years, may not even work on next Slackware & X/KDE. GRX was also old until they rewrote with only Debian/etc. compile instructions, so unsure I'll continue; anyone else may attempt/take GRX rewrite's SlackBuild for SBo, which nothing depends on anyway, just is interesting in supporting both console/SVGAlib & X/SDL.) My other SlackBuilds are just command-line daemons/libraries and/or games; they don't need an entire OS as if running on hardware (let alone X, nor anything else, beyond command-line, emu/VM may provide, like emulated asm & hardware.)

I'd really just like to 'Keep It Simple ('KISS(!):') chroot (with a shell alias I have) to immediately compile on consoles directly there (if I'm even in X) or also terminal I can paste into (X or even from it with clipb to tty,) instead of a complicated, resource-hungry emulator/VM window in X with way more than I need, that takes longer to get into (some minutes boot,) more maintenance/setup, more crashes, corruption if the process is killed, etc., then I have to set up the method to copy in & out... just too many more issues, too cumbersome, for likely no fewer potential bugs, no more benefits, in my case.

Last edited by dchmelik; 10-07-2017 at 06:24 AM.
 
Old 10-07-2017, 06:38 AM   #2
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-14.2 on Lenovo Thinkpad W520
Posts: 7,703

Rep: Reputation: 2620Reputation: 2620Reputation: 2620Reputation: 2620Reputation: 2620Reputation: 2620Reputation: 2620Reputation: 2620Reputation: 2620Reputation: 2620Reputation: 2620
Well, it all depends why you want to chroot. Assuming that it's to build stuff, if you have in mind the risks running a SlackBuild that you just wrote as root, you could simply use fakeroot. That's what I always do.

Now, if what you want is run the SlackBuild in a clean environment, i.e. in a genuine Slackware without any third party software but the needed deps of the software you are compiling, I think that using a VM is the simplest way, unless you have another (clean) Slackware in a dedicated partition where you could just chroot (assuming the same Arch).

This being said I am very far be an expert in that field, but there has been an interesting discussion in this thread.

Last edited by Didier Spaier; 10-07-2017 at 06:40 AM.
 
Old 10-07-2017, 06:44 AM   #3
dchmelik
Member
 
Registered: Nov 2008
Location: Washington state, USA
Distribution: NetBSD, FreeBSD, OpenBSD, OpenSolaris, Slackware, Salix, FreeSlack, Android
Posts: 263

Original Poster
Rep: Reputation: 24
I don't worry much about 'running stuff as root,' even though I login as root at least every week, if not every day. The reason is clean environment. Maybe for that, emu/VM is simplest for you, not me.
 
Old 10-07-2017, 10:59 AM   #4
Gordie
Member
 
Registered: Aug 2007
Distribution: Slackware, Puppy
Posts: 285

Rep: Reputation: 81
Could you not have two installs of Slackware and keep one clean to boot into and use for this purpose?
 
Old 10-07-2017, 11:44 AM   #5
orbea
Member
 
Registered: Feb 2015
Distribution: Slackware64-current
Posts: 728

Rep: Reputation: Disabled
This is how I make chroots.

https://www.linuxquestions.org/quest...root-825598/#5

To chroot into them I do this.
Code:
#! /bin/sh

TARGET=/media/data/home/chroot/Slackware64-14.2
mount -o bind /proc $TARGET/proc
mount -o bind /sys $TARGET/sys
mount -o bind /dev $TARGET/dev
mount -o bind /tmp $TARGET/tmp
mount --bind /etc/resolv.conf $TARGET/etc/resolv.conf

chroot $TARGET /bin/bash -l
You can exit the chroot once done with.
Code:
#! /bin/sh

TARGET=/media/data/home/chroot/Slackware64-14.2
umount -l $TARGET/proc
umount -l $TARGET/sys
umount -l $TARGET/dev
umount -l $TARGET/tmp
umount -l $TARGET/etc/resolv.conf
For 32-bit chroots you want this instead.
Code:
#! /bin/sh

TARGET=/media/data/home/chroot/Slackware32-14.2
mount --rbind /proc $TARGET/proc
mount --rbind /sys $TARGET/sys
mount --rbind /dev $TARGET/dev
mount --bind /etc/resolv.conf $TARGET/etc/resolv.conf

linux32 chroot $TARGET /bin/bash -l
 
2 members found this post helpful.
Old 10-08-2017, 05:38 AM   #6
mid-kid
LQ Newbie
 
Registered: Oct 2016
Posts: 22

Rep: Reputation: Disabled
For building packages on a clean install, I'd like to recommend looking into overlayfs.
You can mount a read-write directory structure over your read-only system, and afterwards you can view and delete the diff. It's very useful for quickly reverting to the "clean" state.

As for setting up the chroot, I found the slackware wiki isn't as complete as I'd like. This script can set up a slackware chroot, even on systems that don't run slackware, and generate all necessary files: http://chunk.io/midkid/b31b78e3eaef4df7b7ffdaf4e25a2ba5

As for entering the chroot, this is really up to you. As I mentioned earlier, I like using overlayfs. I have a script, to which you feed the clean chroot, a "build" directory, and a slackbuild, and it'll mount the slackbuild's directory under /mnt, runs it, and saves build log in the build directory, next to the filesystem diff: http://chunk.io/midkid/16c2a2ef3fc344619e5e730a908ae2fd
It's a bit of a hassle to use, but you can modify it to simply enter a shell, and it's good enough for illustrative purposes.

If you don't like manual work like this, I'd recommend you look into docker, which also serves fine for this purpose. You feed it your clean tared chroot directory, from which it creates an "image", and you can spawn as many "containers" as you want from it, and it works like overlayfs, allowing you to see the filesystem diff based on the "base" image, extract files, create new reuseable "layers" on top of it, etc.
It's a bit more of a learning curve but much less of a hassle than shell scripting, and even though it has a ton of features you'll probably never use, it comes with a negligible overhead, since it actually uses the same techniques as in the shell script above (overlayfs, chroot, uunshare), as well as other techniques to provide better isolation.
 
Old 10-09-2017, 03:22 PM   #7
drumz
Member
 
Registered: Apr 2005
Location: Scottsdale, AZ, USA
Distribution: Slackware
Posts: 196

Rep: Reputation: 43
Quote:
Originally Posted by dchmelik View Post
I ... would like full chroot setup instructions (just into Slackware(64) 14.2.)
I use a chroot for compiling SBo packages. Why don't I use slackrepo? Not-invented-here syndrome, I guess.

Step 1: Download and save all bash scripts in /root/build/*

Step 2: Modify PKG_SRC and SLACK_TREE variables in all scripts (and also possibly RELEASE_ROOT, PATCHED_ROOT, BUILD_ROOT, UPPERDIR, WORKDIR, and CHROOT). There is also a hard-coded reference to /home/erich in use-build-environment.sh that you'll have to update. It's for non-SBo (but locally installed) packages (e.g. alien's packages). Also modify /etc/sbopkg/sbopkg.conf and set the OUTPUT variable to /tmp/SBo/pkgs.

Step 3: Run install-release.sh
Code:
#!/bin/bash
# install-release.sh
#
# Copyright 2016 Erich Ritz
#
# This script installs Slackware64 14.2 to a chroot environment.

IFS="$(printf '\n\t')"

SERIES=(a ap d e f k kde l n t tcl x xap xfce y)
PKG_SRC=/home/erich/pkgs/slackware/slackware64-14.2/slackware64
NEW_ROOT=/root/build/14.2-release

if [ ! -d "$NEW_ROOT" ]; then
	mkdir -p "$NEW_ROOT"
fi

# These packages are safe to install using the --root option of installpkg and
# set up the initial chroot environment from which we can install all other
# packages.
BASE_PKGS=( \
	a/aaa_base-14.2-x86_64-2.txz \
	a/aaa_elflibs-14.2-x86_64-23.txz \
	a/aaa_terminfo-5.9-x86_64-1.txz \
	a/devs-2.3.1-noarch-25 \
	a/pkgtools-14.2-noarch-10.txz \
	a/etc-14.2-x86_64-7.txz \
	a/tar-1.29-x86_64-1.txz \
	a/xz-5.2.2-x86_64-1.txz \
	a/findutils-4.4.2-x86_64-1.txz \
	a/bash-4.3.046-x86_64-1.txz \
	a/coreutils-8.25-x86_64-2.txz \
	a/grep-2.25-x86_64-1.txz \
	a/sed-4.2.2-x86_64-1.txz \
	a/util-linux-2.27.1-x86_64-1.txz)

for pkg in "${BASE_PKGS[@]}" ; do
	echo " *** --- *** Installing package $pkg *** --- ***"
	installpkg --root "$NEW_ROOT" "$PKG_SRC/$pkg"
done

# Copy files needed by the chroot installpkg.  All of these will be overwritten
# when installing glibc-solibs-*.txz.
copy_file() {
	cp "$1" "$NEW_ROOT$1"
}
link_file() {
	( cd "$NEW_ROOT$1" ; ln -sf "$2" "$3" )
}
copy_file /lib64/libdl-2.23.so
link_file /lib64 libdl-2.23.so libdl.so.2
copy_file /lib64/libc-2.23.so
link_file /lib64 libc-2.23.so libc.so.6
copy_file /lib64/ld-2.23.so
link_file /lib64 ld-2.23.so ld-linux-x86-64.so.2
copy_file /lib64/libpthread-2.23.so
link_file /lib64 libpthread-2.23.so libpthread.so.0

# The only packages that touch /proc, /sys, and /dev are aaa_base and devs.
# Since they are already installed, they will be skipped when using upgradepkg
# to install all packages.  Thus, it is safe to mount /proc, /sys, and /dev in
# the chroot environment.
mount -t proc proc "$NEW_ROOT"/proc || exit 1
#mount -B /sys "$NEW_ROOT"/sys || exit 1
#mount -B /dev "$NEW_ROOT"/dev || exit 1

# The only package to touch /mnt is aaa_base, so use /mnt as the location of the
# Slackware tree.
mount -B "$PKG_SRC" "$NEW_ROOT"/mnt || exit 1

# Define the installpkg_chroot function.  Use upgradepkg rather than installpkg
# because upgradepkg will skip packages that are already installed - a desirable
# behavior because we don't want to reinstall aaa_base and devs packages.
installpkg_chroot() {
	chroot "$NEW_ROOT" upgradepkg --install-new "$1"
}

# Install a few more base packages, now using the chroot.
# These packages provide binaries called from various doinst.sh scripts.
installpkg_chroot /mnt/a/glibc-solibs-2.23-x86_64-1.txz
installpkg_chroot /mnt/ap/texinfo-6.1-x86_64-1.txz
installpkg_chroot /mnt/l/glib2-2.46.2-x86_64-2.txz
installpkg_chroot /mnt/l/desktop-file-utils-0.22-x86_64-1.txz
installpkg_chroot /mnt/l/shared-mime-info-1.6-x86_64-1.txz
installpkg_chroot /mnt/l/gdk-pixbuf2-2.32.3-x86_64-1.txz
installpkg_chroot /mnt/l/gtk+2-2.24.30-x86_64-1.txz
# fontconfig is used by all font packages
installpkg_chroot /mnt/l/glibc-2.23-x86_64-1.txz
installpkg_chroot /mnt/l/freetype-2.6.3-x86_64-1.txz
installpkg_chroot /mnt/l/harfbuzz-1.2.7-x86_64-1.txz
installpkg_chroot /mnt/x/libfontenc-1.1.3-x86_64-1.txz
installpkg_chroot /mnt/x/fontconfig-2.11.1-x86_64-2.txz
installpkg_chroot /mnt/x/mkfontscale-1.1.2-x86_64-2.txz
installpkg_chroot /mnt/x/mkfontdir-1.0.7-noarch-1.txz

for series in "${SERIES[@]}" ; do
	echo " *** --- *** Installing series $series *** --- ***"
	for pkgfull in $PKG_SRC/$series/*.t?z ; do
		pkg="$(basename "$pkgfull")"
		installpkg_chroot "/mnt/$series/$pkg"
	done
done

# Unmount
umount "$NEW_ROOT"/mnt
#umount "$NEW_ROOT"/dev
#umount "$NEW_ROOT"/sys
umount "$NEW_ROOT"/proc
Step 4: Run install-patched.sh to install Slackware patches:
Code:
#!/bin/bash
# install-patched.sh
#
# Copyright 2016 Erich Ritz
#
# This script updates the chroot Slackware64 14.2 to include all patches

IFS="$(printf '\n\t')"

SLACK_TREE=/home/erich/pkgs/slackware/slackware64-14.2
PKG_SRC=$SLACK_TREE/patches/packages
RELEASE_ROOT=/root/build/14.2-release
PATCHED_ROOT=/root/build/14.2-patched
WORKDIR=/root/build/14.2-patched-work
CHROOT=/root/build/chroot

if [ ! -d "$PATCHED_ROOT" ]; then
	mkdir -p "$PATCHED_ROOT"
fi
if [ ! -d "$WORKDIR" ]; then
	mkdir -p "$WORKDIR"
fi
if [ ! -d "$CHROOT" ]; then
	mkdir -p "$CHROOT"
fi

#	mozilla-thunderbird-45.2.0-x86_64-1_slack14.2.txz \
#	stunnel-5.35-x86_64-1_slack14.2.txz \
#	php-5.6.24-x86_64-1_slack14.2.txz \
#	curl-7.50.1-x86_64-1_slack14.2.txz \
#	mozilla-firefox-45.3.0esr-x86_64-1_slack14.2.txz \
#	php-5.6.25-x86_64-1_slack14.2.txz \
#	openssl-1.0.2i-x86_64-1_slack14.2.txz \
#	openssl-solibs-1.0.2i-x86_64-1_slack14.2.txz \
#	bind-9.10.4_P2-x86_64-1_slack14.2.txz \
#	glibc-zoneinfo-2016f-noarch-1_slack14.2.txz \
#	mozilla-thunderbird-45.3.0-x86_64-1_slack14.2.txz \
#	mariadb-10.0.27-x86_64-1_slack14.2.txz \
#	php-5.6.26-x86_64-1_slack14.2.txz \
#	linux-4.4.19/kernel-huge-4.4.19-x86_64-1_slack14.2.txz \
#	linux-4.4.19/kernel-generic-4.4.19-x86_64-1_slack14.2.txz \
#	linux-4.4.19/kernel-headers-4.4.19-x86-1_slack14.2.txz \
#	linux-4.4.19/kernel-modules-4.4.19-x86_64-1_slack14.2.txz \
#	linux-4.4.19/kernel-source-4.4.19-noarch-1_slack14.2.txz \
#	linux-4.4.19/kernel-firmware-20160823git-noarch-1_slack14.2.txz \
#	bind-9.10.4_P3-x86_64-1_slack14.2.txz \
#	curl-7.50.3-x86_64-1_slack14.2.txz \
#	glibc-zoneinfo-2016g-noarch-1_slack14.2.txz \
#	mozilla-firefox-45.4.0esr-x86_64-1_slack14.2.txz \
#	mozilla-firefox-45.5.0esr-x86_64-1_slack14.2.txz \
#	mozilla-thunderbird-45.4.0-x86_64-1_slack14.2.txz \
#	linux-4.4.29/kernel-huge-4.4.29-x86_64-1_slack14.2.txz \
#	linux-4.4.29/kernel-generic-4.4.29-x86_64-1_slack14.2.txz \
#	linux-4.4.29/kernel-headers-4.4.29-x86-1_slack14.2.txz \
#	linux-4.4.29/kernel-modules-4.4.29-x86_64-1_slack14.2.txz \
#	linux-4.4.29/kernel-source-4.4.29-noarch-1_slack14.2.txz \
#	php-5.6.27-x86_64-1_slack14.2.txz \
#	mozilla-firefox-45.5.1esr-x86_64-1_slack14.2.txz \
#	glibc-zoneinfo-2016i-noarch-1_slack14.2.txz \
#	openssh-7.3p1-x86_64-1_slack14.2.txz \
#	samba-4.4.5-x86_64-1_slack14.2.txz \
#	mozilla-thunderbird-45.5.1-x86_64-1_slack14.2.txz \
#	bind-9.10.4_P4-x86_64-1_slack14.2.txz \
#	gnutls-3.4.15-x86_64-1_slack14.2.txz \
#	irssi-0.8.20-x86_64-1_slack14.2.txz \
#	python-2.7.13-x86_64-1_slack14.2.txz \
#	seamonkey-2.46-x86_64-1_slack14.2.txz \
#	seamonkey-solibs-2.46-x86_64-1_slack14.2.txz \
#	mariadb-10.0.28-x86_64-1_slack14.2.txz \
#	seamonkey-2.46-x86_64-2_slack14.2.txz \
#	seamonkey-solibs-2.46-x86_64-2_slack14.2.txz \
#	mozilla-firefox-45.6.0esr-x86_64-1_slack14.2.txz \
#	mozilla-thunderbird-45.6.0-x86_64-1_slack14.2.txz \
#	bind-9.10.4_P5-x86_64-1_slack14.2.txz \
#	mozilla-thunderbird-45.7.0-x86_64-1_slack14.2.txz \
#	openssl-1.0.2j-x86_64-1_slack14.2.txz \
#	openssl-solibs-1.0.2j-x86_64-1_slack14.2.txz \
#	php-5.6.29-x86_64-1_slack14.2.txz \
#	glibc-zoneinfo-2016j-noarch-1_slack14.2.txz \
#	mozilla-thunderbird-45.7.1-x86_64-1_slack14.2.txz \
#	mozilla-firefox-45.7.0esr-x86_64-1_slack14.2.txz \
#	pidgin-2.11.0-x86_64-1_slack14.2.txz \
#	glibc-zoneinfo-2017a-noarch-1_slack14.2.txz \
#	mcabber-1.0.4-x86_64-1_slack14.2.txz \
#	samba-4.4.8-x86_64-1_slack14.2.txz \
#	mariadb-10.0.29-x86_64-1_slack14.2.txz \
#	mozilla-firefox-45.8.0esr-x86_64-1_slack14.2.txz \
#	samba-4.4.12-x86_64-1_slack14.2.txz \
#	mozilla-thunderbird-45.8.0-x86_64-1_slack14.2.txz \
#	bind-9.10.4_P6-x86_64-1_slack14.2.txz \
#	mozilla-thunderbird-52.0-x86_64-1_slack14.2.txz \
#	ntp-4.2.8p9-x86_64-1_slack14.2.txz \
#	mozilla-firefox-52.0.2esr-x86_64-1_slack14.2.txz \
#	xfce4-weather-plugin-0.8.8-x86_64-1_slack14.2.txz \
#	mozilla-thunderbird-52.0.1-x86_64-1_slack14.2.txz \
#	mozilla-thunderbird-52.1.0-x86_64-1_slack14.2.txz \
#	mozilla-firefox-52.1.0esr-x86_64-1_slack14.2.txz \
#	samba-4.4.13-x86_64-1_slack14.2.txz \
#	sudo-1.8.20p1-x86_64-1_slack14.2.txz \
#	irssi-0.8.21-x86_64-1_slack14.2.txz \
#	bind-9.10.4_P8-x86_64-1_slack14.2.txz \
#	mozilla-firefox-52.1.2esr-x86_64-1_slack14.2.txz \
#	mozilla-thunderbird-52.1.1-x86_64-1_slack14.2.txz \
#	linux-4.4.38/kernel-firmware-20161211git-noarch-1.txz \
#	linux-4.4.38/kernel-huge-4.4.38-x86_64-1.txz \
#	linux-4.4.38/kernel-generic-4.4.38-x86_64-1.txz \
#	linux-4.4.38/kernel-headers-4.4.38-x86-1.txz \
#	linux-4.4.38/kernel-modules-4.4.38-x86_64-1.txz \
#	linux-4.4.38/kernel-source-4.4.38-noarch-1.txz \
#	mozilla-thunderbird-52.2.0-x86_64-1_slack14.2.txz \
#	bind-9.10.5_P1-x86_64-1_slack14.2.txz \
#	httpd-2.4.25-x86_64-1_slack14.2.txz \
#	libgcrypt-1.7.3-x86_64-1_slack14.2.txz \
#	linux-4.4.74/kernel-firmware-20170626git-noarch-1.txz \
#	linux-4.4.74/kernel-huge-4.4.74-x86_64-1.txz \
#	linux-4.4.74/kernel-generic-4.4.74-x86_64-1.txz \
#	linux-4.4.74/kernel-headers-4.4.74-x86-1.txz \
#	linux-4.4.74/kernel-modules-4.4.74-x86_64-1.txz \
#	linux-4.4.74/kernel-source-4.4.74-noarch-1.txz \
#	glibc-2.23-x86_64-2_slack14.2.txz \
#	glibc-i18n-2.23-x86_64-2_slack14.2.txz \
#	glibc-profile-2.23-x86_64-2_slack14.2.txz \
#	glibc-solibs-2.23-x86_64-2_slack14.2.txz \
#	xscreensaver-5.36-x86_64-1_slack14.2.txz \
#	php-5.6.30-x86_64-1_slack14.2.txz \
#	irssi-1.0.3-x86_64-1_slack14.2.txz \
#	httpd-2.4.26-x86_64-1_slack14.2.txz \
#	mariadb-10.0.30-x86_64-1_slack14.2.txz \
#	samba-4.4.14-x86_64-1_slack14.2.txz \
#	expat-2.2.0-x86_64-1_slack14.2.txz \
#	libtirpc-1.0.1-x86_64-3_slack14.2.txz \
#	rpcbind-0.2.4-x86_64-1_slack14.2.txz \
#	seamonkey-2.46-x86_64-3_slack14.2.txz \
#	seamonkey-solibs-2.46-x86_64-3_slack14.2.txz \
#	tcpdump-4.9.0-x86_64-1_slack14.2.txz \
#	bind-9.10.5_P2-x86_64-1_slack14.2.txz \
#	gnupg-1.4.21-x86_64-1_slack14.2.txz \
#	curl-7.51.0-x86_64-1_slack14.2.txz \
#	glibc-2.23-x86_64-3_slack14.2.txz \
#	glibc-i18n-2.23-x86_64-3_slack14.2.txz \
#	glibc-profile-2.23-x86_64-3_slack14.2.txz \
#	glibc-solibs-2.23-x86_64-3_slack14.2.txz \
#	mozilla-firefox-52.2.0esr-x86_64-1_slack14.2.txz \
#	mozilla-thunderbird-52.2.1-x86_64-1_slack14.2.txz \
#	mariadb-10.0.31-x86_64-1_slack14.2.txz \
#	tcpdump-4.9.1-x86_64-1_slack14.2.txz \
#	linux-4.4.75/kernel-firmware-20170626git-noarch-1.txz \
#	linux-4.4.75/kernel-huge-4.4.75-x86_64-1.txz \
#	linux-4.4.75/kernel-generic-4.4.75-x86_64-1.txz \
#	linux-4.4.75/kernel-headers-4.4.75-x86-1.txz \
#	linux-4.4.75/kernel-modules-4.4.75-x86_64-1.txz \
#	linux-4.4.75/kernel-source-4.4.75-noarch-1.txz \
#	httpd-2.4.27-x86_64-1_slack14.2.txz \
#	libgcrypt-1.7.8-x86_64-1_slack14.2.txz \
#	samba-4.4.15-x86_64-1_slack14.2.txz \
#	python-2.7.13-x86_64-2_slack14.2.txz \
#	mozilla-firefox-52.3.0esr-x86_64-1_slack14.2.txz \
#	curl-7.55.0-x86_64-1_slack14.2.txz \
#	xorg-server-1.18.3-x86_64-3_slack14.2.txz \
#	xorg-server-xephyr-1.18.3-x86_64-3_slack14.2.txz \
#	xorg-server-xnest-1.18.3-x86_64-3_slack14.2.txz \
#	xorg-server-xvfb-1.18.3-x86_64-3_slack14.2.txz \
#	mozilla-thunderbird-52.3.0-x86_64-1_slack14.2.txz \
PKGS=( \
	gimp-2.8.18-x86_64-1_slack14.2.txz \
	libidn-1.33-x86_64-1_slack14.2.txz \
	stunnel-5.35-x86_64-2_slack14.2.txz \
	screen-4.4.0-x86_64-2_slack14.2.txz \
	glib2-2.46.2-x86_64-3_slack14.2.txz \
	gtk+2-2.24.31-x86_64-1_slack14.2.txz \
	sdl-1.2.15-x86_64-5_slack14.2.txz \
	libX11-1.6.4-x86_64-1_slack14.2.txz \
	libXfixes-5.0.3-x86_64-1_slack14.2.txz \
	libXi-1.7.8-x86_64-1_slack14.2.txz \
	libXrandr-1.5.1-x86_64-1_slack14.2.txz \
	libXrender-0.9.10-x86_64-1_slack14.2.txz \
	libXtst-1.2.3-x86_64-1_slack14.2.txz \
	libXv-1.0.11-x86_64-1_slack14.2.txz \
	libXvMC-1.0.10-x86_64-1_slack14.2.txz \
	intltool-0.51.0-x86_64-3_slack14.2.txz \
	loudmouth-1.5.3-x86_64-1_slack14.2.txz \
	openssh-7.4p1-x86_64-1_slack14.2.txz \
	libpng-1.6.27-x86_64-1_slack14.2.txz \
	gnutls-3.5.8-x86_64-1_slack14.2.txz \
	scim-1.4.17-x86_64-1_slack14.2.txz \
	libpcap-1.8.1-x86_64-1_slack14.2.txz \
	openssl-1.0.2k-x86_64-1_slack14.2.txz \
	openssl-solibs-1.0.2k-x86_64-1_slack14.2.txz \
	libcgroup-0.41-x86_64-2_slack14.2.txz \
	pidgin-2.12.0-x86_64-1_slack14.2.txz \
	glibc-zoneinfo-2017b-noarch-1_slack14.2.txz \
	mcabber-1.0.5-x86_64-1_slack14.2.txz \
	libtiff-4.0.7-x86_64-1_slack14.2.txz \
	minicom-2.7.1-x86_64-1_slack14.2.txz \
	getmail-4.54.0-x86_64-1_slack14.2.txz \
	ntp-4.2.8p10-x86_64-1_slack14.2.txz \
	proftpd-1.3.5e-x86_64-1_slack14.2.txz \
	xfce4-weather-plugin-0.8.9-x86_64-1_slack14.2.txz \
	rxvt-2.7.10-x86_64-5_slack14.2.txz \
	freetype-2.6.3-x86_64-2_slack14.2.txz \
	kdelibs-4.14.32-x86_64-1_slack14.2.txz \
	gkrellm-2.3.10-x86_64-1_slack14.2.txz \
	lynx-2.8.8rel.2-x86_64-3_slack14.2.txz \
	sudo-1.8.20p2-x86_64-1_slack14.2.txz \
	pkg-config-0.29.2-x86_64-1_slack14.2.txz \
	openvpn-2.3.17-x86_64-1_slack14.2.txz \
	nasm-2.13.01-x86_64-1_slack14.2.txz \
	mkinitrd-1.4.10-x86_64-1_slack14.2.txz \
	xscreensaver-5.37-x86_64-1_slack14.2.txz \
	ca-certificates-20161130-noarch-1_slack14.2.txz \
	php-5.6.31-x86_64-1_slack14.2.txz \
	irssi-1.0.4-x86_64-1_slack14.2.txz \
	expat-2.2.2-x86_64-1_slack14.2.txz \
	gd-2.2.4-x86_64-1_slack14.2.txz \
	libtirpc-1.0.2-x86_64-1_slack14.2.txz \
	rpcbind-0.2.4-x86_64-2_slack14.2.txz \
	seamonkey-2.48-x86_64-1_slack14.2.txz \
	seamonkey-solibs-2.48-x86_64-1_slack14.2.txz \
	bind-9.10.5_P3-x86_64-1_slack14.2.txz \
	dbus-1.10.8-x86_64-2_slack14.2.txz \
	squashfs-tools-4.3-x86_64-2_slack14.2.txz \
	gnupg-1.4.22-x86_64-1_slack14.2.txz \
	glibc-2.23-x86_64-4_slack14.2.txz \
	glibc-i18n-2.23-x86_64-4_slack14.2.txz \
	glibc-profile-2.23-x86_64-4_slack14.2.txz \
	glibc-solibs-2.23-x86_64-4_slack14.2.txz \
	git-2.14.1-x86_64-1_slack14.2.txz \
	libsoup-2.52.2-x86_64-3_slack14.2.txz \
	mercurial-4.3.1-x86_64-1_slack14.2.txz \
	subversion-1.9.7-x86_64-1_slack14.2.txz \
	bash-4.3.048-x86_64-1_slack14.2.txz \
	mariadb-10.0.32-x86_64-1_slack14.2.txz \
	mozilla-nss-3.31.1-x86_64-1_slack14.2.txz \
	tcpdump-4.9.2-x86_64-1_slack14.2.txz \
	emacs-25.3-x86_64-1_slack14.2.txz \
	libzip-1.0.1-x86_64-3_slack14.2.txz \
	bluez-5.47-x86_64-1_slack14.2.txz \
	linux-4.4.88/kernel-firmware-20170914git-noarch-1.txz \
	linux-4.4.88/kernel-huge-4.4.88-x86_64-1.txz \
	linux-4.4.88/kernel-generic-4.4.88-x86_64-1.txz \
	linux-4.4.88/kernel-headers-4.4.88-x86-1.txz \
	linux-4.4.88/kernel-modules-4.4.88-x86_64-1.txz \
	linux-4.4.88/kernel-source-4.4.88-noarch-1.txz \
	httpd-2.4.27-x86_64-2_slack14.2.txz \
	libgcrypt-1.7.9-x86_64-1_slack14.2.txz \
	ruby-2.2.8-x86_64-1_slack14.2.txz \
	samba-4.4.16-x86_64-1_slack14.2.txz \
	libxml2-2.9.5-x86_64-1_slack14.2.txz \
	python-2.7.14-x86_64-1_slack14.2.txz \
	gegl-0.2.0-x86_64-4_slack14.2.txz \
	mozilla-firefox-52.4.0esr-x86_64-1_slack14.2.txz \
	openexr-2.2.0-x86_64-2_slack14.2.txz \
	dnsmasq-2.78-x86_64-1_slack14.2.txz \
	curl-7.56.0-x86_64-1_slack14.2.txz \
	openjpeg-2.3.0-x86_64-1_slack14.2.txz \
	xorg-server-1.18.3-x86_64-4_slack14.2.txz \
	xorg-server-xephyr-1.18.3-x86_64-4_slack14.2.txz \
	xorg-server-xnest-1.18.3-x86_64-4_slack14.2.txz \
	xorg-server-xvfb-1.18.3-x86_64-4_slack14.2.txz \
	mozilla-thunderbird-52.4.0-x86_64-1_slack14.2.txz)

mount -t overlay overlay \
	-olowerdir=$RELEASE_ROOT,upperdir=$PATCHED_ROOT,workdir=$WORKDIR \
	$CHROOT
mount -t proc proc "$CHROOT"/proc || exit 1
mount -B "$PKG_SRC" "$CHROOT"/mnt || exit 1

installpkg_chroot() {
	chroot "$CHROOT" upgradepkg "$1"
}

for pkg in "${PKGS[@]}" ; do
	installpkg_chroot "/mnt/$pkg"
done

#chroot "$CHROOT" upgradepkg --reinstall /mnt/glibc-2.23-x86_64-4_slack14.2.txz

echo "***************************"
echo "* Fix *.new files in /etc *"
echo "***************************"
chroot "$CHROOT" /bin/bash -l
rm -rf "$PATCHED_ROOT"/root

umount "$CHROOT"/mnt
umount "$CHROOT"/proc
umount "$CHROOT"
Step 5: Run install-build-environment.sh to install sbopkg into your chroot:
Code:
#!/bin/bash
# install-build-environment.sh
#
# Copyright 2016 Erich Ritz
#
# This script installs sbopkg in the chroot Slackware64 14.2

IFS="$(printf '\n\t')"

PKG_SRC=/home/erich/pkgs
RELEASE_ROOT=/root/build/14.2-release
PATCHED_ROOT=/root/build/14.2-patched
BUILD_ROOT=/root/build/14.2-build
WORKDIR=/root/build/workdir
CHROOT=/root/build/chroot

if [ ! -d "$BUILD_ROOT" ]; then
	mkdir -p "$BUILD_ROOT"
fi
if [ ! -d "$WORKDIR" ]; then
	mkdir -p "$WORKDIR"
fi
if [ ! -d "$CHROOT" ]; then
	mkdir -p "$CHROOT"
fi

mount -t overlay overlay \
	-olowerdir=$PATCHED_ROOT:$RELEASE_ROOT,upperdir=$BUILD_ROOT,workdir=$WORKDIR \
	$CHROOT
mount -t proc proc "$CHROOT"/proc || exit 1
mount -B "$PKG_SRC" "$CHROOT"/mnt || exit 1

installpkg_chroot() {
	chroot "$CHROOT" installpkg "$1"
}

installpkg_chroot /mnt/sbopkg/sbopkg-0.38.1-noarch-1_wsr.tgz

# Copy configuration file
cp /etc/sbopkg/sbopkg.conf $CHROOT/etc/sbopkg/sbopkg.conf
# Create directories for sbo
mkdir -p $CHROOT/var/lib/sbopkg
mkdir -p $CHROOT/var/cache/sbopkg
mkdir -p $CHROOT/var/log/sbopkg
mkdir -p $CHROOT/tmp/SBo

umount "$CHROOT"/mnt
umount "$CHROOT"/proc
umount "$CHROOT"
Every time new Slackware patches are released, edit install-patched.sh and rerun. There is no need to rerun install-build-environment.sh due to the way overlayfs works.

Now, any time you want to use the chroot, run use-build-environment.sh:
Code:
#!/bin/bash
# use-build-environment.sh
#
# Copyright 2016 Erich Ritz
#
# This script uses the chroot Slackware environment

IFS="$(printf '\n\t')"

PKG_SRC=/home/erich/pkgs
RELEASE_ROOT=/root/build/14.2-release
PATCHED_ROOT=/root/build/14.2-patched
BUILD_ROOT=/root/build/14.2-build
UPPERDIR=/root/build/changes
WORKDIR=/root/build/workdir
CHROOT=/root/build/chroot

# First delete UPPERDIR to remove any previous changes
if [ -d "$UPPERDIR" ] ; then
	rm -rf -- "$UPPERDIR"
fi

mkdir -p "$UPPERDIR"
if [ ! -d "$WORKDIR" ]; then
	mkdir -p "$WORKDIR"
fi
if [ ! -d "$CHROOT" ]; then
	mkdir -p "$CHROOT"
fi

mount -t overlay overlay \
	-olowerdir=$BUILD_ROOT:$PATCHED_ROOT:$RELEASE_ROOT,upperdir=$UPPERDIR,workdir=$WORKDIR \
	$CHROOT

cp -a /root/.gnupg "$CHROOT"/root

mount -B "$PKG_SRC" "$CHROOT"/mnt
# Bind sbo directories from /
mount -B /var/lib/sbopkg "$CHROOT"/var/lib/sbopkg
mount -B /var/cache/sbopkg "$CHROOT"/var/cache/sbopkg
mount -B /var/log/sbopkg "$CHROOT"/var/log/sbopkg
mount -B /tmp/SBo "$CHROOT"/tmp/SBo
# Also bind pkgs directory
mkdir -p "$CHROOT"/home/erich/pkgs
mount -B /home/erich/pkgs "$CHROOT"/home/erich/pkgs

./chroot.sh "$CHROOT"

umount "$CHROOT"/home/erich/pkgs
umount "$CHROOT"/tmp/SBo
umount "$CHROOT"/var/log/sbopkg
umount "$CHROOT"/var/cache/sbopkg
umount "$CHROOT"/var/lib/sbopkg
umount "$CHROOT"/mnt
umount $CHROOT
And finally, a dependent script used by the above scripts:
Code:
#!/bin/bash
# chroot.sh

# Exit if location not specified
if [ -z "$1" ]; then
	echo "chroot folder not specified"
	exit 1
elif [ "$1" = -h ]; then
	echo "./chroot.sh <chroot-folder>"
	exit 1
fi

location="$1"
cd "$location" || exit 1

# Mounting, basic
mount -t proc proc "$1"/proc || exit 1
mount -o bind /sys "$1"/sys || exit 1
mount -o bind /dev "$1"/dev || exit 1

# Mounting extra partition which is already mounted on host
# first one is host mount path, second is chroot mount
#mount -B /mnt/datalinux2 "$1"/mnt/data

# For internet access
cp /etc/resolv.conf "$1"/etc/resolv.conf

# Prevent D-Bus errors
cp /var/lib/dbus/machine-id "$1"/var/lib/dbus/machine-id

# Finally, chroot
chroot "$location" /bin/bash -l

# Unmounting after exit from chroot
#umount "$1"/mnt/data
umount "$1"/{proc,sys,dev}/ || exit 1

echo "Done"
Note there are a few differences between my scripts and orbea's solution. His bind mounts /etc/resolv.conf, while my solution copies, for example.

Earlier today I upgraded nodejs from SBo. My session looked something like this:
Code:
# cd ~/build
# # Edit install-patched.sh due to Slackware patches released recently.
# ./install-patched.sh
# ./use-build-environment.sh
(chroot) # sbopkg -k -b nodejs
(chroot) # exit
# upgradepkg /tmp/SBo/pkgs/nodejs-6.11.4-x86_64-1_SBo.tgz
You can of course modify use-build-environment.sh to edit which system directories are available in the chroot. For example, currently I have /tmp/SBo and /home/erich/pkgs as shared directories to the chroot.
 
1 members found this post helpful.
Old 10-10-2017, 08:45 AM   #8
zerouno
Member
 
Registered: Oct 2009
Location: Italy
Distribution: Slackware
Posts: 498

Rep: Reputation: 127Reputation: 127
Consider to use lxc that provide a running chroot enviroment with ip, services and all other, similar to a virtual machine, using paravirtualization.


Also you can do a REAL BOOT of a system installed on chroot, so you can test natively X applications, kernel modules, services and other.

enter in chroot enviroment

Code:
mount -o bind /proc /CHROOT/proc
mount -o bind /dev /CHROOT/dev
mount -o bind /sys /CHROOT/sys
chroot /CHROOT
create an initrd
Code:
mkinitrd -c -f ext4 -r /dev/sda1
if you need kernel modules add
-k <kernel_version> -m <modules_list>
where kernel_version is the kernel installed in chroot enviroment
then
Code:
cd /boot/initrd-tree
mkdir mnt2
edit 'init' file and replace
Code:
  mount -o ro${ROOTFLAGS:+,$ROOTFLAGS} -t $ROOTFS $ROOTDEV /mnt
with
Code:
  mount -o ro${ROOTFLAGS:+,$ROOTFLAGS} -t $ROOTFS $ROOTDEV /mnt2
  mount -o bind /mnt2/CHROOTPATH /mnt
launch
Code:
mkinitrd
without parameters

be sure that fstab is configured as the main slackware system
optionally you can add

Code:
/dev/sda1        /ORIGINAL            ext4        defaults         0   0
(remember mkdir /ORIGINAL)

to access to the main slackware from chroot

exit from chroot

edit /etc/lilo.conf and add
Code:
image = /CHROOT/boot/vmlinuz
root = /dev/sda1
label = CHROOT
initrd = /CHROOT/boot/initrd.gz
read-only
and run lilo -v

now reboot.
 
1 members found this post helpful.
Old 10-10-2017, 10:03 PM   #9
dchmelik
Member
 
Registered: Nov 2008
Location: Washington state, USA
Distribution: NetBSD, FreeBSD, OpenBSD, OpenSolaris, Slackware, Salix, FreeSlack, Android
Posts: 263

Original Poster
Rep: Reputation: 24
Drumz, orbea, zerouno, thanks! Though I didn't ask for debate, I might try overlayfs, though am not going to try an entire other install (same drive or different PC, worst option yet,) nor Docker (bad experience with that so far, though it might be easier for something else.)

However, I noticed Slackware 14.2 also mounts some stuff it runs from /etc/rc.d/rc.cg* files. There should be instructions how to mount those, though stuff I build doesn't use them (I should start another thread, 'what's cg* really for,' because when I type 'mount' it's getting cluttered.)
 
1 members found this post helpful.
Old 10-11-2017, 12:36 AM   #10
mid-kid
LQ Newbie
 
Registered: Oct 2016
Posts: 22

Rep: Reputation: Disabled
Quote:
Originally Posted by dchmelik View Post
Drumz, orbea, zerouno, thanks! Though I didn't ask for debate, I might try overlayfs, though am not going to try an entire other install (same drive or different PC, worst option yet,) nor Docker (bad experience with that so far, though it might be easier for something else.)
I don't really like Docker either, but it's the only thing I have found thus far that implements this "Just spin up a new one to get a clean slate" paradigm and filesystem layer-based approach in a generic way that isn't a huge hassle to manage. I might someday™ implement it myself properly, but for now it's good enough for what I need.
I failed to mention slackrepo, which also uses overlayfs to manage multiple layers on top of a "clean" chroot, and is more tailored towards SlackBuild building than any other approach. You might want to look into that if you need ideas.
I hope you find the approach that's most useful to you, and can continue creating packages.

Quote:
Originally Posted by dchmelik View Post
However, I noticed Slackware 14.2 also mounts some stuff it runs from /etc/rc.d/rc.cg* files. There should be instructions how to mount those, though stuff I build doesn't use them (I should start another thread, 'what's cg* really for,' because when I type 'mount' it's getting cluttered.)
For what I'm aware, cg stands for cgroups, or control groups. It's a method to allocate per-process resources, such as CPUs, memory, etc. Often used by container software (docker, lxc) or systemd, but you could use it yourself to restrict some programs, if you figure out how.
On my machine, the cgroups filesystems are mounted on boot, even if the rc.cg* are disabled, by rc.S. You can see how to mount them there, but I wouldn't bother mounting them inside a chroot, as they're usually unecessary, and I'm unsure what kind of side-effects it could have.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Slackware in an android chroot? michaelslack Slackware 0 02-25-2014 09:44 AM
slackware 10.2 chroot/jail ssh zdannar Slackware 3 07-12-2007 05:51 PM
segmentation fault with chroot in Slackware 11 vilnisr Slackware 1 10-30-2006 06:16 PM
Chroot bind 9.3.0 in slackware 10 - noobie houler Linux - Security 8 04-01-2005 05:53 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 01:11 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration