Jeremy Huntwork wrote:
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 '[EMAIL PROTECTED]/@@' -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 '[EMAIL PROTECTED]/@@;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?
Jermemy:
tar -tf ${heArchiveName} | head -n 1 | sed -e '[EMAIL PROTECTED]/@@' -e
's@/.*$@@'
Will give you the root 'without' unpacking the archive. The -t only
lists the contents. Extracting the root dir for a kernel happens in the
blink of an eye.. give it a try.
--
JH
--
http://linuxfromscratch.org/mailman/listinfo/alfs-discuss
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page