Browse Source

mytarc: Add options to exclude VCS and eide files

Add --no-vcs option to exclude VCS directories, and --no-eide to
exclude files generated by Emacs eide package.

Signed-off-by: Cédric Marie <cedric@hjuvi.fr.eu.org>
main
Cédric Marie 4 months ago
parent
commit
d027f32dfe
  1. 21
      scripts/mytarc

21
scripts/mytarc

@ -27,7 +27,10 @@ print_usage()
printf " --bz2 create a .tar.bz2 file instead of .tar.xz\n"
printf " -t,--timestamp timestamp the output file\n"
printf " -e,--encrypt encrypt the output file with a password (add .enc suffix)\n"
printf " -s,--sha256 create a .sha256 file\n"
printf " -s,--sha256 create a .sha256 file (checksum)\n"
printf " --no-vcs Exclude VCS files\n"
printf " --no-eide Exclude Emacs eide files (.emacs.desktop*, TAGS, cscope.*,\n"
printf " .emacs-ide-project.cfg, *.ref, *.new)\n"
}
option_tar=0
@ -36,9 +39,11 @@ option_bz2=0
option_timestamp=0
option_encrypt=0
option_sha256=0
option_no_vcs=0
option_no_eide=0
# Get options from the command line
options=$(getopt --options htes --longoptions help,tar,gz,bz2,timestamp,encrypt,sha256 -- "$@")
options=$(getopt --options htes --longoptions help,tar,gz,bz2,timestamp,encrypt,sha256,no-vcs,no-eide -- "$@")
if [ $? -ne 0 ]; then print_usage; exit 1; fi
eval set -- "$options"
@ -51,6 +56,8 @@ while true; do
-t|--timestamp) option_timestamp=1;;
-e|--encrypt) option_encrypt=1;;
-s|--sha256) option_sha256=1;;
--no-vcs) option_no_vcs=1;;
--no-eide) option_no_eide=1;;
--) shift; break;;
*) print_usage; exit 1;;
esac
@ -89,8 +96,16 @@ if [ $option_encrypt -eq 1 ]; then
else
output_file=$file
fi
if [ $option_no_vcs -eq 1 ]; then
tar_exclude_opts="--exclude-vcs"
else
tar_exclude_opts=
fi
if [ $option_no_eide -eq 1 ]; then
tar_exclude_opts="${tar_exclude_opts} --exclude=.emacs.desktop* --exclude=TAGS --exclude=cscope.* --exclude=.emacs-ide-project.cfg --exclude=*.ref --exclude=*.new"
fi
printf "\033[1mCreate archive...\033[0m\n"
tar -${tar_opt}cvf $file $dir
tar ${tar_exclude_opts} -${tar_opt}cvf $file $dir
if [ $option_encrypt -eq 1 ]; then
openssl aes-256-cbc -pbkdf2 -e -a -salt -in $file -out $output_file
rm -f $file

Loading…
Cancel
Save