Patch for polystrap

Gilles Filippini <[email protected]>
Newsgroups gmane.linux.debian.devel.embedded
Message-ID <[email protected]>
Hi,

I've recently discovered the polystrap tool and I find it very useful.

I've just had to patch it a bit (attached) to fix absolute path handling
for symlinks inside the chroot.

Thanks,

_g.
0001-Fix-chroot-internal-symlinks-path.patch (text/x-diff, 1.6 KB)
From 2e74755698f4fbe60c5780f9c28c4188cb7be4fd Mon Sep 17 00:00:00 2001
From: Gilles Filippini <[email protected]>
Date: Mon, 8 Oct 2012 10:07:32 +0200
Subject: [PATCH] Fix chroot internal symlinks path

This patch makes sure ${ROOTDIR} is always an absolute path. This
is requested for the absolute symlink conversion step to work
properly.
---
 polystrap.sh |   11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/polystrap.sh b/polystrap.sh
index fe0a65a..2f1f091 100755
--- a/polystrap.sh
+++ b/polystrap.sh
@@ -73,7 +73,7 @@ BOARD="$1"
 # overwrite target options by commandline options
 SUITE=${_SUITE:-$SUITE}
 ARCH=${_ARCH:-$ARCH}
-ROOTDIR=${_ROOTDIR:-$ROOTDIR}
+ROOTDIR=$(readlink -m ${_ROOTDIR:-$ROOTDIR})
 MIRROR=${_MIRROR:-$MIRROR}
 
 if [ "$_PACKAGES" = "" ] && [ -r "$BOARD/packages" ]; then
@@ -130,7 +130,7 @@ for link in `find $ROOTDIR -type l`; do
         if [ "${target%%/*}" = "" ]; then # target begins with slash
 		echo "I: convert symlink: ${link#$ROOTDIR} -> $target"
 		rm $link
-                ln -s $ROOTDIR/$target $link
+                ln -s ${ROOTDIR}$target $link
         fi
 done
 
@@ -175,6 +175,7 @@ rm $ROOTDIR/usr/sbin/policy-rc.d
 
 # need to generate tar inside fakechroot so that absolute symlinks are correct
 # tar is clever enough to not try and put the archive inside itself
-echo "I: create tarball $ROOTDIR.tar"
-fakechroot chroot $ROOTDIR tar -cf $ROOTDIR.tar -C / .
-mv $ROOTDIR/$ROOTDIR.tar .
+TARBALL=$(basename $ROOTDIR).tar
+echo "I: create tarball $TARBALL"
+fakechroot chroot $ROOTDIR tar -cf $TARBALL -C / .
+mv $ROOTDIR/$TARBALL .
-- 
1.7.10.4
signature.asc (application/pgp-signature, 490 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iQEcBAEBCAAGBQJQcotnAAoJEO/obGx//s+DETEH/39+Hwzrubl9IN9QSd65sIrD
vtW1Vv0EXwDThARq6vrI1g7BJxfyJNRuL8bhgZlgG9HsR2m4eQl+jOAURytZpaNg
riX6aSpUwRmyR2pHmuvS3WOHxdeFI2EecvqtIQLybiN30XFjvQUiyWRPGgoPo4As
vVqySRmHqPjH9/CZgEdCB0ZQ0694Oul+uksWuk0MfGEEK4wjSysunDD58tcjbC/Q
rkN1Icmz8TxgdW8zZtaJ6cUeiym/CPzdgpC8jK/iWsKrxfFKgsP2Eeg7g2Zo42jM
ZeTPLhwgbMZ/ai0Z1edcwJOShs5MMkffmn/f3FLsYpztCpbLgQU/umM1+rDNEJQ=
=gQaL
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.