Debian Codegraph @

debian/gen-patchlevel

raw
1 #!/bin/sh
2 set -e
3
4 # Copyright 2011 Niko Tyni
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the same terms as Perl itself.
8 #
9 # Given a list of patches in debian/patches, write out one line
10 # per patch containing the patch description, bug pointers and
11 # upstream commit information where available.
12 #
13 # The output format is designed to be included into Perl's patchlevel.h,
14 # which eventually controls what 'perl -V' prints.
15 #
16 # When called with the '-d' option, outputs the timestamp of the newest
17 # patch, for the purposes of getting $patchlevel_date in perlbug right
18
19 prefix="DEBPKG:"
20 version=""
21 patchdir=debian/patches
22 showdate=false
23
24 while getopts p:v:d f
25 do
26 case $f in
27 p) prefix=$OPTARG;;
28 v) version=$OPTARG;;
29 d) showdate=true
30 esac
31 done
32 shift `expr $OPTIND - 1`
33
34 in=${1:-$patchdir/series}
35
36 if [ -n "$version" ]; then
37 version=" for $version"
38 fi
39
40 newest_mtime=0
41 while read patch strip
42 do
43 if $showdate; then
44 mtime=$(stat --format='%Y' $patchdir/$patch)
45 if [ "$mtime" -gt "$newest_mtime" ]; then
46 newest_mtime="$mtime"
47 fi
48 continue
49 fi
50
51 patchname=$(echo $patch | sed 's/\.diff$//')
52 < $patchdir/$patch sed -e '/^Subject:/ { N; s/\n / / }' | sed -n -e '
53
54 # massage the patch headers
55 s|^Bug: .*https\?://rt\.perl\.org/.*id=\(.*\).*|[RT #\1]|; tprepend;
56 s|^Bug: .*https\?://rt\.cpan\.org/.*id=\(.*\).*|[rt.cpan.org #\1]|; tprepend;
57 s|^Bug: .*https\?://github\.com/Perl/perl5/issues/\(.*\)|[GH #\1]|; tprepend;
58 s|^Bug-Debian: [^0-9]*\([0-9]\{5,\}\)|https://bugs.debian.org/\1|; tprepend;
59 s/^\(Subject\|Description\): //; tappend;
60 s|^Origin: .*https\?://perl5\.git\.perl\.org/perl\.git/commit\(diff\)\?/\(.......\).*|[\2]|; tprepend;
61 s|^Origin: .*https\?://github\.com/Perl/perl5/commit\(diff\)\?/\(.......\).*|[\2]|; tprepend;
62
63 # post-process at the end of input
64 $ { x;
65 # include the version number in the patchlevel.h description (if available)
66 s/List packaged patches/&'"${version}"'/;
67
68 # escape any backslashes and double quotes
69 s|\\|\\\\|g; s|"|\\"|g;
70
71 # add a prefix
72 s|^|\t,"'"$prefix$patchname"' - |;
73 # newlines away
74 s/\n/ /g; s/ */ /g;
75 # add a suffix
76 s/ *$/"/; p
77 };
78 # stop all processing
79 d;
80 # label: append to the hold space
81 :append H; d;
82 # label: prepend to the hold space
83 :prepend x; H; d;
84 '
85 done < $in
86 if $showdate; then
87 echo $newest_mtime
88 fi