0

I build some archive for linux kernel it need an archive file with absolute path. File are under folder /data/ when I pack normally it keeps file path like this

bin/ln
bin/ls
etc

the command I used is like this

cd /data
find|cpio -o -H newc -F ../data.cpio

but I want cpio to keep file with root path like this

/bin/ln
/bin/ls
/etc

I found I shuold use pax but I dont know how to write regex for path replacement

Hamid
  • 113
  • 4

1 Answers1

2

This should work as long as no filename contain the '>' characters:

pax -w -x sv4cpio -s '>^\.>>' . >../data.cpio

The -x sv4cpio should satisfy the requirement for using -H newc (SVR4 format).

Colin Pearse
  • 126
  • 4
  • thanx alot it saved my time, can you explain what is the meaning of ^ in your regex – Hamid Mar 19 '19 at 18:54
  • ^ tells regex to match the start of the string. (And $ tells regex to match the end of the string). – Colin Pearse Mar 20 '19 at 19:34
  • Please note that `-x sv4cpio` is non-portable and applies only to one specific `pax` implementation that is not `pax` compliant since it does not support `-x pax`. This specific `pax` implementation you have in mind therefore is still at a development state from 1992. – schily Jul 13 '20 at 09:31