WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Making a TC remaster script but need a little help  (Read 2221 times)

Offline Magil

  • Newbie
  • *
  • Posts: 13
Making a TC remaster script but need a little help
« on: January 05, 2010, 08:25:43 AM »
Hello, I am trying to make a script to remaster TC as i remaster a lot and dont want to type it out all the time. My question is however about a line that I dont quite understand:

zcat /tmp/tinycore.gz | sudo cpio -i -H newc -d

This line is normally used to unpack tinycore.gz in the directory your currently in. I want it to output to a specific directory. I tried a few combinations by adding the directory before and after the | mark but it doesnt output to that directory. Can someone tell me what im overlooking? thanks.

Offline robc

  • Sr. Member
  • ****
  • Posts: 447
Re: Making a TC remaster script but need a little help
« Reply #1 on: January 05, 2010, 11:30:17 AM »
this will work in a script:
Code: [Select]
#!/bin/sh
ORIGDIR=`pwd`
mkdir -p $1
cd $1
zcat $ORIGDIR/tinycore.gz | sudo cpio -i -H newc -d

just use a command like: ./script.sh /path/to/tc/source
the script needs to be in the same directory as tinycore.gz
"Never give up! Never surrender!" - Commander Peter Quincy Taggart

"Make it so." - Captain Picard

Offline maro

  • Hero Member
  • *****
  • Posts: 1228
Re: Making a TC remaster script but need a little help
« Reply #2 on: January 05, 2010, 05:48:09 PM »
AFAIK, the cpio command will always extract into the current directory.

Unless you have the cpio.tcz extension installed, you'd be using the BusyBox cpio command. The web page (http://www.busybox.net/downloads/BusyBox.html#cpio) does not provide any more information than what you'd get with 'cpio --help'. Since BusyBox uses mostly a subset of it's GNU cousins the next stop to find out more is the GNU cpio web page: http://www.gnu.org/software/cpio/manual/cpio.html

Reading through that page shows that even the fully featured GNU cpio command (the one you'd get with cpio.tcz) does not offer any option to change the extraction target directory.

I personally use for cpio extraction the 'cpio -idum' options to: (1) extract directories, (2) overwrite pre-existing files, and (3) preserve the modification timestamps from the archive. Please note that I've found '-H newc' to be a completely redundant option, that might have had some meaning in the past.

One further note with regards to the initrd archive: One should always extract this as root (e.g. "... | sudo cpio -idum") to ensure that no ownership, permissions or special devices are "lost".
« Last Edit: January 05, 2010, 05:53:05 PM by maro »

Offline Magil

  • Newbie
  • *
  • Posts: 13
Re: Making a TC remaster script but need a little help
« Reply #3 on: January 06, 2010, 03:11:44 AM »
ok, so if I want to make this script automated but make it run from another folder, I would first need to make a second cpio script and copy that to the folder where I want to extract tinycore. Then run the second script from the first one. I'm Going to try this today, ill let you know if it works and if you guys have more idea's please tell me. Thanks for the input  :)

Offline Magil

  • Newbie
  • *
  • Posts: 13
Re: Making a TC remaster script but need a little help
« Reply #4 on: January 06, 2010, 04:00:39 AM »
Hmmm my idea did not work (ofcourse), if I make a second script but call it from the first one then tinycore still gets extracted in the directory where I run the first script. This makes sense but i have to try something else.