File: gen-patchlevel

package info (click to toggle)
perl 5.24.1-3+deb9u5
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 103,716 kB
  • sloc: perl: 559,611; ansic: 293,886; sh: 67,316; pascal: 7,632; cpp: 3,895; makefile: 2,436; xml: 2,410; yacc: 989; sed: 6; lisp: 1
file content (86 lines) | stat: -rwxr-xr-x 2,347 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/sh
set -e

# Copyright 2011 Niko Tyni
#
# This program is free software; you can redistribute it and/or modify
# it under the same terms as Perl itself.
#
# Given a list of patches in debian/patches, write out one line
# per patch containing the patch description, bug pointers and
# upstream commit information where available.
#
# The output format is designed to be included into Perl's patchlevel.h,
# which eventually controls what 'perl -V' prints.
#
# When called with the '-d' option, outputs the timestamp of the newest
# patch, for the purposes of getting $patchlevel_date in perlbug right

prefix="DEBPKG:"
version=""
patchdir=debian/patches
showdate=false

while getopts p:v:d f
do
    case $f in
    p) prefix=$OPTARG;;
    v) version=$OPTARG;;
    d) showdate=true
    esac
done
shift `expr $OPTIND - 1`

in=${1:-$patchdir/series}

if [ -n "$version" ]; then
    version=" for $version"
fi

newest_mtime=0
while read patch strip
do
    if $showdate; then
        mtime=$(stat --format='%Y' $patchdir/$patch)
        if [ "$mtime" -gt "$newest_mtime" ]; then
            newest_mtime="$mtime"
        fi
        continue
    fi

    patchname=$(echo $patch | sed 's/\.diff$//')
    < $patchdir/$patch sed -e '/^Subject:/ { N; s/\n / / }' | sed -n -e '

    # massage the patch headers
    s|^Bug: .*https\?://rt\.perl\.org/.*id=\(.*\).*|[perl #\1]|; tprepend;
    s|^Bug: .*https\?://rt\.cpan\.org/.*id=\(.*\).*|[rt.cpan.org #\1]|; tprepend;
    s|^Bug-Debian: [^0-9]*\([0-9]\{5,\}\)|https://bugs.debian.org/\1|; tprepend;
    s/^\(Subject\|Description\): //; tappend;
    s|^Origin: .*https\?://perl5\.git\.perl\.org/perl\.git/commit\(diff\)\?/\(.......\).*|[\2]|; tprepend;

    # post-process at the end of input
    $ { x;
        # include the version number in the patchlevel.h description (if available)
        s/List packaged patches/&'"${version}"'/;

        # escape any backslashes and double quotes
        s|\\|\\\\|g; s|"|\\"|g;

        # add a prefix
        s|^|\t,"'"$prefix$patchname"' - |;
        # newlines away
        s/\n/ /g; s/  */ /g;
        # add a suffix
        s/ *$/"/; p
    };
    # stop all processing
    d;
    # label: append to the hold space
    :append H; d;
    # label: prepend to the hold space
    :prepend x; H; d;
    '
done < $in
if $showdate; then
    echo $newest_mtime
fi