V2.pm 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550
  1. # Copyright © 2008 Raphaël Hertzog <hertzog@debian.org>
  2. #
  3. # This program is free software; you can redistribute it and/or modify
  4. # it under the terms of the GNU General Public License as published by
  5. # the Free Software Foundation; either version 2 of the License, or
  6. # (at your option) any later version.
  7. #
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. package Dpkg::Source::Package::V2;
  16. use strict;
  17. use warnings;
  18. our $VERSION = "0.01";
  19. use base 'Dpkg::Source::Package';
  20. use Dpkg;
  21. use Dpkg::Gettext;
  22. use Dpkg::ErrorHandling;
  23. use Dpkg::Compression;
  24. use Dpkg::Source::Archive;
  25. use Dpkg::Source::Patch;
  26. use Dpkg::Exit;
  27. use Dpkg::Source::Functions qw(erasedir is_binary fs_time);
  28. use POSIX;
  29. use File::Basename;
  30. use File::Temp qw(tempfile tempdir);
  31. use File::Path;
  32. use File::Spec;
  33. use File::Find;
  34. our $CURRENT_MINOR_VERSION = "0";
  35. sub init_options {
  36. my ($self) = @_;
  37. $self->SUPER::init_options();
  38. $self->{'options'}{'include_removal'} = 0
  39. unless exists $self->{'options'}{'include_removal'};
  40. $self->{'options'}{'include_timestamp'} = 0
  41. unless exists $self->{'options'}{'include_timestamp'};
  42. $self->{'options'}{'include_binaries'} = 0
  43. unless exists $self->{'options'}{'include_binaries'};
  44. $self->{'options'}{'preparation'} = 1
  45. unless exists $self->{'options'}{'preparation'};
  46. $self->{'options'}{'skip_patches'} = 0
  47. unless exists $self->{'options'}{'skip_patches'};
  48. $self->{'options'}{'unapply_patches'} = 0
  49. unless exists $self->{'options'}{'unapply_patches'};
  50. $self->{'options'}{'skip_debianization'} = 0
  51. unless exists $self->{'options'}{'skip_debianization'};
  52. $self->{'options'}{'create_empty_orig'} = 0
  53. unless exists $self->{'options'}{'create_empty_orig'};
  54. $self->{'options'}{'abort_on_upstream_changes'} = 0
  55. unless exists $self->{'options'}{'abort_on_upstream_changes'};
  56. }
  57. sub parse_cmdline_option {
  58. my ($self, $opt) = @_;
  59. if ($opt =~ /^--include-removal$/) {
  60. $self->{'options'}{'include_removal'} = 1;
  61. return 1;
  62. } elsif ($opt =~ /^--include-timestamp$/) {
  63. $self->{'options'}{'include_timestamp'} = 1;
  64. return 1;
  65. } elsif ($opt =~ /^--include-binaries$/) {
  66. $self->{'options'}{'include_binaries'} = 1;
  67. return 1;
  68. } elsif ($opt =~ /^--no-preparation$/) {
  69. $self->{'options'}{'preparation'} = 0;
  70. return 1;
  71. } elsif ($opt =~ /^--skip-patches$/) {
  72. $self->{'options'}{'skip_patches'} = 1;
  73. return 1;
  74. } elsif ($opt =~ /^--unapply-patches$/) {
  75. $self->{'options'}{'unapply_patches'} = 1;
  76. return 1;
  77. } elsif ($opt =~ /^--skip-debianization$/) {
  78. $self->{'options'}{'skip_debianization'} = 1;
  79. return 1;
  80. } elsif ($opt =~ /^--create-empty-orig$/) {
  81. $self->{'options'}{'create_empty_orig'} = 1;
  82. return 1;
  83. } elsif ($opt =~ /^--abort-on-upstream-changes$/) {
  84. $self->{'options'}{'abort_on_upstream_changes'} = 1;
  85. return 1;
  86. }
  87. return 0;
  88. }
  89. sub do_extract {
  90. my ($self, $newdirectory) = @_;
  91. my $fields = $self->{'fields'};
  92. my $dscdir = $self->{'basedir'};
  93. my $basename = $self->get_basename();
  94. my $basenamerev = $self->get_basename(1);
  95. my ($tarfile, $debianfile, %origtar, %seen);
  96. my $re_ext = $compression_re_file_ext;
  97. foreach my $file ($self->get_files()) {
  98. (my $uncompressed = $file) =~ s/\.$re_ext$//;
  99. error(_g("duplicate files in %s source package: %s.*"), "v2.0",
  100. $uncompressed) if $seen{$uncompressed};
  101. $seen{$uncompressed} = 1;
  102. if ($file =~ /^\Q$basename\E\.orig\.tar\.$re_ext$/) {
  103. $tarfile = $file;
  104. } elsif ($file =~ /^\Q$basename\E\.orig-([[:alnum:]-]+)\.tar\.$re_ext$/) {
  105. $origtar{$1} = $file;
  106. } elsif ($file =~ /^\Q$basenamerev\E\.debian\.tar\.$re_ext$/) {
  107. $debianfile = $file;
  108. } else {
  109. error(_g("unrecognized file for a %s source package: %s"),
  110. "v2.0", $file);
  111. }
  112. }
  113. unless ($tarfile and $debianfile) {
  114. error(_g("missing orig.tar or debian.tar file in v2.0 source package"));
  115. }
  116. erasedir($newdirectory);
  117. # Extract main tarball
  118. info(_g("unpacking %s"), $tarfile);
  119. my $tar = Dpkg::Source::Archive->new(filename => "$dscdir$tarfile");
  120. $tar->extract($newdirectory, no_fixperms => 1,
  121. options => [ "--anchored", "--no-wildcards-match-slash",
  122. "--exclude", "*/.pc", "--exclude", ".pc" ]);
  123. # The .pc exclusion is only needed for 3.0 (quilt) and to avoid
  124. # having an upstream tarball provide a directory with symlinks
  125. # that would be blindly followed when applying the patches
  126. # Extract additional orig tarballs
  127. foreach my $subdir (keys %origtar) {
  128. my $file = $origtar{$subdir};
  129. info(_g("unpacking %s"), $file);
  130. if (-e "$newdirectory/$subdir") {
  131. warning(_g("required removal of `%s' installed by original tarball"), $subdir);
  132. erasedir("$newdirectory/$subdir");
  133. }
  134. $tar = Dpkg::Source::Archive->new(filename => "$dscdir$file");
  135. $tar->extract("$newdirectory/$subdir", no_fixperms => 1);
  136. }
  137. # Stop here if debianization is not wanted
  138. return if $self->{'options'}{'skip_debianization'};
  139. # Extract debian tarball after removing the debian directory
  140. info(_g("unpacking %s"), $debianfile);
  141. erasedir("$newdirectory/debian");
  142. # Exclude existing symlinks from extraction of debian.tar.gz as we
  143. # don't want to overwrite something outside of $newdirectory due to a
  144. # symlink
  145. my @exclude_symlinks;
  146. my $wanted = sub {
  147. return if not -l $_;
  148. my $fn = File::Spec->abs2rel($_, $newdirectory);
  149. push @exclude_symlinks, "--exclude", $fn;
  150. };
  151. find({ wanted => $wanted, no_chdir => 1 }, $newdirectory);
  152. $tar = Dpkg::Source::Archive->new(filename => "$dscdir$debianfile");
  153. $tar->extract($newdirectory, in_place => 1,
  154. options => [ '--anchored', '--no-wildcards',
  155. @exclude_symlinks ]);
  156. # Apply patches (in a separate method as it might be overriden)
  157. $self->apply_patches($newdirectory, usage => 'unpack')
  158. unless $self->{'options'}{'skip_patches'};
  159. }
  160. sub get_autopatch_name {
  161. return "zz_debian-diff-auto";
  162. }
  163. sub get_patches {
  164. my ($self, $dir, %opts) = @_;
  165. $opts{"skip_auto"} = 0 unless defined($opts{"skip_auto"});
  166. my @patches;
  167. my $pd = "$dir/debian/patches";
  168. my $auto_patch = $self->get_autopatch_name();
  169. if (-d $pd) {
  170. opendir(DIR, $pd) || syserr(_g("cannot opendir %s"), $pd);
  171. foreach my $patch (sort readdir(DIR)) {
  172. # patches match same rules as run-parts
  173. next unless $patch =~ /^[\w-]+$/ and -f "$pd/$patch";
  174. next if $opts{"skip_auto"} and $patch eq $auto_patch;
  175. push @patches, $patch;
  176. }
  177. closedir(DIR);
  178. }
  179. return @patches;
  180. }
  181. sub apply_patches {
  182. my ($self, $dir, %opts) = @_;
  183. $opts{"skip_auto"} = 0 unless defined($opts{"skip_auto"});
  184. my @patches = $self->get_patches($dir, %opts);
  185. return unless scalar(@patches);
  186. my $applied = File::Spec->catfile($dir, "debian", "patches", ".dpkg-source-applied");
  187. open(APPLIED, '>', $applied) || syserr(_g("cannot write %s"), $applied);
  188. print APPLIED "# During $opts{'usage'}\n";
  189. my $timestamp = fs_time($applied);
  190. foreach my $patch ($self->get_patches($dir, %opts)) {
  191. my $path = File::Spec->catfile($dir, "debian", "patches", $patch);
  192. info(_g("applying %s"), $patch) unless $opts{"skip_auto"};
  193. my $patch_obj = Dpkg::Source::Patch->new(filename => $path);
  194. $patch_obj->apply($dir, force_timestamp => 1,
  195. timestamp => $timestamp,
  196. add_options => [ '-E' ]);
  197. print APPLIED "$patch\n";
  198. }
  199. close(APPLIED);
  200. }
  201. sub unapply_patches {
  202. my ($self, $dir, %opts) = @_;
  203. my @patches = reverse($self->get_patches($dir, %opts));
  204. return unless scalar(@patches);
  205. my $applied = File::Spec->catfile($dir, "debian", "patches", ".dpkg-source-applied");
  206. my $timestamp = fs_time($applied);
  207. foreach my $patch (@patches) {
  208. my $path = File::Spec->catfile($dir, "debian", "patches", $patch);
  209. info(_g("unapplying %s"), $patch) unless $opts{"quiet"};
  210. my $patch_obj = Dpkg::Source::Patch->new(filename => $path);
  211. $patch_obj->apply($dir, force_timestamp => 1, verbose => 0,
  212. timestamp => $timestamp,
  213. add_options => [ '-E', '-R' ]);
  214. }
  215. unlink($applied);
  216. }
  217. sub can_build {
  218. my ($self, $dir) = @_;
  219. return 1 if $self->find_original_tarballs(include_supplementary => 0);
  220. return 1 if $self->{'options'}{'create_empty_orig'} and
  221. $self->find_original_tarballs(include_main => 0);
  222. return (0, _g("no orig.tar file found"));
  223. }
  224. sub before_build {
  225. my ($self, $dir) = @_;
  226. $self->check_patches_applied($dir) if $self->{'options'}{'preparation'};
  227. }
  228. sub after_build {
  229. my ($self, $dir) = @_;
  230. my $applied = File::Spec->catfile($dir, "debian", "patches", ".dpkg-source-applied");
  231. my $reason = "";
  232. if (-e $applied) {
  233. open(APPLIED, "<", $applied) || syserr(_g("cannot read %s"), $applied);
  234. $reason = <APPLIED>;
  235. close(APPLIED);
  236. }
  237. if ($reason =~ /^# During preparation/ or
  238. $self->{'options'}{'unapply_patches'}) {
  239. $self->unapply_patches($dir);
  240. }
  241. }
  242. sub prepare_build {
  243. my ($self, $dir) = @_;
  244. $self->{'diff_options'} = {
  245. diff_ignore_regexp => $self->{'options'}{'diff_ignore_regexp'},
  246. include_removal => $self->{'options'}{'include_removal'},
  247. include_timestamp => $self->{'options'}{'include_timestamp'},
  248. use_dev_null => 1,
  249. };
  250. push @{$self->{'options'}{'tar_ignore'}}, "debian/patches/.dpkg-source-applied";
  251. $self->check_patches_applied($dir) if $self->{'options'}{'preparation'};
  252. if ($self->{'options'}{'create_empty_orig'} and
  253. not $self->find_original_tarballs(include_supplementary => 0))
  254. {
  255. # No main orig.tar, create a dummy one
  256. my $filename = $self->get_basename() . ".orig.tar." .
  257. $self->{'options'}{'comp_ext'};
  258. my $tar = Dpkg::Source::Archive->new(filename => $filename);
  259. $tar->create();
  260. $tar->finish();
  261. }
  262. }
  263. sub check_patches_applied {
  264. my ($self, $dir) = @_;
  265. my $applied = File::Spec->catfile($dir, "debian", "patches", ".dpkg-source-applied");
  266. unless (-e $applied) {
  267. info(_g("patches are not applied, applying them now"));
  268. $self->apply_patches($dir, usage => 'preparation');
  269. }
  270. }
  271. sub do_build {
  272. my ($self, $dir) = @_;
  273. my ($dirname, $updir) = fileparse($dir);
  274. my @argv = @{$self->{'options'}{'ARGV'}};
  275. if (scalar(@argv)) {
  276. usageerr(_g("-b takes only one parameter with format `%s'"),
  277. $self->{'fields'}{'Format'});
  278. }
  279. $self->prepare_build($dir);
  280. my $include_binaries = $self->{'options'}{'include_binaries'};
  281. my @tar_ignore = map { "--exclude=$_" } @{$self->{'options'}{'tar_ignore'}};
  282. my $sourcepackage = $self->{'fields'}{'Source'};
  283. my $basenamerev = $self->get_basename(1);
  284. my $basename = $self->get_basename();
  285. my $basedirname = $basename;
  286. $basedirname =~ s/_/-/;
  287. # Identify original tarballs
  288. my ($tarfile, %origtar);
  289. my @origtarballs;
  290. foreach (sort $self->find_original_tarballs()) {
  291. if (/\.orig\.tar\.$compression_re_file_ext$/) {
  292. if (defined($tarfile)) {
  293. error(_g("several orig.tar files found (%s and %s) but only " .
  294. "one is allowed"), $tarfile, $_);
  295. }
  296. $tarfile = $_;
  297. push @origtarballs, $_;
  298. $self->add_file($_);
  299. } elsif (/\.orig-([[:alnum:]-]+)\.tar\.$compression_re_file_ext$/) {
  300. $origtar{$1} = $_;
  301. push @origtarballs, $_;
  302. $self->add_file($_);
  303. }
  304. }
  305. error(_g("no orig.tar file found")) unless $tarfile;
  306. info(_g("building %s using existing %s"),
  307. $sourcepackage, "@origtarballs");
  308. # Unpack a second copy for comparison
  309. my $tmp = tempdir("$dirname.orig.XXXXXX", DIR => $updir);
  310. push @Dpkg::Exit::handlers, sub { erasedir($tmp) };
  311. # Extract main tarball
  312. my $tar = Dpkg::Source::Archive->new(filename => $tarfile);
  313. $tar->extract($tmp);
  314. # Extract additional orig tarballs
  315. foreach my $subdir (keys %origtar) {
  316. my $file = $origtar{$subdir};
  317. $tar = Dpkg::Source::Archive->new(filename => $file);
  318. $tar->extract("$tmp/$subdir");
  319. }
  320. # Copy over the debian directory
  321. erasedir("$tmp/debian");
  322. system("cp", "-a", "--", "$dir/debian", "$tmp/");
  323. subprocerr(_g("copy of the debian directory")) if $?;
  324. # Apply all patches except the last automatic one
  325. $self->apply_patches($tmp, skip_auto => 1, usage => 'build');
  326. # Prepare handling of binary files
  327. my %auth_bin_files;
  328. my $incbin_file = File::Spec->catfile($dir, "debian", "source", "include-binaries");
  329. if (-f $incbin_file) {
  330. open(INC, "<", $incbin_file) || syserr(_g("cannot read %s"), $incbin_file);
  331. while(defined($_ = <INC>)) {
  332. chomp; s/^\s*//; s/\s*$//;
  333. next if /^#/ or /^$/;
  334. $auth_bin_files{$_} = 1;
  335. }
  336. close(INC);
  337. }
  338. my @binary_files;
  339. my $handle_binary = sub {
  340. my ($self, $old, $new) = @_;
  341. my $relfn = File::Spec->abs2rel($new, $dir);
  342. # Include binaries if they are whitelisted or if
  343. # --include-binaries has been given
  344. if ($include_binaries or $auth_bin_files{$relfn}) {
  345. push @binary_files, $relfn;
  346. } else {
  347. errormsg(_g("cannot represent change to %s: %s"), $new,
  348. _g("binary file contents changed"));
  349. errormsg(_g("add %s in debian/source/include-binaries if you want" .
  350. " to store the modified binary in the debian tarball"),
  351. $relfn);
  352. $self->register_error();
  353. }
  354. };
  355. # Check if the debian directory contains unwanted binary files
  356. my $unwanted_binaries = 0;
  357. my $check_binary = sub {
  358. my $fn = File::Spec->abs2rel($_, $dir);
  359. if (-f $_ and is_binary($_)) {
  360. if ($include_binaries or $auth_bin_files{$fn}) {
  361. push @binary_files, $fn;
  362. } else {
  363. errormsg(_g("unwanted binary file: %s"), $fn);
  364. $unwanted_binaries++;
  365. }
  366. }
  367. };
  368. my $tar_ignore_glob = "{" . join(",",
  369. map {
  370. my $copy = $_;
  371. $copy =~ s/,/\\,/g;
  372. $copy;
  373. } @{$self->{'options'}{'tar_ignore'}}) . "}";
  374. my $filter_ignore = sub {
  375. # Filter out files that are not going to be included in the debian
  376. # tarball due to ignores.
  377. my %exclude;
  378. my $reldir = File::Spec->abs2rel($File::Find::dir, $dir);
  379. my $cwd = getcwd();
  380. # Apply the pattern both from the top dir and from the inspected dir
  381. chdir($dir) || syserr(_g("unable to chdir to `%s'"), $dir);
  382. $exclude{$_} = 1 foreach glob($tar_ignore_glob);
  383. chdir($cwd) || syserr(_g("unable to chdir to `%s'"), $cwd);
  384. chdir($File::Find::dir) ||
  385. syserr(_g("unable to chdir to `%s'"), $File::Find::dir);
  386. $exclude{$_} = 1 foreach glob($tar_ignore_glob);
  387. chdir($cwd) || syserr(_g("unable to chdir to `%s'"), $cwd);
  388. my @result;
  389. foreach my $fn (@_) {
  390. unless (exists $exclude{$fn} or exists $exclude{"$reldir/$fn"}) {
  391. push @result, $fn;
  392. }
  393. }
  394. return @result;
  395. };
  396. find({ wanted => $check_binary, preprocess => $filter_ignore,
  397. no_chdir => 1 }, File::Spec->catdir($dir, "debian"));
  398. error(P_("detected %d unwanted binary file (add it in " .
  399. "debian/source/include-binaries to allow its inclusion).",
  400. "detected %d unwanted binary files (add them in " .
  401. "debian/source/include-binaries to allow their inclusion).",
  402. $unwanted_binaries), $unwanted_binaries)
  403. if $unwanted_binaries;
  404. # Create a patch
  405. my $autopatch = File::Spec->catfile($dir, "debian", "patches",
  406. $self->get_autopatch_name());
  407. my ($difffh, $tmpdiff) = tempfile("$basenamerev.diff.XXXXXX",
  408. DIR => $updir, UNLINK => 0);
  409. push @Dpkg::Exit::handlers, sub { unlink($tmpdiff) };
  410. my $diff = Dpkg::Source::Patch->new(filename => $tmpdiff,
  411. compression => "none");
  412. $diff->create();
  413. $diff->set_header($self->get_patch_header($dir, $autopatch));
  414. $diff->add_diff_directory($tmp, $dir, basedirname => $basedirname,
  415. %{$self->{'diff_options'}}, handle_binary_func => $handle_binary,
  416. order_from => $autopatch);
  417. error(_g("unrepresentable changes to source")) if not $diff->finish();
  418. # The previous auto-patch must be removed, it has not been used and it
  419. # will be recreated if it's still needed
  420. if (-e $autopatch) {
  421. unlink($autopatch) || syserr(_g("cannot remove %s"), $autopatch);
  422. }
  423. # Install the diff as the new autopatch
  424. if (not -s $tmpdiff) {
  425. unlink($tmpdiff) || syserr(_g("cannot remove %s"), $tmpdiff);
  426. } else {
  427. mkpath(File::Spec->catdir($dir, "debian", "patches"));
  428. info(_g("local changes stored in %s, the modified files are:"), $autopatch);
  429. my $analysis = $diff->analyze($dir, verbose => 0);
  430. foreach my $fn (sort keys %{$analysis->{'filepatched'}}) {
  431. print " $fn\n";
  432. }
  433. rename($tmpdiff, $autopatch) ||
  434. syserr(_g("cannot rename %s to %s"), $tmpdiff, $autopatch);
  435. chmod(0666 & ~ umask(), $autopatch) ||
  436. syserr(_g("unable to change permission of `%s'"), $autopatch);
  437. }
  438. $self->register_autopatch($dir);
  439. if (-e $autopatch and $self->{'options'}{'abort_on_upstream_changes'}) {
  440. error(_g("aborting due to --abort-on-upstream-changes"));
  441. }
  442. rmdir(File::Spec->catdir($dir, "debian", "patches")); # No check on purpose
  443. pop @Dpkg::Exit::handlers;
  444. # Remove the temporary directory
  445. erasedir($tmp);
  446. pop @Dpkg::Exit::handlers;
  447. # Update debian/source/include-binaries if needed
  448. if (scalar(@binary_files) and $include_binaries) {
  449. mkpath(File::Spec->catdir($dir, "debian", "source"));
  450. open(INC, ">>", $incbin_file) || syserr(_g("cannot write %s"), $incbin_file);
  451. foreach my $binary (@binary_files) {
  452. unless ($auth_bin_files{$binary}) {
  453. print INC "$binary\n";
  454. info(_g("adding %s to %s"), $binary, "debian/source/include-binaries");
  455. }
  456. }
  457. close(INC);
  458. }
  459. # Create the debian.tar
  460. my $debianfile = "$basenamerev.debian.tar." . $self->{'options'}{'comp_ext'};
  461. info(_g("building %s in %s"), $sourcepackage, $debianfile);
  462. $tar = Dpkg::Source::Archive->new(filename => $debianfile);
  463. $tar->create(options => \@tar_ignore, 'chdir' => $dir);
  464. $tar->add_directory("debian");
  465. foreach my $binary (@binary_files) {
  466. $tar->add_file($binary) unless $binary =~ m{^debian/};
  467. }
  468. $tar->finish();
  469. $self->add_file($debianfile);
  470. }
  471. sub get_patch_header {
  472. my ($self, $dir, $previous) = @_;
  473. my $ph = File::Spec->catfile($dir, "debian", "source", "local-patch-header");
  474. unless (-f $ph) {
  475. $ph = File::Spec->catfile($dir, "debian", "source", "patch-header");
  476. }
  477. my $text;
  478. if (-f $ph) {
  479. open(PH, "<", $ph) || syserr(_g("cannot read %s"), $ph);
  480. $text = join("", <PH>);
  481. close(PH);
  482. return $text;
  483. }
  484. return "Description: Undocumented upstream changes
  485. This patch has been created by dpkg-source during the package build
  486. but it might have accumulated changes from several uploads. Please
  487. check the changelog to (hopefully) learn more on those changes.\n\n";
  488. }
  489. sub register_autopatch {
  490. my ($self, $dir) = @_;
  491. my $autopatch = File::Spec->catfile($dir, "debian", "patches",
  492. $self->get_autopatch_name());
  493. if (-e $autopatch) {
  494. my $applied = File::Spec->catfile($dir, "debian", "patches", ".dpkg-source-applied");
  495. open(APPLIED, '>>', $applied) || syserr(_g("cannot write %s"), $applied);
  496. print APPLIED ($self->get_autopatch_name() . "\n");
  497. close(APPLIED);
  498. }
  499. }
  500. # vim:et:sw=4:ts=8
  501. 1;