I'm working on something in a Makefile that will look something like this:
tarball: mkdir -p tmp/tarball/etc/service mkdir -p tmp/tarball/usr/local mkdir -p tmp/tarball/opt/myproject cd sensordatad; make cd sensortunneld; make device_name cp -r sensorservices tmp/tarball/etc/service # Make a tarball here, something like: # chroot tmp/tarball; tar -czvf myproject.tar.gz .
The idea is that I'll be able to move into the ./tmp/tarball
directory, and create a tarball which when unpacked on a system will unpack itself to /etc/service
, /usr/local
and to /opt/myproject
.
The classical approach seems to be to use tar -czvf -C tmp/tarball .
but this leads to a tar listing of entries that start with ./
.
I'm inspired by the package from the Go language, which indicates that it should be installed with:
tar -C /usr/local -xzf go1.0.3.linux-amd64.tar.gz
Which would be ideal for my use-case, I'd like to be able to do:
tar -C / -xzf myproject.tar.gx
Which would in turn extract the files originally in ~/some-working-directory/tmp/tarball/_____
to /_____
, meaning that I could simply fake the installation structure.
Of course this might better be achieved with something like fpm
, which I haven't ruled out, but I'm not keen on heavy weight solutions, and I assumed that I'd be able to do this without resorting to Ruby.
I've stumbled upon fakechroot
, which seems promising, but not surprisingly, tar doesn't exist in the chroot, and when I started going down that rabbit hole I just assumed I was doing something wrong and should ask for assistance.
.deb
and.rpm
./opt
doesn't exist on my system! Tarballs are great for source distribution, or where the entire application can be unpacked to a single folder anywhere on the system and run from there.