Merge ~ahasenack/ubuntu/+source/backuppc:trusty-backuppc-smb-1576187 into ubuntu/+source/backuppc:ubuntu/trusty-devel

Proposed by Andreas Hasenack
Status: Merged
Approved by: Christian Ehrhardt 
Approved revision: 7d660d980d5a1ec9ba52e77025060c039cc673f2
Merged at revision: 79e410c3d44c5783a8e5552e7614c81bb5120800
Proposed branch: ~ahasenack/ubuntu/+source/backuppc:trusty-backuppc-smb-1576187
Merge into: ubuntu/+source/backuppc:ubuntu/trusty-devel
Diff against target: 204 lines (+167/-0)
5 files modified
debian/changelog (+8/-0)
debian/patches/smb-compat-fix.patch (+66/-0)
debian/rules (+1/-0)
debian/tests/control (+3/-0)
debian/tests/smb-backup (+89/-0)
Reviewer Review Type Date Requested Status
Christian Ehrhardt  (community) Approve
Canonical Server Pending
Canonical Server Core Reviewers Pending
Review via email: mp+356883@code.launchpad.net

Description of the change

Same as https://code.launchpad.net/~ahasenack/ubuntu/+source/backuppc/+git/backuppc/+merge/356880, but for trusty

This branch applies the fix that upstream chose for #1576187. This is different from what was applied in debian (which is what we have in bionic and later), but also fixes the problem, and in a better way we believe.

While writing up the testing instructions, I realized these could be easily scripted, and as such I'm also adding a simple samba-based DEP8 test to this package. This test actually exercises the present bug, so if it's run with the package without the fix, it will correctly fail.

The same dep8 test can and will be added to cosmic+1 once it opens (see https://bugs.launchpad.net/ubuntu/+source/backuppc/+bug/1677755).

Testing instructions are provided in the bug, but they are the same as the newly added DEP8 test, which you can run manually if you want.

Bileto ticket: https://bileto.ubuntu.com/#/ticket/3486
PPA: sudo add-apt-repository ppa:ci-train-ppa-service/3486

To post a comment you must log in.
Revision history for this message
Andreas Hasenack (ahasenack) wrote :

I don't understand why the trusty dep8 tests are not running in bileto. They ran locally via autopkgtest in a VM just fine. Is it a bileto restriction or shortcoming?

Revision history for this message
Andreas Hasenack (ahasenack) wrote :

I also updated this branch with the same change I did to the xenial one regarding how the dep8 test populates the share directory.

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

But you did not move the dep3 tags up :-/
Not bad but to keep things symetric fix it here as well please or explicitly state that you want to keep as-is.

review: Needs Information
Revision history for this message
Andreas Hasenack (ahasenack) wrote :

Indeed, I just pushed a fix for that. No --force was used, so you can check the diff.

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

LGTM now - thanks +1

review: Approve
Revision history for this message
Andreas Hasenack (ahasenack) wrote :

This now contains all the latest changes.

Updated bileto ticket: https://bileto.ubuntu.com/#/ticket/3486

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

On trusty bileto still doesn't run your tests, but I know you have local runs that work.
+1 here as well, thanks for sorting out arm.

Revision history for this message
Andreas Hasenack (ahasenack) wrote :

Correct, I ran the dep8 tests in trusty locally in a vm.

Revision history for this message
Andreas Hasenack (ahasenack) wrote :

Tagged and uploaded.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/debian/changelog b/debian/changelog
index 1badf10..90b3286 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
1backuppc (3.3.0-1ubuntu1.1) trusty; urgency=medium
2
3 * d/rules, d/p/smb-compat-fix.patch: cope with changes in newer smbclient.
4 Thanks to Maksym Schipka <maksym@hotmail.com> (LP: #1576187)
5 * d/t/{control,smb-backup}: simple smb-based DEP8 test (LP: #1677755)
6
7 -- Andreas Hasenack <andreas@canonical.com> Tue, 23 Oct 2018 09:06:27 -0300
8
1backuppc (3.3.0-1ubuntu1) trusty-proposed; urgency=low9backuppc (3.3.0-1ubuntu1) trusty-proposed; urgency=low
210
3 * Merge from Debian unstable. Remaining changes: (LP: #1201029)11 * Merge from Debian unstable. Remaining changes: (LP: #1201029)
diff --git a/debian/patches/smb-compat-fix.patch b/debian/patches/smb-compat-fix.patch
4new file mode 10064412new file mode 100644
index 0000000..b436970
--- /dev/null
+++ b/debian/patches/smb-compat-fix.patch
@@ -0,0 +1,66 @@
1From d7a8403b537ed0068e862abc20065e98209527b7 Mon Sep 17 00:00:00 2001
2From: Maksym Schipka <maksym@hotmail.com>
3Date: Sun, 14 Aug 2016 09:24:52 +0100
4Subject: [PATCH] Fixing compatibility with Samba 4.3
5Origin: https://github.com/backuppc/backuppc/commit/c550528be63c3b66744830e992b908fff3f2e271
6Bug: https://github.com/backuppc/backuppc/issues/21
7Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/backuppc/+bug/1576187
8Bug-Debian: https://bugzilla.samba.org/show_bug.cgi?id=11642
9Last-Update: 2018-10-16
10
11---
12 bin/BackupPC_dump | 2 ++
13 lib/BackupPC/Xfer/Smb.pm | 13 ++++++++++++-
14 2 files changed, 14 insertions(+), 1 deletion(-)
15diff --git a/bin/BackupPC_dump b/bin/BackupPC_dump
16index 9491046..e41cb68 100755
17--- debian/backuppc/usr/share/backuppc/bin/BackupPC_dump
18+++ debian/backuppc/usr/share/backuppc/bin/BackupPC_dump
19@@ -873,6 +873,8 @@ for my $shareName ( @$ShareNames ) {
20 # Merge the xfer status (need to accumulate counts)
21 #
22 my $newStat = $xfer->getStats;
23+ # MAKSYM 14082016: forcing the right file count if some bytes were transferred; ensures compatibility with at least Samba-4.3
24+ $newStat->{fileCnt} = $nFilesTotal if ( $useTar && $newStat->{fileCnt} == 0 && $xfer->getStats->{byteCnt} > 0 );
25 if ( $newStat->{fileCnt} == 0 ) {
26 $noFilesErr ||= "No files dumped for share $shareName";
27 }
28diff --git a/lib/BackupPC/Xfer/Smb.pm b/lib/BackupPC/Xfer/Smb.pm
29index eaf002e..48964cb 100644
30--- debian/backuppc/usr/share/backuppc/lib/BackupPC/Xfer/Smb.pm
31+++ debian/backuppc/usr/share/backuppc/lib/BackupPC/Xfer/Smb.pm
32@@ -217,6 +217,8 @@ sub readOutput
33 # This section is highly dependent on the version of smbclient.
34 # If you upgrade Samba, make sure that these regexp are still valid.
35 #
36+ # MAKSYM 14082016: The next regex will never match on Samba-4.3, as
37+ # smbclient doesn't produce output required; keeping it for older Sambas
38 if ( /^\s*(-?\d+) \(\s*\d+[.,]\d kb\/s\) (.*)$/ ) {
39 my $sambaFileSize = $1;
40 my $pcFileName = $2;
41@@ -230,8 +232,15 @@ sub readOutput
42 $t->{byteCnt} += $2;
43 $t->{fileCnt}++;
44 $t->{XferLOG}->write(\"$_\n") if ( $t->{logLevel} >= 1 );
45- } elsif ( /^\s*tar: dumped \d+ files/ ) {
46+ } elsif ( /^\s*tar: dumped (\d+) files/) {
47+ # MAKSYM 14082016: Updating file count to the likely number
48 $t->{xferOK} = 1;
49+ $t->{fileCnt} = $1;
50+ $t->{XferLOG}->write(\"$_\n") if ( $t->{logLevel} >= 0 );
51+ } elsif ( /^\s*tar:\d+\s*Total bytes received: (\d+)/) {
52+ # MAKSYM 14082016: Updating byte count to the likely number
53+ $t->{xferOK} = 1;
54+ $t->{byteCnt} = $1;
55 $t->{XferLOG}->write(\"$_\n") if ( $t->{logLevel} >= 0 );
56 } elsif ( /^\s*tar: restored \d+ files/ ) {
57 $t->{xferOK} = 1;
58@@ -270,6 +279,8 @@ sub readOutput
59 } elsif ( /^\s*directory \\/i ) {
60 $t->{XferLOG}->write(\"$_\n") if ( $t->{logLevel} >= 2 );
61 } elsif ( /smb: \\>/
62+ || /^\s*tar:\d+/ # MAKSYM 14082016: ignoring 2 more Samba-4.3 specific lines
63+ || /^\s*WARNING:/i
64 || /^\s*added interface/i
65 || /^\s*tarmode is now/i
66 || /^\s*Total bytes written/i
diff --git a/debian/rules b/debian/rules
index 3f65022..55e790c 100755
--- a/debian/rules
+++ b/debian/rules
@@ -75,6 +75,7 @@ install: build
75 patch --no-backup-if-mismatch -p0 < debian/patches/config.pl.diff75 patch --no-backup-if-mismatch -p0 < debian/patches/config.pl.diff
76 install --mode=644 debian/backuppc/etc/backuppc/config.pl debian/backuppc/usr/share/backuppc/conf76 install --mode=644 debian/backuppc/etc/backuppc/config.pl debian/backuppc/usr/share/backuppc/conf
77 rm -rf debian/backuppc/etc/backuppc/config.pl77 rm -rf debian/backuppc/etc/backuppc/config.pl
78 patch --no-backup-if-mismatch -p0 < debian/patches/smb-compat-fix.patch
7879
79# Build architecture-independent files here.80# Build architecture-independent files here.
80binary-indep: build install81binary-indep: build install
diff --git a/debian/tests/control b/debian/tests/control
81new file mode 10064482new file mode 100644
index 0000000..c07f175
--- /dev/null
+++ b/debian/tests/control
@@ -0,0 +1,3 @@
1Tests: smb-backup
2Depends: @, samba, smbclient
3Restrictions: isolation-container, allow-stderr, needs-root
diff --git a/debian/tests/smb-backup b/debian/tests/smb-backup
0new file mode 1006444new file mode 100644
index 0000000..7ec3f21
--- /dev/null
+++ b/debian/tests/smb-backup
@@ -0,0 +1,89 @@
1#!/bin/sh
2
3set -ex
4
5check_status() {
6 local status_code=$1
7 local msg="${2:-task}"
8
9 if [ "$status_code" -ne "0" ]; then
10 echo "ERROR: $msg failed, exit status was $status_code"
11 exit "$status_code"
12 else
13 echo "OK: $msg succeeded"
14 fi
15}
16
17populate_directory() {
18 local target="$1"
19 local tempfile
20
21 # target must exist and be a directory
22 test -d "$target" || exit 1
23
24 for n in $(seq 1 10); do
25 tempfile=$(mktemp "$target/tmp.XXXXXX")
26 # the date command makes each tempfile different
27 # the seq command just produces a lot of output
28 # using a "here" document as to not pollute the set -x
29 # output with large command lines
30 cat > "$tempfile" <<EOF
31$(date +%s%N)
32$(seq 1 81920)
33EOF
34 chmod 0644 "$tempfile"
35 done
36}
37
38add_samba_share() {
39 if ! testparm -s 2>&1 | grep -qE "^\[public\]"; then
40 echo "Adding [public] share"
41 cat >> /etc/samba/smb.conf <<EOFEOF
42[public]
43 path = /public
44 read only = no
45 guest ok = yes
46EOFEOF
47 service smbd reload
48 else
49 echo "No need to add [public] share, continuing."
50 fi
51 echo "Populating share"
52 rm -rf /public
53 mkdir -p /public
54 chmod 1777 /public
55 populate_directory /public
56}
57
58add_localhost_backuppc_config() {
59 cat > /etc/backuppc/localhost.pl <<EOFEOF
60\$Conf{XferMethod} = 'smb';
61\$Conf{XferLogLevel} = 1;
62\$Conf{ClientCharset} = '';
63\$Conf{ClientCharsetLegacy} = 'iso-8859-1';
64\$Conf{SmbShareName} = 'public';
65\$Conf{SmbShareUserName} = '';
66\$Conf{SmbSharePasswd} = '';
67\$Conf{PingPath} = '/bin/ping';
68\$Conf{Ping6Path} = '/bin/ping6';
69EOFEOF
70}
71
72echo "Adding samba share"
73add_samba_share
74
75echo "Configuring backuppc"
76add_localhost_backuppc_config
77
78result=0
79echo "Performing a full backup"
80sudo -u backuppc -H /usr/share/backuppc/bin/BackupPC_dump -v -f localhost || result=$?
81check_status $result "Full backup"
82
83result=0
84echo "Changing share content and performing an incremental backup"
85populate_directory /public
86sudo -u backuppc -H /usr/share/backuppc/bin/BackupPC_dump -v -i localhost || result=$?
87check_status $result "Incremental backup"
88
89echo "Done."

Subscribers

People subscribed via source and target branches