LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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-22-2012, 05:59 AM   #1
basil_brush
LQ Newbie
 
Registered: Oct 2012
Posts: 25

Rep: Reputation: Disabled
Pkgtool and chroot directory.


Can you use pkgtool to install packages from the installation disc to a chroot directory? Or do you have to manually use installpkg -root /chroot package.t?z.
 
Old 10-22-2012, 06:14 AM   #2
ponce
LQ Guru
 
Registered: Aug 2004
Location: Pisa, Italy
Distribution: Slackware
Posts: 7,097

Rep: Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174
from "man pkgtool"
Quote:
--target_dir directory
The directory where the target root directory is located. This is '/' when installing on the hard drive, or typically '/mnt' when installing from an install disk.
 
Old 10-22-2012, 07:32 AM   #3
basil_brush
LQ Newbie
 
Registered: Oct 2012
Posts: 25

Original Poster
Rep: Reputation: Disabled
I've tried that ponce, but using this command...

pkgtool --source_dir /cdrom/slackware/a/ --target_dir /mnt/chroot


chmod: cannot access '/mnt/chroot//var': No such file or directory
chmod: cannot access '/mnt/chroot//usr': No such file or directory
chmod: cannot access '/mnt/chroot//tmp': No such file or directory

I created those directories manually, when I issued the command again nothing happened?
I was thinking this would bring up Dialog to let me choose which packages I wanted to install in the chroot directory. Or am I doing something wrong?
 
Old 10-22-2012, 08:37 AM   #4
damgar
Senior Member
 
Registered: Sep 2009
Location: dallas, tx
Distribution: Slackware - current multilib/gsb Arch
Posts: 1,949
Blog Entries: 8

Rep: Reputation: 203Reputation: 203Reputation: 203
I believe it would just be /mnt since that is the mountpoint of / when using the install disk. In other words no /chroot. I honestly can't say for sure since I usually only have a few packages to install from /extra after a full install or I just use slackpkg with a local mirror for updates. From a working system to install a whole series I just mount the slackware disk and cd to the slackware directory and use something like
Code:
upgradepkg -install-new -reinstall x/*.t?Z

Last edited by damgar; 10-22-2012 at 08:39 AM.
 
Old 10-22-2012, 09:55 AM   #5
basil_brush
LQ Newbie
 
Registered: Oct 2012
Posts: 25

Original Poster
Rep: Reputation: Disabled
@damgar, my idea was to use pkgtool dialog for selecting which packages to install in /chroot without using upgradepkg or installpkg commands. Basically like the dialog when you're selecting which packages you want on a fresh install.
 
Old 10-22-2012, 12:08 PM   #6
xflow7
Member
 
Registered: May 2004
Distribution: Slackware
Posts: 215

Rep: Reputation: 45
Disclaimer: I don't really know what I'm talking about.

Just a thought....

Is your intention to do this to a mounted partition with nothing on it yet? If so, I wonder if perhaps before you use pkgtool you need to use installpkg to install aaa_base. I believe aaa_base is what sets up the root directory tree, so it kind of stands to reason that if that is not installed, other things may have a hard time doing what they are supposed to.

Dave
 
Old 10-22-2012, 12:35 PM   #7
ponce
LQ Guru
 
Registered: Aug 2004
Location: Pisa, Italy
Distribution: Slackware
Posts: 7,097

Rep: Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174
you can try changing two lines of /sbin/pkgtool, like below
Code:
--- pkgtool.orig	2012-08-09 20:38:10.000000000 +0200
+++ pkgtool	2012-10-22 15:47:03.360638344 +0200
@@ -94,8 +94,8 @@
   exit
  fi
 else
- TARGET_DIR=/
- TMP=/var/log/setup/tmp
+ TARGET_DIR=${ROOT:-/}
+ TMP=$ROOT/var/log/setup/tmp
 fi
 if [ ! -d $TMP ]; then
  mkdir -p $TMP
this way it should honor the $ROOT environment variable (like installpkg already does) and you can use it to install in the chroot, exporting first ROOT=/chroot (no need for --target_dir, that seems used only in the O.S. install phase).

Last edited by ponce; 10-22-2012 at 12:37 PM.
 
1 members found this post helpful.
Old 10-22-2012, 12:53 PM   #8
basil_brush
LQ Newbie
 
Registered: Oct 2012
Posts: 25

Original Poster
Rep: Reputation: Disabled
Thanks ponce, that is exactly what I was looking for. Previously I was using installpkg for individual packages, when I only wanted to miss a couple of packages out.
 
Old 10-22-2012, 01:20 PM   #9
ponce
LQ Guru
 
Registered: Aug 2004
Location: Pisa, Italy
Distribution: Slackware
Posts: 7,097

Rep: Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174
Maybe slackpkg is a better choice for this kind of tasks, it even supports templates: that's what I use to create my lxc containers.
I had to modify it just a little too to let it honor the $ROOT environment variable and to have the possibility of specifying an alternate configuration folder (in alternative to /etc/slackpkg) with a $CONF variable, to not being tied to the contents of that folder and choose to install, for example, 32bit packages in the container from a slackware64 host, use a custom blacklist and so on.
If you want to try it, it's here

http://ponce.cc/slackware/utilities/...0-noarch-9.tgz

these are the modified bits
Code:
diff -Naur slackpkg/usr/libexec/slackpkg/core-functions.sh slackpkg.new/usr/libexec/slackpkg/core-functions.sh
--- slackpkg/usr/libexec/slackpkg/core-functions.sh	2011-04-05 07:54:23.000000000 +0200
+++ slackpkg.new/usr/libexec/slackpkg/core-functions.sh	2012-10-21 09:09:45.000000000 +0200
@@ -549,9 +549,9 @@
 
 	grep -vE "(^#|^[[:blank:]]*$)" ${CONF}/blacklist > ${TMPDIR}/blacklist
 	if echo $CMD | grep -q install ; then
-		ls -1 /var/log/packages/* | awk -f /usr/libexec/slackpkg/pkglist.awk > ${TMPDIR}/tmplist
+		ls -1 $ROOT/var/log/packages/* | awk -f /usr/libexec/slackpkg/pkglist.awk > ${TMPDIR}/tmplist
 	else
-		ls -1 /var/log/packages/* | awk -f /usr/libexec/slackpkg/pkglist.awk | applyblacklist > ${TMPDIR}/tmplist
+		ls -1 $ROOT/var/log/packages/* | awk -f /usr/libexec/slackpkg/pkglist.awk | applyblacklist > ${TMPDIR}/tmplist
 	fi
 	cat ${WORKDIR}/pkglist | applyblacklist > ${TMPDIR}/pkglist
 
@@ -763,7 +763,7 @@
 	    # First is the package already installed?
 	    # Amazing what a little sleep will do
 	    # exclusion is so much nicer :)
-	    INSTPKG=$(ls -1 /var/log/packages | \
+	    INSTPKG=$(ls -1 $ROOT/var/log/packages | \
 		grep -e "^${BASENAME}-[^-]\+-\(${ARCH}\|fw\|noarch\)-[^-]\+")
 
 		# INSTPKG is local version
@@ -1130,14 +1130,14 @@
 
 	[ "$SPINNING" = "off" ] || spinning ${TMPDIR}/waiting &
 
-	for i in $(ls -1 /var/log/packages | \
+	for i in $(ls -1 $ROOT/var/log/packages | \
 		egrep -- "^.*-(${ARCH}|fw|noarch)-[^-]+-upgraded"); do
 		REVNAME=$(echo ${i} | awk -F'-upgraded' '{ print $1 }')
-		mv /var/log/packages/${i} /var/log/packages/${REVNAME}
-		mv /var/log/scripts/${i} /var/log/scripts/${REVNAME}
+		mv $ROOT/var/log/packages/${i} $ROOT/var/log/packages/${REVNAME}
+		mv $ROOT/var/log/scripts/${i} $ROOT/var/log/scripts/${REVNAME}
 	done
 	
-	ls -1 /var/log/packages | egrep "^.*-(${ARCH}|fw|noarch)-[^-]+$" | \
+	ls -1 $ROOT/var/log/packages | egrep "^.*-(${ARCH}|fw|noarch)-[^-]+$" | \
 				  batchcutpkg | sort > $TMPDIR/list1 
 	cat $TMPDIR/list1 | uniq > $TMPDIR/list2
 	FILES="$(diff $TMPDIR/list1 $TMPDIR/list2 | grep '<' | cut -f2 -d\ )"
@@ -1159,7 +1159,7 @@
 worry about this list - when you select your action, slackpkg will show a\n\
 better list:\n"
 		for i in $DOUBLEFILES ; do
-			ls -1 /var/log/packages |\
+			ls -1 $ROOT/var/log/packages |\
 				egrep -i -- "^${i}-[^-]+-(${ARCH}|fw|noarch)-"
 		done
 		echo -ne "\n\
@@ -1174,7 +1174,7 @@
 			;;
 			R|r)
 				for i in $DOUBLEFILES ; do
-					FILE=$(ls -1 /var/log/packages |\
+					FILE=$(ls -1 $ROOT/var/log/packages |\
 						egrep -i -- "^${i}-[^-]+-(${ARCH}|fw|noarch)-")
 					FILES="$FILES $FILE"
 				done
@@ -1294,7 +1294,7 @@
 	touch $TMPDIR/waiting
 	echo -e "\tGenerating slackware installed package list (this may take a while) \c"
 	[ "$SPINNING" = "off" ] || spinning ${TMPDIR}/waiting &
-	for i in /var/log/packages/* ; do 
+	for i in $ROOT/var/log/packages/* ; do 
 		PKGNAME=$( cutpkg $(basename $i))
 		grep -q " $PKGNAME " ${WORKDIR}/pkglist && \
 			echo $PKGNAME >> $TMPDIR/$TEMPLATE.work
diff -Naur slackpkg/usr/libexec/slackpkg/functions.d/dialog-functions.sh slackpkg.new/usr/libexec/slackpkg/functions.d/dialog-functions.sh
--- slackpkg/usr/libexec/slackpkg/functions.d/dialog-functions.sh	2010-05-02 01:10:33.000000000 +0200
+++ slackpkg.new/usr/libexec/slackpkg/functions.d/dialog-functions.sh	2012-10-21 09:11:36.000000000 +0200
@@ -20,7 +20,7 @@
 		rm -f $TMPDIR/dialog.tmp
 		
 		if [ "$2" = "upgrade" ]; then
-			ls -1 /var/log/packages > $TMPDIR/tmplist
+			ls -1 $ROOT/var/log/packages > $TMPDIR/tmplist
 			for i in $1; do
 				BASENAME=$(cutpkg $i)
 				PKGFOUND=$(grep -m1 -e "^${BASENAME}-[^-]\+-\(noarch\|fw\|${ARCH}\)" $TMPDIR/tmplist)
diff -Naur slackpkg/usr/sbin/slackpkg slackpkg.new/usr/sbin/slackpkg
--- slackpkg/usr/sbin/slackpkg	2011-03-25 03:42:10.000000000 +0100
+++ slackpkg.new/usr/sbin/slackpkg	2012-10-21 09:05:56.000000000 +0200
@@ -35,7 +35,7 @@
 VERSION=2.81.1
 PATH=/bin:/usr/bin:/sbin:/usr/sbin
 SLACKWARE_VERSION=$(cat /etc/slackware-version | cut -f2 -d\ )
-CONF=/etc/slackpkg
+CONF=${CONF:-/etc/slackpkg}
 SOURCE=$(sed -e 's/^[[:blank:]]*//' $CONF/mirrors | grep -m1 -e "^\([a-z]\)")
 . $CONF/slackpkg.conf
 ERROR=""
I'm going to send this to Pat too soon, hoping that he likes the thing
 
2 members found this post helpful.
Old 10-22-2012, 01:27 PM   #10
basil_brush
LQ Newbie
 
Registered: Oct 2012
Posts: 25

Original Poster
Rep: Reputation: Disabled
I was looking at your lxc-container blog before your pkgtool reply. I'll try that too, see which is best for me. I've used lxc-containers in the past and your blog was very helpful.

Thanks once again

Last edited by basil_brush; 10-22-2012 at 01:40 PM.
 
  


Reply



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
[SOLVED] The slackware package description in the install directory it isnt read by pkgtool Gerwar Linux - Software 2 05-29-2011 12:16 PM
chroot:cannot change root directory to: No such file directory janakiramulu Linux From Scratch 5 04-23-2011 01:00 AM
[SOLVED] Vsftpd chroot directory? snq Linux - Networking 3 12-17-2010 03:39 AM
[SOLVED] pkgtool directory & xfce in slackware Asinine Linux - Newbie 2 09-02-2009 11:56 PM
vsftpd chroot, want to allow a directory from elsewhere 60s TV Batman Linux - Security 5 06-16-2007 08:59 AM

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

All times are GMT -5. The time now is 09:03 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
Open Source Consulting | Domain Registration