source: trunk/debathena/third/lprng/debathenify-lprng @ 25736

Revision 25736, 4.2 KB checked in by jdreed, 12 years ago (diff)
Handle wheezy's LPRng, which uses an autogenerated init script, whose name we have changed in the rules file, and must therefore change the filename too
  • Property svn:executable set to *
Line 
1#!/bin/sh
2set -e
3
4name=lprng
5daname=debathena-lprng
6daversionappend=debathena9
7section=debathena
8
9hack_package () {
10    # Rename the package and make it not conflict with lpr or cupsys-bsd.
11    perl -pe 's/^Package: lprng$/Package: debathena-lprng/' -i debian/control
12    perl -ne '/^Provides: lpr$/ || print;' -i debian/control
13    perl -pe '/^Conflicts/ && s/lpr, //' -i debian/control
14    perl -pe '/^Conflicts/ && s/cupsys-bsd/lprng/' -i debian/control
15    perl -pe '/^Replaces/ && s/lpr/lprng/' -i debian/control
16
17    perl -n -i - debian/rules << 'EOS'
18
19        if (/^build:/) {
20            # lprng has a gcc 4.2.3-related build failure on some dists.
21            # src/common/plp_snprintf.c uses a macro safestrlen() on
22            # character arrays in four places; the macro triggers GCC's
23            # -Waddress warning since it tests for the falsehood of an
24            # array address.  This is a workaround.
25            print "confflags += --disable-werror\n";
26        }
27
28        # Since we're renaming the main package, we have to adjust
29        # where things get installed.  But make sure not to change
30        # references to debian/lprng-doc, which we aren't renaming.
31        s|debian/lprng|debian/debathena-lprng|;
32        s|debian/debathena-lprng-doc|debian/lprng-doc|;
33
34        print;
35
36        # Rename the commands.
37        if (/^(?:[^#]*MAKE.*install|\tdh_auto_install)/) {
38            my $usr = "debian/debathena-lprng/usr";
39            my $man1 = "$usr/share/man/man1";
40            my $man8 = "$usr/share/man/man8";
41            print "\trm $usr/bin/cancel\n";
42            print "\tln -s mit-lprm $usr/bin/cancel\n";
43            print "\trm $usr/bin/lp\n";
44            print "\tln -s mit-lpr $usr/bin/lp\n";
45            print "\tmv $usr/bin/cancel $usr/bin/mit-cancel\n";
46            print "\tmv $usr/bin/lp $usr/bin/mit-lp\n";
47            print "\tmv $usr/bin/lpq $usr/bin/mit-lpq\n";
48            print "\tmv $usr/bin/lprm $usr/bin/mit-lprm\n";
49            print "\tmv $usr/bin/lpr $usr/bin/mit-lpr\n";
50            print "\tmv $usr/bin/lpstat $usr/bin/mit-lpstat\n";
51            print "\tmv $usr/sbin/lpc $usr/sbin/mit-lpc\n";
52            print "\tmv $man1/cancel.1 $man1/mit-cancel.1\n";
53            print "\tmv $man1/lp.1 $man1/mit-lp.1\n";
54            print "\tmv $man1/lpq.1 $man1/mit-lpq.1\n";
55            print "\tmv $man1/lprm.1 $man1/mit-lprm.1\n";
56            print "\tmv $man1/lpr.1 $man1/mit-lpr.1\n";
57            print "\tmv $man1/lpstat.1 $man1/mit-lpstat.1\n";
58            print "\tmv $man8/lpc.8 $man8/mit-lpc.8\n";
59        }
60EOS
61
62    grep -q 'mit-lpr' debian/rules
63
64    # The postinst script sets or unsets the setuid bit of
65    # lpr/lprm/lpq and thus needs to be adjusted for the command
66    # renaming.
67    perl -pe 's|/usr/bin/lp|/usr/bin/mit-lp|' -i debian/postinst
68
69    # The init script is auto-generated in some versions, and we changed its
70    # name in the giant substitution above:
71    [ -f debian/lprng.init.in ] && mv debian/lprng.init.in debian/debathena-lprng.init.in
72
73    # The renamed binary package no longer matches the source package
74    # name, so we have to rename a bunch of debhelper files.
75    for f in config cron.daily dirs examples init.d mime postinst postrm \
76      preinst prerm templates; do
77        [ -f debian/$f ] && mv debian/$f debian/debathena-lprng.$f
78    done
79    perl -pe 's/templates/debathena-lprng.templates/' -i debian/po/POTFILES.in
80
81    # lprng's cron job generates mail to root each day if you're not
82    # running a server.  Fix this problem by making the cron script
83    # conditional on the existence of /etc/printcap, just as the
84    # init.d script is.
85    #
86    # Except CUPS happily generates an incompatibile /etc/printcap, because
87    # they hate you.  So instead, bail if cups generated /etc/printcap
88    perl -ne 'print; /#.*main/ && print "# Debathena: Exit if CUPS is our print server\n(! [ -f /etc/printcap ] || grep -q \"automatically generated by cupsd\" /etc/printcap) && exit 0\n";' \
89      -i debian/debathena-lprng.cron.daily
90
91    append_description <<EOF
92 .
93 This package was rebuilt for the Debathena project to rename the
94 package and commands so that it no longer conflicts with cupsys-bsd.
95 Additionally, the daily cron job will not be run if CUPS generated
96 /etc/printcap.
97EOF
98    add_changelog 'Rename commands.'
99    munge_sections
100    set_debathena_maintainer
101
102    perl -pe 'm{^Package: lprng-doc$} .. s{^Section: debathena}{Section: debathena-system}' -i debian/control
103}
104
105. ../common/debathenificator.sh
Note: See TracBrowser for help on using the repository browser.