LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware - ARM (http://www.linuxquestions.org/questions/slackware-arm-108/)
-   -   odd thing happening when I install packages in a chroot (http://www.linuxquestions.org/questions/slackware-arm-108/odd-thing-happening-when-i-install-packages-in-a-chroot-4175489557/)

louigi600 12-30-2013 06:13 AM

odd thing happening when I install packages in a chroot
 
On one of my GoFlexNet I've a folder, on the sata software raid mirror, where I keep a slackware arm 14.1 developement environment for compiling things.

In order to use it I just usually descent into the tree and type "chroot ."
I've noticed that when I use slackpkg from there to install packages the links are not created but the rest is in place. I work around that by extracting the doinst script and run it manually.
As to my understanding slackpkg uses installpkg internally to do the package installation, I've not yet checked out if installpkg does the same but none the less this thing seems odd.
Anyone else had the same thing ?

drmozes 12-30-2013 11:18 AM

Quote:

Originally Posted by louigi600 (Post 5088936)
On one of my GoFlexNet I've a folder, on the sata software raid mirror, where I keep a slackware arm 14.1 developement environment for compiling things.

In order to use it I just usually descent into the tree and type "chroot ."
I've noticed that when I use slackpkg from there to install packages the links are not created but the rest is in place. I work around that by extracting the doinst script and run it manually.
As to my understanding slackpkg uses installpkg internally to do the package installation, I've not yet checked out if installpkg does the same but none the less this thing seems odd.
Anyone else had the same thing ?

There have been a couple of issues with slackpkg. I don't use slackpkg myself and don't have time to try and reproduce it.
The only thing that's different about pkgtools on ARM is that they have been patched to improve the performance on ARM:
http://ftp.arm.slackware.com/slackwa...g.speedup.diff
The other scripts are similarly patched - check the piece of sed at the bottom as this might be the culprit. I don't know if some how slackpkg is interfering with this (I can't think of a reason why it should, but I don't know how slackpkg works). The patches themselves have been around since 2006 and haven't caused any issues, but I can't think of anything else that'd be causing slackpkg to fail on occasions.

ponce 12-30-2013 12:46 PM

I don't think it's related (as you're talking about a chroot, so the new / of the filesystem should be the one you chrooted to and the pkgtools utilities/slackpkg should work fine), but in some spots slackpkg doesn't honor the $ROOT environment variable (unlike the pkgtools utilities), so I prepared a patch some time ago that I sent to Pat but it never got included (maybe because he was waiting for Piter to review it).

I'll attach it here, if you want to try it (I'm using it to create LXC containers with slackpkg's templates)
Code:

diff -Naur slackpkg-2.82.0.orig/usr/libexec/slackpkg/core-functions.sh slackpkg-2.82.0/usr/libexec/slackpkg/core-functions.sh
--- slackpkg-2.82.0.orig/usr/libexec/slackpkg/core-functions.sh        2013-09-17 22:36:36.000000000 +0200
+++ slackpkg-2.82.0/usr/libexec/slackpkg/core-functions.sh        2013-12-30 18:40:34.046098251 +0100
@@ -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
 
@@ -768,7 +768,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
@@ -1135,14 +1135,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,12 +1159,12 @@
 
        if [ "$DOUBLEFILES" != "" ]; then
                echo -e "\
-You have a broken /var/log/packages - with two versions of the same package.\n\
+You have a broken $ROOT/var/log/packages - with two versions of the same package.\n\
 The list of packages duplicated in your machine are shown below, but don't\n\
 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\
@@ -1179,7 +1179,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
@@ -1299,7 +1299,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-2.82.0.orig/usr/libexec/slackpkg/functions.d/dialog-functions.sh slackpkg-2.82.0/usr/libexec/slackpkg/functions.d/dialog-functions.sh
--- slackpkg-2.82.0.orig/usr/libexec/slackpkg/functions.d/dialog-functions.sh        2010-05-02 01:10:33.000000000 +0200
+++ slackpkg-2.82.0/usr/libexec/slackpkg/functions.d/dialog-functions.sh        2013-12-30 18:40:34.047098251 +0100
@@ -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)


drmozes 12-30-2013 03:46 PM

Quote:

Originally Posted by ponce (Post 5089123)
I don't think it's related (as you're talking about a chroot, so the new / of the filesystem should be the one you chrooted to and the pkgtools utilities/slackpkg should work fine)

But since he's already chrooted, the $ROOT setting is not relevant and would not be used or required.

louigi600 12-31-2013 03:13 AM

I've an idea: I'll run slackpkg after having put a -x flag in the interpreter line ... this might give me a suggestion as to why something odd is going on at the time doinst scrip is executed.

louigi600 01-01-2014 03:58 AM

I did that but could not spot anything that would explain the broken links.
I did notice though that installpkg looks at /proc/self :
Code:

root@nas:/tmp# installpkg  slackkit-1.02-arm-1.txz
Verifying package slackkit-1.02-arm-1.txz.
Installing package slackkit-1.02-arm-1.txz:
PACKAGE DESCRIPTION:
# slackkit (Slackware ARM development kit)
#
# slackkit contains the required toolkit to build packages for
# Slackware ARM.
#
# The tookit was developed by Stuart Winter.
#
Executing install script for slackkit-1.02-arm-1.txz.
sh: /proc/self/fd/0: No such file or directory
Package slackkit-1.02-arm-1.txz installed.

root@nas:/tmp#

and in my case in the chroot it's not mounted as I just do "chroor ." and nothing else.
I think this has a bad influence in this part of the installpkg script (which in turn is used by slackpkg):
Code:

  if [ -f $ROOT/install/doinst.sh ]; then
    if [ "$MODE" = "install" ]; then
      echo "Executing install script for $(basename $package)."
    fi
    #    ( cd $ROOT/ ; sh install/doinst.sh -install; )
    # This tonne of sed is to avoid spawning subshells which is slow on ARM:
    # the /proc/self stuff is because I couldn't work out how to specify '-insta
ll' as an argument
    # when piping code into the shell.
    ( cd $ROOT/ ; sed -e's?^( cd \([^;]*\);\(.*\) )$?pushd \1 \&\> /dev/null ; \
2 ; popd \&\> /dev/null?g ' install/doinst.sh | sh /proc/self/fd/0 -install ; )
  fi


ponce 01-01-2014 04:05 AM

to see if it's that, you can mount proc in the chroot too
Code:

mount -t proc proc /your/chroot/proc
in the chroots I use, I bind mount also /dev and /sys
Code:

mount -o bind /dev /your/chroot/dev
mount -o bind /sys /your/chroot/sys


louigi600 01-01-2014 12:26 PM

I'm pretty much certain it's that without trying ... but just to make sure I'll try binding all 3
Code:

root@nas:/mnt/exports/developement/slackware_arm_14.1_dev# mount -o bind /dev ./dev
root@nas:/mnt/exports/developement/slackware_arm_14.1_dev# mount -o bind /sys ./sys
root@nas:/mnt/exports/developement/slackware_arm_14.1_dev# mount -o bind /proc ./proc
root@nas:/mnt/exports/developement/slackware_arm_14.1_dev# chroot .
root@nas:/# cd /tmp
root@nas:/tmp# installpkg  slackkit-1.02-arm-1.txz
Verifying package slackkit-1.02-arm-1.txz.
Installing package slackkit-1.02-arm-1.txz:
PACKAGE DESCRIPTION:
# slackkit (Slackware ARM development kit)
#
# slackkit contains the required toolkit to build packages for
# Slackware ARM.
#
# The tookit was developed by Stuart Winter.
#
Executing install script for slackkit-1.02-arm-1.txz.
Package slackkit-1.02-arm-1.txz installed.

root@nas:/tmp#

That looks like it's no longer complaining about /proc/self
I reinstald libmpc via slackpkg and the links seem to be right this time.


Not sure if I should have them in fstab or make a script to do it each time I want to use the chroot environment.


All times are GMT -5. The time now is 04:19 PM.