dpkg: replace static files for patches to track changes.
This commit is contained in:
parent
202f686415
commit
5934b87b60
4 changed files with 219 additions and 105 deletions
|
|
@ -1,100 +0,0 @@
|
||||||
# Copyright © 2008 Ian Jackson <ijackson@chiark.greenend.org.uk>
|
|
||||||
# Copyright © 2008 Canonical, Ltd.
|
|
||||||
# written by Colin Watson <cjwatson@ubuntu.com>
|
|
||||||
# Copyright © 2008 James Westby <jw+debian@jameswestby.net>
|
|
||||||
# Copyright © 2009 Raphaël Hertzog <hertzog@debian.org>
|
|
||||||
# Copyright © 2022 Ruben Rodriguez <ruben@trisquel.org>
|
|
||||||
#
|
|
||||||
# This program is free software; you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation; either version 2 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
package Dpkg::Vendor::Trisquel;
|
|
||||||
|
|
||||||
use strict;
|
|
||||||
use warnings;
|
|
||||||
|
|
||||||
our $VERSION = '0.01';
|
|
||||||
|
|
||||||
use Dpkg::ErrorHandling;
|
|
||||||
use Dpkg::Gettext;
|
|
||||||
use Dpkg::Control::Types;
|
|
||||||
|
|
||||||
use parent qw(Dpkg::Vendor::Debian);
|
|
||||||
|
|
||||||
=encoding utf8
|
|
||||||
|
|
||||||
=head1 NAME
|
|
||||||
|
|
||||||
Dpkg::Vendor::Trisquel - Trisquel vendor class
|
|
||||||
|
|
||||||
=head1 DESCRIPTION
|
|
||||||
|
|
||||||
This vendor class customizes the behaviour of dpkg scripts for Trisquel
|
|
||||||
specific behavior and policies.
|
|
||||||
|
|
||||||
=cut
|
|
||||||
|
|
||||||
sub run_hook {
|
|
||||||
my ($self, $hook, @params) = @_;
|
|
||||||
|
|
||||||
if ($hook eq 'package-keyrings') {
|
|
||||||
return ($self->SUPER::run_hook($hook),
|
|
||||||
'/usr/share/keyrings/trisquel-archive-keyring.gpg');
|
|
||||||
} elsif ($hook eq 'archive-keyrings') {
|
|
||||||
return ($self->SUPER::run_hook($hook),
|
|
||||||
'/usr/share/keyrings/trisquel-archive-keyring.gpg');
|
|
||||||
} elsif ($hook eq 'archive-keyrings-historic') {
|
|
||||||
return ($self->SUPER::run_hook($hook),
|
|
||||||
'/usr/share/keyrings/trisquel-archive-removed-keys.gpg');
|
|
||||||
} elsif ($hook eq 'update-buildflags') {
|
|
||||||
my $flags = shift @params;
|
|
||||||
|
|
||||||
# Run the Debian hook to add hardening flags
|
|
||||||
$self->SUPER::run_hook($hook, $flags);
|
|
||||||
|
|
||||||
require Dpkg::BuildOptions;
|
|
||||||
|
|
||||||
my $build_opts = Dpkg::BuildOptions->new();
|
|
||||||
|
|
||||||
if (!$build_opts->has('noopt')) {
|
|
||||||
require Dpkg::Arch;
|
|
||||||
|
|
||||||
my $arch = Dpkg::Arch::get_host_arch();
|
|
||||||
if (Dpkg::Arch::debarch_eq($arch, 'ppc64el')) {
|
|
||||||
for my $flag (qw(CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS GCJFLAGS
|
|
||||||
FFLAGS FCFLAGS)) {
|
|
||||||
my $value = $flags->get($flag);
|
|
||||||
$value =~ s/-O[0-9]/-O3/;
|
|
||||||
$flags->set($flag, $value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
# Per https://wiki.ubuntu.com/DistCompilerFlags
|
|
||||||
$flags->prepend('LDFLAGS', '-Wl,-Bsymbolic-functions');
|
|
||||||
} else {
|
|
||||||
return $self->SUPER::run_hook($hook, @params);
|
|
||||||
}
|
|
||||||
|
|
||||||
# Default return value for unknown/unimplemented hooks
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
=head1 CHANGES
|
|
||||||
|
|
||||||
=head2 Version 0.xx
|
|
||||||
|
|
||||||
This is a private module.
|
|
||||||
|
|
||||||
=cut
|
|
||||||
|
|
||||||
1;
|
|
||||||
|
|
@ -0,0 +1,56 @@
|
||||||
|
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
|
||||||
|
index 8d39d24..c69d88d 100644
|
||||||
|
--- a/scripts/Makefile.am
|
||||||
|
+++ b/scripts/Makefile.am
|
||||||
|
@@ -89,6 +89,7 @@ nobase_dist_perllib_DATA = \
|
||||||
|
Dpkg/Vendor/Default.pm \
|
||||||
|
Dpkg/Vendor/Devuan.pm \
|
||||||
|
Dpkg/Vendor/Ubuntu.pm \
|
||||||
|
+ Dpkg/Vendor/Trisquel.pm \
|
||||||
|
Dpkg/Version.pm \
|
||||||
|
Dpkg.pm \
|
||||||
|
# EOL
|
||||||
|
@@ -237,6 +238,7 @@ test_scripts = \
|
||||||
|
t/Dpkg_BuildEnv.t \
|
||||||
|
t/Dpkg_BuildFlags.t \
|
||||||
|
t/Dpkg_BuildFlags_Ubuntu.t \
|
||||||
|
+ t/Dpkg_BuildFlags_Trisquel.t
|
||||||
|
t/Dpkg_BuildInfo.t \
|
||||||
|
t/Dpkg_BuildOptions.t \
|
||||||
|
t/Dpkg_BuildProfiles.t \
|
||||||
|
@@ -258,6 +260,7 @@ test_scripts = \
|
||||||
|
t/Dpkg_Vendor.t \
|
||||||
|
t/Dpkg_Changelog.t \
|
||||||
|
t/Dpkg_Changelog_Ubuntu.t \
|
||||||
|
+ t/Dpkg_Changelog_Trisquel.t \
|
||||||
|
t/Dpkg_Control_Fields.t \
|
||||||
|
t/Dpkg_Control.t \
|
||||||
|
t/Dpkg_Control_Tests.t \
|
||||||
|
diff --git a/scripts/Makefile.in b/scripts/Makefile.in
|
||||||
|
index 8b0a61f..74a035f 100644
|
||||||
|
--- a/scripts/Makefile.in
|
||||||
|
+++ b/scripts/Makefile.in
|
||||||
|
@@ -548,6 +548,7 @@ nobase_dist_perllib_DATA = \
|
||||||
|
Dpkg/Vendor/Default.pm \
|
||||||
|
Dpkg/Vendor/Devuan.pm \
|
||||||
|
Dpkg/Vendor/Ubuntu.pm \
|
||||||
|
+ Dpkg/Vendor/Trisquel.pm \
|
||||||
|
Dpkg/Version.pm \
|
||||||
|
Dpkg.pm \
|
||||||
|
# EOL
|
||||||
|
@@ -644,6 +645,7 @@ test_scripts = \
|
||||||
|
t/Dpkg_BuildEnv.t \
|
||||||
|
t/Dpkg_BuildFlags.t \
|
||||||
|
t/Dpkg_BuildFlags_Ubuntu.t \
|
||||||
|
+ t/Dpkg_BuildFlags_Trisquel.t \
|
||||||
|
t/Dpkg_BuildInfo.t \
|
||||||
|
t/Dpkg_BuildOptions.t \
|
||||||
|
t/Dpkg_BuildProfiles.t \
|
||||||
|
@@ -665,6 +667,7 @@ test_scripts = \
|
||||||
|
t/Dpkg_Vendor.t \
|
||||||
|
t/Dpkg_Changelog.t \
|
||||||
|
t/Dpkg_Changelog_Ubuntu.t \
|
||||||
|
+ t/Dpkg_Changelog_Trisquel.t \
|
||||||
|
t/Dpkg_Control_Fields.t \
|
||||||
|
t/Dpkg_Control.t \
|
||||||
|
t/Dpkg_Control_Tests.t \
|
||||||
154
helpers/DATA/dpkg/patch-Trisquel_pm-from-Ubuntu_pm.patch
Normal file
154
helpers/DATA/dpkg/patch-Trisquel_pm-from-Ubuntu_pm.patch
Normal file
|
|
@ -0,0 +1,154 @@
|
||||||
|
diff --git a/scripts/Dpkg/Vendor/Trisquel.pm b/scripts/Dpkg/Vendor/Trisquel.pm
|
||||||
|
index 383d5cc..8b65c43 100644
|
||||||
|
--- a/scripts/Dpkg/Vendor/Trisquel.pm
|
||||||
|
+++ b/scripts/Dpkg/Vendor/Trisquel.pm
|
||||||
|
@@ -3,6 +3,8 @@
|
||||||
|
# written by Colin Watson <cjwatson@ubuntu.com>
|
||||||
|
# Copyright © 2008 James Westby <jw+debian@jameswestby.net>
|
||||||
|
# Copyright © 2009 Raphaël Hertzog <hertzog@debian.org>
|
||||||
|
+# Copyright © 2022 Ruben Rodriguez <ruben@trisquel.org>
|
||||||
|
+# Copyright © 2024 Luis Guzman <ark@switnet.org>
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@@ -21,18 +23,18 @@
|
||||||
|
|
||||||
|
=head1 NAME
|
||||||
|
|
||||||
|
-Dpkg::Vendor::Ubuntu - Ubuntu vendor class
|
||||||
|
+Dpkg::Vendor::Trisquel - Trisquel vendor class
|
||||||
|
|
||||||
|
=head1 DESCRIPTION
|
||||||
|
|
||||||
|
-This vendor class customizes the behavior of dpkg scripts for Ubuntu
|
||||||
|
+This vendor class customizes the behavior of dpkg scripts for Trisquel
|
||||||
|
specific behavior and policies.
|
||||||
|
|
||||||
|
B<Note>: This is a private module, its API can change at any time.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
-package Dpkg::Vendor::Ubuntu 0.01;
|
||||||
|
+package Dpkg::Vendor::Trisquel 0.01;
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
@@ -48,71 +50,20 @@ use parent qw(Dpkg::Vendor::Debian);
|
||||||
|
sub run_hook {
|
||||||
|
my ($self, $hook, @params) = @_;
|
||||||
|
|
||||||
|
- if ($hook eq 'before-source-build') {
|
||||||
|
- my $src = shift @params;
|
||||||
|
- my $fields = $src->{fields};
|
||||||
|
-
|
||||||
|
- # check that Maintainer/XSBC-Original-Maintainer comply to
|
||||||
|
- # https://wiki.ubuntu.com/DebianMaintainerField
|
||||||
|
- if (defined($fields->{'Version'}) and defined($fields->{'Maintainer'}) and
|
||||||
|
- $fields->{'Version'} =~ /ubuntu/) {
|
||||||
|
- if ($fields->{'Maintainer'} !~ /(?:ubuntu|canonical)/i) {
|
||||||
|
- if (length $ENV{DEBEMAIL} and $ENV{DEBEMAIL} =~ /\@(?:ubuntu|canonical)\.com/) {
|
||||||
|
- error(g_('Version number suggests Ubuntu changes, but Maintainer: does not have Ubuntu address'));
|
||||||
|
- } else {
|
||||||
|
- warning(g_('Version number suggests Ubuntu changes, but Maintainer: does not have Ubuntu address'));
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
- unless ($fields->{'Original-Maintainer'}) {
|
||||||
|
- warning(g_('Version number suggests Ubuntu changes, but there is no XSBC-Original-Maintainer field'));
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
- } elsif ($hook eq 'package-keyrings') {
|
||||||
|
+ if ($hook eq 'package-keyrings') {
|
||||||
|
return ($self->SUPER::run_hook($hook),
|
||||||
|
- '/usr/share/keyrings/ubuntu-archive-keyring.gpg');
|
||||||
|
+ '/usr/share/keyrings/trisquel-archive-keyring.gpg');
|
||||||
|
} elsif ($hook eq 'archive-keyrings') {
|
||||||
|
return ($self->SUPER::run_hook($hook),
|
||||||
|
- '/usr/share/keyrings/ubuntu-archive-keyring.gpg');
|
||||||
|
+ '/usr/share/keyrings/trisquel-archive-keyring.gpg');
|
||||||
|
} elsif ($hook eq 'archive-keyrings-historic') {
|
||||||
|
return ($self->SUPER::run_hook($hook),
|
||||||
|
- '/usr/share/keyrings/ubuntu-archive-removed-keys.gpg');
|
||||||
|
- } elsif ($hook eq 'register-custom-fields') {
|
||||||
|
- my @field_ops = $self->SUPER::run_hook($hook);
|
||||||
|
- push @field_ops, [
|
||||||
|
- 'register', 'Launchpad-Bugs-Fixed',
|
||||||
|
- CTRL_FILE_CHANGES | CTRL_CHANGELOG,
|
||||||
|
- ], [
|
||||||
|
- 'insert_after', CTRL_FILE_CHANGES, 'Closes', 'Launchpad-Bugs-Fixed',
|
||||||
|
- ], [
|
||||||
|
- 'insert_after', CTRL_CHANGELOG, 'Closes', 'Launchpad-Bugs-Fixed',
|
||||||
|
- ];
|
||||||
|
- return @field_ops;
|
||||||
|
- } elsif ($hook eq 'post-process-changelog-entry') {
|
||||||
|
- my $fields = shift @params;
|
||||||
|
-
|
||||||
|
- # Add Launchpad-Bugs-Fixed field
|
||||||
|
- my $bugs = find_launchpad_closes($fields->{'Changes'} // '');
|
||||||
|
- if (scalar(@$bugs)) {
|
||||||
|
- $fields->{'Launchpad-Bugs-Fixed'} = join(' ', @$bugs);
|
||||||
|
- }
|
||||||
|
- } elsif ($hook eq 'update-buildopts') {
|
||||||
|
- my $build_opts = shift @params;
|
||||||
|
- require Dpkg::Arch;
|
||||||
|
- my $arch = Dpkg::Arch::get_host_arch();
|
||||||
|
- if (Dpkg::Arch::debarch_eq($arch, 'riscv64')) {
|
||||||
|
- $build_opts->set('nocheck', 1, 'riscv64');
|
||||||
|
- }
|
||||||
|
- } elsif ($hook eq 'update-buildprofiles') {
|
||||||
|
- my $build_profiles_ref = shift @params;
|
||||||
|
- unless(grep $_ =~ /^!?noudeb$/, @$build_profiles_ref) {
|
||||||
|
- unshift(@$build_profiles_ref, 'noudeb');
|
||||||
|
- } else {
|
||||||
|
- # Strip otherwise invalid profile name
|
||||||
|
- @$build_profiles_ref = grep { $_ ne "!noudeb" } @$build_profiles_ref;
|
||||||
|
- }
|
||||||
|
+ '/usr/share/keyrings/trisquel-archive-removed-keys.gpg');
|
||||||
|
} else {
|
||||||
|
return $self->SUPER::run_hook($hook, @params);
|
||||||
|
}
|
||||||
|
+ # Default return value for unknown/unimplemented hooks
|
||||||
|
+ return;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub _lto_disabled {
|
||||||
|
@@ -289,39 +240,11 @@ sub add_build_flags {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
-=head1 PUBLIC FUNCTIONS
|
||||||
|
-
|
||||||
|
-=over
|
||||||
|
-
|
||||||
|
-=item $bugs = Dpkg::Vendor::Ubuntu::find_launchpad_closes($changes)
|
||||||
|
-
|
||||||
|
-Takes one string as argument and finds "LP: #123456, #654321" statements,
|
||||||
|
-which are references to bugs on Launchpad. Returns all closed bug
|
||||||
|
-numbers in an array reference.
|
||||||
|
-
|
||||||
|
-=cut
|
||||||
|
-
|
||||||
|
-sub find_launchpad_closes {
|
||||||
|
- my $changes = shift;
|
||||||
|
- my %closes;
|
||||||
|
-
|
||||||
|
- while ($changes &&
|
||||||
|
- ($changes =~ /lp:\s+\#\d+(?:,\s*\#\d+)*/pig)) {
|
||||||
|
- $closes{$_} = 1 foreach (${^MATCH} =~ /\#?\s?(\d+)/g);
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- my @closes = sort { $a <=> $b } keys %closes;
|
||||||
|
-
|
||||||
|
- return \@closes;
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
-=back
|
||||||
|
-
|
||||||
|
=head1 CHANGES
|
||||||
|
|
||||||
|
=head2 Version 0.xx
|
||||||
|
|
||||||
|
-This is a semi-private module. Only documented functions are public.
|
||||||
|
+This is a private module.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
|
# Copyright (C) 2024 Luis Guzmán <ark@switnet.org>
|
||||||
# Copyright (C) 2012-2022 Ruben Rodriguez <ruben@trisquel.info>
|
# Copyright (C) 2012-2022 Ruben Rodriguez <ruben@trisquel.info>
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
|
@ -19,7 +20,7 @@
|
||||||
|
|
||||||
#STAGE-1-DEBOOTSTRAP
|
#STAGE-1-DEBOOTSTRAP
|
||||||
|
|
||||||
VERSION=4
|
VERSION=5
|
||||||
COMPONENT=main
|
COMPONENT=main
|
||||||
|
|
||||||
. ./config
|
. ./config
|
||||||
|
|
@ -34,11 +35,14 @@ EOF
|
||||||
cp scripts/t/Dpkg_BuildFlags_Ubuntu.t scripts/t/Dpkg_BuildFlags_Trisquel.t
|
cp scripts/t/Dpkg_BuildFlags_Ubuntu.t scripts/t/Dpkg_BuildFlags_Trisquel.t
|
||||||
cp scripts/t/Dpkg_Changelog_Ubuntu.t scripts/t/Dpkg_Changelog_Trisquel.t
|
cp scripts/t/Dpkg_Changelog_Ubuntu.t scripts/t/Dpkg_Changelog_Trisquel.t
|
||||||
sed 's/Ubuntu/Trisquel/g' -i scripts/t/Dpkg_BuildFlags_Trisquel.t
|
sed 's/Ubuntu/Trisquel/g' -i scripts/t/Dpkg_BuildFlags_Trisquel.t
|
||||||
cp $DATA/Trisquel.pm scripts/Dpkg/Vendor/Trisquel.pm
|
|
||||||
|
|
||||||
sed '/Ubuntu.pm/a\\tDpkg/Vendor/Trisquel.pm \\' -i scripts/Makefile.in scripts/Makefile.am
|
# Patch a copy from the Ubuntu.pm file to force track changes more often,
|
||||||
sed '/Dpkg_BuildFlags_Ubuntu.t/a\\tt/Dpkg_BuildFlags_Trisquel.t \\' -i scripts/Makefile.in scripts/Makefile.am
|
# and rebuild easier the original changes.
|
||||||
sed '/Dpkg_Changelog_Ubuntu.t/a\\tt/Dpkg_Changelog_Trisquel.t \\' -i scripts/Makefile.in scripts/Makefile.am
|
cp scripts/Dpkg/Vendor/{Ubuntu,Trisquel}.pm
|
||||||
|
patch_p1 $DATA/patch-Trisquel_pm-from-Ubuntu_pm.patch
|
||||||
|
|
||||||
|
# Use patch to track changes at Makefile.{in,am} files.
|
||||||
|
patch_p1 $DATA/patch-Makefile_in_am-to-add-trisquel-options.patch
|
||||||
|
|
||||||
# Trisquel.pm in now here, not at trisquel-base-data
|
# Trisquel.pm in now here, not at trisquel-base-data
|
||||||
sed '/Package: libdpkg-perl/,/^$/s/Depends:/Replaces: trisquel-base-data\nDepends:/' -i debian/control
|
sed '/Package: libdpkg-perl/,/^$/s/Depends:/Replaces: trisquel-base-data\nDepends:/' -i debian/control
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue