Skip to content

Commit

Permalink
Release automation revamp
Browse files Browse the repository at this point in the history
  • Loading branch information
iskunk committed Sep 11, 2024
1 parent d2da7c2 commit 5198c5b
Show file tree
Hide file tree
Showing 6 changed files with 756 additions and 146 deletions.
118 changes: 118 additions & 0 deletions .github/workflows/convert.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
#!/bin/bash
# convert.sh
#
# Perform the conversion from Chromium to ungoogled-chromium
#

set -e

test -n "$DOWNLOAD_DIR"
test -n "$OUTPUT_DIR"
test -n "$STATE_DIR"
test -n "$WORK_DIR"
test -d "$GITHUB_WORKSPACE"

uc_git=$GITHUB_WORKSPACE/ungoogled-chromium

wrap=

tab=' '

run()
{
echo "+ $*"
env "$@"
echo ' '
}

do_conversion()
{
local codename="$1" deb_version="$2" uc_tag="$3"
local conv_dir=$WORK_DIR/convert/$codename

echo "Using ungoogled-chromium Git tag $uc_tag ..."
(cd $uc_git && run git switch --detach $uc_tag)

rm -rf $conv_dir
mkdir -p $conv_dir

echo 'Unpacking source package ...'
run dpkg-source \
--no-copy \
--require-valid-signature \
--skip-patches \
--extract \
$DOWNLOAD_DIR/chromium_$deb_version.dsc \
$conv_dir/chromium-src

local uc_rev="${uc_tag##*-}"
local ucd_convert=$GITHUB_WORKSPACE/convert

local ups_version="${deb_version%-*}"

# NOTE: Nested output groups are not yet supported
# https://github.com/actions/toolkit/issues/1001
#echo '::group::Ungoogling Chromium'

(cd $conv_dir && run $wrap make -f $ucd_convert/Makefile \
convert ug-tarball clean \
VERSION=$ups_version \
ORIG_SOURCE=chromium-src \
ORIG_TARBALL=$DOWNLOAD_DIR/chromium_$ups_version.orig.tar.xz \
UNGOOGLED=$uc_git \
DEBIAN_CONVERT=$ucd_convert \
ADD_VERSION_SUFFIX=.$uc_rev \
DISTRIBUTION= \
INPLACE=1
)

#echo '::endgroup::'

echo 'Building new source package ...'
(cd $conv_dir && run time -p dpkg-source --no-preparation --no-generate-diff --build chromium-src 2>&1)

local uc_version=$deb_version.$uc_rev

local files=
files="$codename/ungoogled-chromium_$uc_version.dsc"
files+=" $codename/ungoogled-chromium_$uc_version.debian.tar.xz"
ofiles=" $codename/ungoogled-chromium_$ups_version.orig.tar.xz"

mkdir -p $OUTPUT_DIR/$codename

(cd $conv_dir/..
ls -LUl $files $ofiles
echo ' '; echo 'SHA-256 sums:'
sha256sum $files $ofiles
cp -np $files $OUTPUT_DIR/$codename/
)

# Note: Do NOT save the .orig tarball as an artifact!
# It's enormous, and we do not modify it.

rm -rf $conv_dir
}

for todo in $WORK_DIR/todo.*.chromium.txt
do
test -f "$todo" || continue
IFS="$tab" read codename deb_version uc_tag < $todo

echo "::group::Build DEB($codename, $deb_version) + UC($uc_tag)"

do_conversion "$codename" "$deb_version" "$uc_tag"

echo '::endgroup::'

case "$codename" in
debian-sid | debian-unstable)
# do Ubuntu conversions here if desired
;;
esac

cat $todo >> $STATE_DIR/done.chromium.txt
rm -f $todo
echo ' '
done

# end convert.sh
99 changes: 99 additions & 0 deletions .github/workflows/dpkg-source-build.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
This patch greatly speeds up the "dpkg-source --build" operation when the
--no-generate-diff option is used. It has been submitted to the upstream
project, but discussion on it remains unresolved:

https://lists.debian.org/debian-dpkg/2023/09/msg00013.html

This patch specifically targets the version of dpkg in Ubuntu 22.04.

--- /usr/share/perl5/Dpkg/Source/Package/V2.pm.orig
+++ /usr/share/perl5/Dpkg/Source/Package/V2.pm
@@ -60,6 +60,7 @@
$self->{options}{unapply_patches} //= 'auto';
$self->{options}{skip_debianization} //= 0;
$self->{options}{create_empty_orig} //= 0;
+ $self->{options}{generate_diff} //= 1;
$self->{options}{auto_commit} //= 0;
$self->{options}{ignore_bad_version} //= 0;
}
@@ -94,6 +95,10 @@
help => N_('create an empty original tarball if missing'),
when => 'build',
}, {
+ name => '--no-generate-diff',
+ help => N_('do not generate diff against upstream sources'),
+ when => 'build',
+ }, {
name => '--abort-on-upstream-changes',
help => N_('abort if generated diff has upstream files changes'),
when => 'build',
@@ -145,6 +150,9 @@
} elsif ($opt eq '--create-empty-orig') {
$self->{options}{create_empty_orig} = 1;
return 1;
+ } elsif ($opt eq '--no-generate-diff') {
+ $self->{options}{generate_diff} = 0;
+ return 1;
} elsif ($opt eq '--abort-on-upstream-changes') {
$self->{options}{auto_commit} = 0;
return 1;
@@ -448,6 +456,8 @@
}
}

+ return if !$opts{do_diff};
+
# Unpack a second copy for comparison
my $tmp = tempdir("$dirname.orig.XXXXXX", DIR => $updir);
push_exit_handler(sub { erasedir($tmp) });
@@ -516,6 +526,21 @@
usageerr(g_("-b takes only one parameter with format '%s'"),
$self->{fields}{'Format'});
}
+ if (!$self->{options}{generate_diff} &&
+ ($self->{options}{include_removal} ||
+ $self->{options}{include_timestamp} ||
+ $self->{options}{include_binaries} ||
+ $self->{options}{create_empty_orig} ||
+ $self->{options}{auto_commit})) {
+ my @incompat = (
+ "--include-removal",
+ "--include-timestamp",
+ "--include-binaries",
+ "--create-empty-orig",
+ "--auto-commit"
+ );
+ usageerr(g_("--no-generate-diff is incompatible with the following options: %s"), join(", ", @incompat));
+ }
$self->prepare_build($dir);

my $include_binaries = $self->{options}{include_binaries};
@@ -555,8 +580,9 @@
header_from => $autopatch,
handle_binary => $handle_binary,
skip_auto => $self->{options}{auto_commit},
+ do_diff => $self->{options}{generate_diff},
usage => 'build');
- unless (-z $tmpdiff or $self->{options}{auto_commit}) {
+ unless (!$tmpdiff or -z $tmpdiff or $self->{options}{auto_commit}) {
info(g_('Hint: make sure the version in debian/changelog matches ' .
'the unpacked source tree'));
info(g_('you can integrate the local changes with %s'),
@@ -564,7 +590,7 @@
error(g_('aborting due to unexpected upstream changes, see %s'),
$tmpdiff);
}
- push_exit_handler(sub { unlink($tmpdiff) });
+ push_exit_handler(sub { !$tmpdiff or unlink($tmpdiff) });
$binaryfiles->update_debian_source_include_binaries() if $include_binaries;

# Install the diff as the new autopatch
@@ -576,7 +602,7 @@
$autopatch) if -e $autopatch;
rmdir(File::Spec->catdir($dir, 'debian', 'patches')); # No check on purpose
}
- unlink($tmpdiff) or syserr(g_('cannot remove %s'), $tmpdiff);
+ !$tmpdiff or unlink($tmpdiff) or syserr(g_('cannot remove %s'), $tmpdiff);
pop_exit_handler();

# Create the debian.tar
Loading

0 comments on commit 5198c5b

Please sign in to comment.