Difference between revisions of "tar notes"
From Noah.org
Jump to navigationJump to searchm (Created page with 'Category:Engineering == permission and ownership of files inside a tar == If you are making tarballs for installing on other machines you usually want the files inside the …') |
m |
||
Line 13: | Line 13: | ||
<pre> | <pre> | ||
GZIP="--best" tar --numeric-owner --owner=0 --group=0 --directory=${STAGING_DIR%/*} --exclude=.svn -czf ${OUTPUT_DIR##*/}/piebox_setup.tar.gz ${STAGING_DIR##*/} | GZIP="--best" tar --numeric-owner --owner=0 --group=0 --directory=${STAGING_DIR%/*} --exclude=.svn -czf ${OUTPUT_DIR##*/}/piebox_setup.tar.gz ${STAGING_DIR##*/} | ||
+ | </pre> | ||
+ | |||
+ | == show progress bar when decompressing tar == | ||
+ | |||
+ | This will print and update message like "Wrote 27%". This will overwrite and update the current line. | ||
+ | <pre> | ||
+ | tar --blocking-factor=$(($(gzip --list -v tarball.tgz | sed -n -e "s/.*[[:space:]]\+[0-9]\+[[:space:]]\+\([0-9]\+\)[[:space:]].*$/\1/p") / 51200 + 1)) --checkpoint=1 --checkpoint-action='ttyout=Wrote %u% \r' -zxf tarball.tgz | ||
+ | </pre> | ||
+ | If you prefer the have the update message on a separate line then use this syntax: | ||
+ | <pre> | ||
+ | tar --blocking-factor=$(($(gzip --list -v tarball.tgz | sed -n -e "s/.*[[:space:]]\+[0-9]\+[[:space:]]\+\([0-9]\+\)[[:space:]].*$/\1/p") / 51200 + 1)) --checkpoint=1 --checkpoint-action='echo=Wrote %u%' -zxf tarball.tgz | ||
</pre> | </pre> |
Revision as of 01:30, 24 August 2010
permission and ownership of files inside a tar
If you are making tarballs for installing on other machines you usually want the files inside the archive to be owned by root. Usually you do not build as root. You can force ownership and group with three arguments. This will record the UID and GID in the tar file as 0 (root).
tar --numeric-owner --owner=0 --group=0 -czf install_tree.tgz $STAGING_DIR
This is a fancier version that sets input and directories; trims the trailing slash off of STAGING_DIR; and sets the gzip compression level to the max.
GZIP="--best" tar --numeric-owner --owner=0 --group=0 --directory=${STAGING_DIR%/*} --exclude=.svn -czf ${OUTPUT_DIR##*/}/piebox_setup.tar.gz ${STAGING_DIR##*/}
show progress bar when decompressing tar
This will print and update message like "Wrote 27%". This will overwrite and update the current line.
tar --blocking-factor=$(($(gzip --list -v tarball.tgz | sed -n -e "s/.*[[:space:]]\+[0-9]\+[[:space:]]\+\([0-9]\+\)[[:space:]].*$/\1/p") / 51200 + 1)) --checkpoint=1 --checkpoint-action='ttyout=Wrote %u% \r' -zxf tarball.tgz
If you prefer the have the update message on a separate line then use this syntax:
tar --blocking-factor=$(($(gzip --list -v tarball.tgz | sed -n -e "s/.*[[:space:]]\+[0-9]\+[[:space:]]\+\([0-9]\+\)[[:space:]].*$/\1/p") / 51200 + 1)) --checkpoint=1 --checkpoint-action='echo=Wrote %u%' -zxf tarball.tgz