Skip to content

Commit

Permalink
Add support for xz compression
Browse files Browse the repository at this point in the history
Fixes: #79
  • Loading branch information
cypriani committed Nov 21, 2016
1 parent 6d7d8bd commit 4eea33d
Show file tree
Hide file tree
Showing 15 changed files with 117 additions and 6 deletions.
4 changes: 2 additions & 2 deletions backup-manager.conf.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ export BM_TARBALL_NAMEFORMAT="long"

# Type of archives
# Available types are:
# tar, tar.gz, tar.bz2, tar.lzma, dar, zip.
# tar, tar.gz, tar.bz2, tar.xz, tar.lzma, dar, zip.
# Make sure to satisfy the appropriate dependencies
# (bzip2, dar, lzma, ...).
# (bzip2, dar, xz, lzma, ...).
export BM_TARBALL_FILETYPE="tar.gz"

# You can choose to build archives remotely over SSH.
Expand Down
5 changes: 3 additions & 2 deletions doc/user-guide.sgml
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ Suggested value: <tt>long</tt>.
<sect2 id="BM_TARBALL_FILETYPE"><tt>BM_TARBALL_FILETYPE</tt>

<p>
<em>Type: enum(tar, tar.gz, tar.bz2, tar.lzma, zip, dar), default: <tt>tar.gz</tt>.</em>
<em>Type: enum(tar, tar.gz, tar.bz2, tar.xz, tar.lzma, zip, dar), default: <tt>tar.gz</tt>.</em>

<p>
Basically, this configuration key defines the filetype of the resulting archive.
Expand All @@ -496,7 +496,7 @@ Note that depending on the filetype you choose, you will have to
make sure you have the corresponding compressor installed.

<p>
For the best compression rate, choose <tt>tar.bz2</tt> or <tt>tar.lzma</tt>.
For the best compression rate, choose <tt>tar.bz2</tt> or <tt>tar.xz</tt>.

<p>
Since version 0.7.1, &bmngr; supports <em>dar</em> archives. This archiver
Expand All @@ -509,6 +509,7 @@ Make sure to statisfy dependencies according to the filetype you choose:

<list>
<item> tar.bz2 : needs "bzip2".
<item> tar.xz : needs "xz".
<item> tar.lzma : needs "lzma".
<item> dar : needs "dar".
<item> zip : needs "zip".
Expand Down
5 changes: 5 additions & 0 deletions lib/actions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,11 @@ function check_filetypes()
if [[ ! -x "$bzip" ]]; then
error "The BM_TARBALL_FILETYPE conf key is set to \"tar.bz2\" but bzip2 is not installed."
fi
;;
"tar.xz" )
if [[ ! -x "$xz" ]]; then
error "The BM_TARBALL_FILETYPE conf key is set to \"tar.xz\" but xz is not installed."
fi
;;
"tar.lzma" )
if [[ ! -x "$lzma" ]]; then
Expand Down
16 changes: 14 additions & 2 deletions lib/backup-methods.sh
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,10 @@ function __get_backup_tarball_remote_command()
__get_flags_tar_blacklist "$target"
command="$tar $blacklist $dumpsymlinks $BM_TARBALL_EXTRA_OPTIONS -p -c -j "$target""
;;
tar.xz)
__get_flags_tar_blacklist "$target"
command="$tar $blacklist $dumpsymlinks $BM_TARBALL_EXTRA_OPTIONS -p -c --xz "$target""
;;
tar.lzma)
__get_flags_tar_blacklist "$target"
command="$tar $blacklist $dumpsymlinks $BM_TARBALL_EXTRA_OPTIONS -p -c --lzma "$target""
Expand Down Expand Up @@ -586,6 +590,13 @@ function __get_backup_tarball_command()
__get_flags_tar_blacklist "$target"
command="$tar $incremental $blacklist $dumpsymlinks $BM_TARBALL_EXTRA_OPTIONS -p -c -j -f"
;;
tar.xz)
if [[ ! -x $xz ]]; then
error "The archive type \"tar.xz\" depends on the tool \"\$xz\"."
fi
__get_flags_tar_blacklist "$target"
command="$tar $incremental $blacklist $dumpsymlinks $BM_TARBALL_EXTRA_OPTIONS -p -c --xz -f"
;;
tar.lzma)
if [[ ! -x $lzma ]]; then
error "The archive type \"tar.lzma\" depends on the tool \"\$lzma\"."
Expand Down Expand Up @@ -658,7 +669,8 @@ function build_encrypted_archive
error "The configuration variable \"BM_ENCRYPTION_RECIPIENT\" must be defined."
fi

if [[ "$BM_TARBALL_FILETYPE" = "tar.lzma" ]] ||
if [[ "$BM_TARBALL_FILETYPE" = "tar.xz" ]] ||
[[ "$BM_TARBALL_FILETYPE" = "tar.lzma" ]] ||
[[ "$BM_TARBALL_FILETYPE" = "zip" ]] ||
[[ "$BM_TARBALL_FILETYPE" = "dar" ]]; then
error "The encryption is not yet possible with \"\$BM_TARBALL_FILETYPE\" archives."
Expand Down Expand Up @@ -796,7 +808,7 @@ function __make_local_tarball_token
"dar")
__get_flags_dar_incremental "$dir_name"
;;
"tar"|"tar.gz"|"tar.bz2"|"tar.lzma")
"tar"|"tar.gz"|"tar.bz2"|"tar.xz"|"tar.lzma")
__get_flags_tar_incremental "$dir_name"
;;
esac
Expand Down
1 change: 1 addition & 0 deletions lib/externals.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ zip=$(which zip 2> /dev/null) || true
bzip=$(which bzip2 2> /dev/null) || true
gzip=$(which gzip 2> /dev/null) || true
gpg=$(which gpg 2> /dev/null) || true
xz=$(which xz 2> /dev/null) || true
lzma=$(which lzma 2> /dev/null) || true
dar=$(which dar 2> /dev/null) || true
tar=$(which tar 2> /dev/null) || true
Expand Down
11 changes: 11 additions & 0 deletions po/backup-manager.pot
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ msgid ""
"installed."
msgstr ""

#: ../lib/actions.sh:193
msgid ""
"The BM_TARBALL_FILETYPE conf key is set to \"tar.xz\" but xz is not "
"installed."
msgstr ""

#: ../lib/actions.sh:193
msgid ""
"The BM_TARBALL_FILETYPE conf key is set to \"tar.lzma\" but lzma is not "
Expand Down Expand Up @@ -206,6 +212,11 @@ msgstr ""
msgid "The archive type \"tar.bz2\" depends on the tool \"$bzip\"."
msgstr ""

#: ../lib/backup-methods.sh:576
#, sh-format
msgid "The archive type \"tar.xz\" depends on the tool \"$xz\"."
msgstr ""

#: ../lib/backup-methods.sh:576
#, sh-format
msgid "The archive type \"tar.lzma\" depends on the tool \"$lzma\"."
Expand Down
5 changes: 5 additions & 0 deletions po/cs.po
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@ msgstr ""
msgid "The archive type \"tar.bz2\" depends on the tool \"$bzip\"."
msgstr "Typ archivu \"tar.bz2\" závisí na nástroji \"$bzip\"."

#: ../lib/backup-methods.sh:571
#, sh-format
msgid "The archive type \"tar.xz\" depends on the tool \"$xz\"."
msgstr "Typ archivu \"tar.xz\" závisí na nástroji \"$xz\"."

#: ../lib/backup-methods.sh:571
#, sh-format
msgid "The archive type \"tar.lzma\" depends on the tool \"$lzma\"."
Expand Down
5 changes: 5 additions & 0 deletions po/de.po
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,11 @@ msgstr "Dar berichtete eine geänderte Datei beim Erstellen des Archivs."
msgid "The archive type \"tar.bz2\" depends on the tool \"$bzip\"."
msgstr "Der Archivtyp »tar.bz2« hängt vom Werkzeug »$bzip« ab."

#: ../lib/backup-methods.sh:571
#, sh-format
msgid "The archive type \"tar.xz\" depends on the tool \"$xz\"."
msgstr "Der Archivtyp »tar.xz« hängt vom Werkzeug »$xz« ab."

#: ../lib/backup-methods.sh:571
#, sh-format
msgid "The archive type \"tar.lzma\" depends on the tool \"$lzma\"."
Expand Down
5 changes: 5 additions & 0 deletions po/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,11 @@ msgstr ""
msgid "The archive type \"tar.bz2\" depends on the tool \"$bzip\"."
msgstr "El tipo de fichero \"tar.bz2\" depende de la herramienta \"$bzip\"."

#: ../lib/backup-methods.sh:571
#, sh-format
msgid "The archive type \"tar.xz\" depends on the tool \"$xz\"."
msgstr "El tipo de fichero \"tar.xz\" depende de la herramienta \"$xz\"."

#: ../lib/backup-methods.sh:571
#, sh-format
msgid "The archive type \"tar.lzma\" depends on the tool \"$lzma\"."
Expand Down
9 changes: 9 additions & 0 deletions po/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ msgstr "La clef BM_TARBALL_FILETYPE vaut « zip » mais zip n'est pas install
msgid "The BM_TARBALL_FILETYPE conf key is set to \"tar.bz2\" but bzip2 is not installed."
msgstr "La clef BM_TARBALL_FILETYPE vaut « tar.bz2 » mais bzip2 n'est pas installé."

#: ../lib/actions.sh:193
msgid "The BM_TARBALL_FILETYPE conf key is set to \"tar.xz\" but xz is not installed."
msgstr "La clef BM_TARBALL_FILETYPE vaut « tar.xz » mais xz n'est pas installé."

#: ../lib/actions.sh:193
msgid "The BM_TARBALL_FILETYPE conf key is set to \"tar.lzma\" but lzma is not installed."
msgstr "La clef BM_TARBALL_FILETYPE vaut « tar.lzma » mais lzma n'est pas installé."
Expand Down Expand Up @@ -195,6 +199,11 @@ msgstr "Dar a renvoyé qu'un fichier a changé pendant la création de l'archive
msgid "The archive type \"tar.bz2\" depends on the tool \"$bzip\"."
msgstr "Le type d'archive « tar.bz2 » dépend de l'outil « $bzip »."

#: ../lib/backup-methods.sh:576
#, sh-format
msgid "The archive type \"tar.xz\" depends on the tool \"$xz\"."
msgstr "Le type d'archive « tar.xz » dépend de l'outil « $xz »."

#: ../lib/backup-methods.sh:576
#, sh-format
msgid "The archive type \"tar.lzma\" depends on the tool \"$lzma\"."
Expand Down
5 changes: 5 additions & 0 deletions po/it.po
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,11 @@ msgstr ""
msgid "The archive type \"tar.bz2\" depends on the tool \"$bzip\"."
msgstr "Il tipo di archivio \"tar.bz2\" dipende dal tool \"$bzip\"."

#: ../lib/backup-methods.sh:571
#, sh-format
msgid "The archive type \"tar.xz\" depends on the tool \"$xz\"."
msgstr "Il tipo di archivio \"tar.xz\" dipende dal tool \"$xz\"."

#: ../lib/backup-methods.sh:571
#, sh-format
msgid "The archive type \"tar.lzma\" depends on the tool \"$lzma\"."
Expand Down
5 changes: 5 additions & 0 deletions po/nl.po
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@ msgstr ""
msgid "The archive type \"tar.bz2\" depends on the tool \"$bzip\"."
msgstr "Het archieftype \"tar.bz2\" is afhankelijk van de tool \"$bzip\"."

#: ../lib/backup-methods.sh:571
#, sh-format
msgid "The archive type \"tar.xz\" depends on the tool \"$xz\"."
msgstr "Het archieftype \"tar.xz\" is afhankelijk van de tool \"$xz\"."

#: ../lib/backup-methods.sh:571
#, sh-format
msgid "The archive type \"tar.lzma\" depends on the tool \"$lzma\"."
Expand Down
5 changes: 5 additions & 0 deletions po/vi.po
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,11 @@ msgstr ""
msgid "The archive type \"tar.bz2\" depends on the tool \"$bzip\"."
msgstr "Kiểu kho nén « tar.bz2 » phụ thuộc vào công cụ « $bzip »."

#: ../lib/backup-methods.sh:571
#, sh-format
msgid "The archive type \"tar.xz\" depends on the tool \"$xz\"."
msgstr "Kiểu kho nén « tar.xz » phụ thuộc vào công cụ « $xz »."

#: ../lib/backup-methods.sh:571
#, sh-format
msgid "The archive type \"tar.lzma\" depends on the tool \"$lzma\"."
Expand Down
41 changes: 41 additions & 0 deletions t/t21-tarball-xz.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/sh

set -e

# Each test script should include testlib.sh
source testlib.sh
# When the test is ready, set this to false for nice outputs.
# if you want to see what happens, use those flags
#verbose="true"
#warnings="true"
#verbosedebug="true"

# The conffile part of the test, see confs/* for details.
source confs/base.conf
source confs/tarball.conf

export BM_ARCHIVE_ROOT="repository"
export BM_ARCHIVE_METHOD="tarball"
export BM_TARBALL_DIRECTORIES="$PWD"
export BM_TARBALL_FILETYPE="tar.xz"
source $locallib/sanitize.sh

# The test actions

if [[ -e $BM_ARCHIVE_ROOT ]]; then
rm -f $BM_ARCHIVE_ROOT/*
fi

bm_init_env
bm_init_today

create_directories
make_archives

name=$(get_dir_name $PWD long)
if [[ -e "$BM_ARCHIVE_ROOT/$BM_ARCHIVE_PREFIX$name.$TODAY.master.tar.xz" ]]; then
rm -rf $BM_ARCHIVE_ROOT
exit 0
else
exit 1
fi
1 change: 1 addition & 0 deletions t/testlib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ zip=$(which zip) || true
bzip=$(which bzip2) || true
gzip=$(which gzip) || true
gpg=$(which gpg) || true
xz=$(which xz) || true
lzma=$(which lzma) || true
dar=$(which dar) || true
tar=$(which tar) || true
Expand Down

0 comments on commit 4eea33d

Please sign in to comment.