0

I faced a problem of building a tarball for my application manually to prepare a distribution. My project structure looks as

project_root
     |
     |__resources
     |     |____config.conf
     |
   ....
     |__target
           |____release
                    |___bin
                         |___app.bin

So I need to tar 2 files as foolows:

project_root/resource/config.conf         -->   ./app/config/example/config.conf
project_root/target/release/bin/app.bin   -->   ./app/app.bin

There is a good example of how to tar multiple files and for tar with relative paths, but for a single file.

Is there a way to tar the two files in the scheme above?

1 Answers1

1

With GNU tar you can include the two files manually and modify the paths using the --transform option:

tar --transform=s,project_root/resources/,./app/config/example/, \
    --transform=s,project_root/target/release/bin/,./app/, \
    -cf my.tar \
    project_root/resources/config.conf \
    project_root/target/release/bin/app.bin

Output:

$ tar tf my.tar
./app/config/example/config.conf
./app/app.bin
Freddy
  • 25,565