abort/resume package builds could be a bit more controlled

Jeremy Huntwork jhuntwork at linuxfromscratch.org
Sun May 28 12:30:34 PDT 2006


On Sun, May 28, 2006 at 11:30:39AM -0700, Dan Nicholson wrote:
> >top entry.  I believe he ended up with the cmd DIR=$(bunzip2 -dc $1 |
> >tar tf - | head -n 1 ) and then he stripped $DIR .  Would this be helpful?
> 
> I thought you guys already had that.  You have to be a little careful
> with that command because the first line is not necessarily a
> directory and could be prefixed with ./.  Here's the code that I
> ripped off from Ryan Oliver's scripts:
> 
> PKG_DIR=$( tar -t${ZM} -f ${ARCHIVE} | head -n1 \
>                | sed -e 's@^\./@@' -e 's@/.*$@@' || : )

We don't need new commands to extract the directory name - that's not
the issue here. We've been able to get that just fine up to now with
this:

tar -xvf `ls -t $(1) | head -n1` > /tmp/unpacked (when we unpack the
tarball)

Then when we need the directory name:

ROOT=`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'`

The solution you present above only removes the output to a file. In our
current setup, the file is necessary because we're using the variables
later in the game and the process is not controlled by one environment
in a shell, but by make and its environment.

My problem is how do you dynamically retrieve the name of the directory
*before* you unpack it so that you can remove a possibly existing
directory of the same name, and *then* unpack it freshly?

--
JH



More information about the alfs-discuss mailing list