~ubuntu-branches/ubuntu/quantal/dh-make/quantal

« back to all changes in this revision

Viewing changes to dh_make

  • Committer: Package Import Robot
  • Author(s): Craig Small
  • Date: 2012-07-13 21:26:38 UTC
  • mto: This revision was merged to the branch mainline in revision 17.
  • Revision ID: package-import@ubuntu.com-20120713212638-e2ymcmc30xek8ca4
* Update to standards version 3.9.3
* Update to debhelper version 9
* debhelper v9 uses dpkg-buildflags Closes: #644486
* Remove ldap-utils conflict as that version is not even in stable
* Changed emacsen-startup script to debian-emacs-flavour Closes:
  #662163
* Fixed emacsen-install from SamBs patch Closes: #665312
* emacsen-install uses relative symlinks Closes: #670409
* emacsen-install uses debian-pkg-add-load-path Closes: #672478
* Man page doesnt have discouraged AUTHORS section Closes: #672543
* Final version of 1.0 copyright file changed Closes: #665770
* Minor tweaks to license files Closes: #662192
* Rename x11 to mit license to follow SPDX list, same bug as above
* Add -y,--yes option to run non-interactively
* Add --packageclass,-C option to set class instead of -s,-i,-m etc
* Don't add missing when non .ex file exists Closes: #662888

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 
16
16
# Some important parameters
17
17
our $DHLIB="/usr/share/debhelper/dh_make";
18
 
our $POLICY_VERSION="3.9.2";
19
 
our $DH_MAKE_VERSION="0.60";
20
 
my %PACKAGE_TYPES = ( 's' => 'Single', 'l' => 'Library',
 
18
our $POLICY_VERSION="3.9.3";
 
19
our $DH_MAKE_VERSION="0.61";
 
20
my %PACKAGE_CLASSES = ( 's' => 'Single', 'l' => 'Library',
21
21
        'm' => 'Multi-Binary', 'k' => 'Kernel Module',
22
22
        'n' => 'Kernel Patch', 'i' => 'Independent' );
23
23
my %RULES_FORMATS = ('dh7' => 'Debhelper v7+', 'old' => 'old debhelper',
35
35
our $source_file="";
36
36
our $debian_native = 0;
37
37
our $create_orig_tar = 0;
38
 
our $package_type="";
 
38
our $package_class="";
39
39
our $CHANGELOG="";
40
40
our $PRESERVE="";
41
41
our $add_missing = 0;
43
43
our $no_defaults = 0;
44
44
our $overlay = "";
45
45
our $forced_package_name="";
 
46
our $assume_yes = 0;
46
47
our @filenames;
47
48
our $filename;
48
49
our $SOURCE_EXTRADOCS="";
51
52
sub process_file(@)
52
53
{
53
54
        my ($infile, $outfile) = @_;  
 
55
        my $outfile2 = $outfile;
54
56
        my $line;
 
57
        $outfile2 =~ s/\.ex$//;
55
58
 
56
59
        if ( $main::overlay eq "" )
57
60
        {
58
 
                if ( $main::add_missing && -f $outfile)
 
61
                if ( $main::add_missing && ( -f $outfile  ||  -f $outfile2 ))
59
62
                {
60
63
                        print "File $outfile exists, skipping.\n";
61
64
                        return;
132
135
sub show_version
133
136
{
134
137
        print "dh_make - prepare Debian packaging for an original source archive, version $main::DH_MAKE_VERSION\n\n";
135
 
        print "Copyright (C) 1998-2011 Craig Small <csmall\@debian.org>\n";
 
138
        print "Copyright (C) 1998-2012 Craig Small <csmall\@debian.org>\n";
136
139
        print "This is free software; see the source for copying conditions.  There is NO\n";
137
140
        print "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n";
138
141
}
144
147
  Usage: dh_make [options]
145
148
  -c, --copyright <type>    use <type> of license in copyright file
146
149
                            (apache|artistic|bsd|gpl|gpl2|gpl3|lgpl|lgpl2|
147
 
                             lgpl3|x11)
 
150
                             lgpl3|mit)
 
151
  -C, --packageclass <cls>  set package class (s|i|k||l||m||n)
148
152
  -e, --email <address>     use <address> as the maintainer e-mail address
149
153
  -n, --native              the program is Debian native, don\'t generate .orig
150
154
  -f, --file <file>         specify file to use as the original source archive
162
166
  -p, --packagename <name>  force package name to be <name>
163
167
  -r, --rulesformat <fmt>   Set the format of debian/rules file
164
168
                            (old|dh7|cdbs)
 
169
  -y, --yes                                     Automatic yes to prompts and run non-interactively
165
170
  -h, --help                display this help screen and exit
166
171
  -v, --version             show the version and exit
167
172
 
176
181
        my ($dohelp,$doversion, $single,$indep,$multi,$library,$kmod,$kpatch);
177
182
        if (GetOptions(
178
183
                        'copyright|c=s' => \$main::license,
 
184
                    'packageclass|C=s' => \$main::package_class,
179
185
                        'email|e=s' => \$main::email,
180
186
                        'file|f=s' => \$main::source_file,
181
187
                        'createorig' => \$main::create_orig_tar,
193
199
                        'templates|t=s' => \$main::custom,
194
200
                        'defaultless|d' => \$main::no_defaults,
195
201
                        'overlay|o=s' => \$main::overlay,
196
 
                        'packagename|p=s' => \$main::forced_package_name
 
202
                        'packagename|p=s' => \$main::forced_package_name,
 
203
                        'yes|y' => \$main::assume_yes
197
204
                ) == 0)
198
205
        {
199
206
                show_help();
218
225
        }
219
226
        if ($single)
220
227
        {
221
 
                $main::package_type = 's';
 
228
                $main::package_class = 's';
222
229
        }
223
230
        if ($indep)
224
231
        {
225
 
                $main::package_type = 'i';
 
232
                $main::package_class = 'i';
226
233
        }
227
234
        if ($multi)
228
235
        {
229
 
                $main::package_type = 'm';
 
236
                $main::package_class = 'm';
230
237
        }
231
238
        if ($library)
232
239
        {
233
 
                $main::package_type = 'l';
 
240
                $main::package_class = 'l';
234
241
        }
235
242
        if ($kmod)
236
243
        {
237
 
                $main::package_type = 'k';
 
244
                $main::package_class = 'k';
238
245
        }
239
246
        if ($kpatch)
240
247
        {
241
 
                $main::package_type = 'n';
 
248
                $main::package_class = 'n';
242
249
        }
243
250
        $main::license = lc $main::license;
244
 
        if ($main::license ne "" && !($main::license =~ /^(gpl|gpl2|gpl3|lgpl|lgpl2|lgpl3|artistic|bsd|blank|apache|x11)$/))
 
251
        if ($main::license ne "" && !($main::license =~ /^(gpl|gpl2|gpl3|lgpl|lgpl2|lgpl3|artistic|bsd|blank|apache|mit)$/))
245
252
        { 
246
 
                print "Copyright type \"$main::license\" is not gpl, gpl2, gpl3, lgpl, lgpl2, lgpl3, apache, artistic, bsd, blank or x11.\n";
 
253
                print "Copyright type \"$main::license\" is not gpl, gpl2, gpl3, lgpl, lgpl2, lgpl3, apache, artistic, bsd, blank or mit.\n";
247
254
                exit;
248
255
        }
249
256
        # Change the non-versioned into the latest version
441
448
        print 'blank' if $license eq '';
442
449
        print "\n";
443
450
        print "Type of Package  : ";
444
 
        if (exists $PACKAGE_TYPES{$package_type})
 
451
        if (exists $PACKAGE_CLASSES{$package_class})
445
452
        {
446
 
                print $PACKAGE_TYPES{$package_type};
 
453
                print $PACKAGE_CLASSES{$package_class};
447
454
        } else {
448
455
                print 'unknown';
449
456
        }
450
457
        print "\nCustom template : $custom" if ( $custom ne "" );
451
458
        print " (overlay)" if ( $overlay ne "" );
452
459
        print "\nDefault debian and package class templates will not be applied." if ( $no_defaults );
453
 
        print "\nHit <enter> to confirm: ";
454
 
        my $dummy = <STDIN>;
 
460
        if ($assume_yes == 0 )
 
461
        {
 
462
                print "\nHit <enter> to confirm: ";
 
463
                my $dummy = <STDIN>;
 
464
        } else {
 
465
                print "\n";
 
466
        }
455
467
}
456
468
$username = get_username();
457
469
$email = get_email();
479
491
 
480
492
if ( ! $no_defaults )
481
493
{
482
 
        while ($package_type eq "")
 
494
        while ($package_class eq "")
483
495
        {
484
496
                print "\nType of package: single binary, indep binary, multiple binary, library, kernel module, kernel patch?\n [s/i/m/l/k/n] ";
485
497
                my $type = <STDIN>;
486
498
                chomp($type);
487
499
                print "\n";
488
500
                $type = lc($type);
489
 
                $main::package_type = 's' if $type eq 's';
490
 
                $main::package_type = 'i' if $type eq 'i';
491
 
                $main::package_type = 'm' if $type eq 'm';
492
 
                $main::package_type = 'l' if $type eq 'l';
493
 
                $main::package_type = 'k' if $type eq 'k';
494
 
                $main::package_type = 'n' if $type eq 'n';
 
501
                $main::package_class = 's' if $type eq 's';
 
502
                $main::package_class = 'i' if $type eq 'i';
 
503
                $main::package_class = 'm' if $type eq 'm';
 
504
                $main::package_class = 'l' if $type eq 'l';
 
505
                $main::package_class = 'k' if $type eq 'k';
 
506
                $main::package_class = 'n' if $type eq 'n';
495
507
        }
496
508
}
497
509
 
600
612
        if ( -f 'Makefile.am' )
601
613
        {
602
614
                # If it is a library then install into tmp
603
 
                if ( $package_type eq "l")
 
615
                if ( $package_class eq "l")
604
616
                {
605
617
                        $INSTALL="\$(MAKE) DESTDIR=\$(CURDIR)/debian/tmp install";
606
618
                } else {
607
619
                        $INSTALL="\$(MAKE) DESTDIR=\$(CURDIR)/debian/$package_name install";
608
620
                }
609
621
        } else {
610
 
                if ( $package_type eq "l")
 
622
                if ( $package_class eq "l")
611
623
                {
612
624
                        $INSTALL="\$(MAKE) prefix=\$(CURDIR)/debian/tmp/usr install";
613
625
                } else {
630
642
                         "\t".'cd builddir && cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_C_FLAGS="$(CFLAGS)" -DCMAKE_LD_FLAGS="-Wl,-z,defs" -DCMAKE_CXX_FLAGS="$(CXXFLAGS)" -DCMAKE_SKIP_RPATH=ON -DCMAKE_VERBOSE_MAKEFILE=ON'."\n";
631
643
        $MAKE="\$(MAKE) -C builddir";
632
644
        # If it is a library then install into tmp
633
 
        if ( $package_type eq "l")
 
645
        if ( $package_class eq "l")
634
646
        {
635
647
                $INSTALL="\$(MAKE) -C builddir DESTDIR=\$(CURDIR)/debian/tmp install";
636
648
        } else {
655
667
        $PHONY_CONFIGURE='configure';
656
668
        $MAKE="\$(MAKE)";
657
669
        $DPKG_ARCH='';
658
 
        if ($package_type eq "l") {
 
670
        if ($package_class eq "l") {
659
671
         $INSTALL="\$(MAKE) DESTDIR=\$(CURDIR)/debian/tmp install";
660
672
        } else {
661
673
         $INSTALL="\$(MAKE) DESTDIR=\$(CURDIR)/debian/$package_name install";
662
674
        }
663
675
        $CLEAN='$(MAKE) clean';
664
676
}
665
 
if ($package_type eq "k") {
 
677
if ($package_class eq "k") {
666
678
        $BUILD_DEPS .= ', bzip2';
667
679
}
668
680
 
669
 
if ($package_type eq "n") {
 
681
if ($package_class eq "n") {
670
682
        $BUILD_DEPS .= ', dh-kpatches';
671
683
}
672
684
 
719
731
                }
720
732
        }
721
733
        # Remove the  README if a kernel package, we use the specific one
722
 
        if ( $package_type eq 'k')
 
734
        if ( $package_class eq 'k')
723
735
        {
724
736
                unlink('README.Debian');
725
737
        }
726
738
 
727
739
        # Special Files
728
 
        @filenames = split / |\n/, qx{(cd $DHLIB/debian$package_type && ls)};
 
740
        @filenames = split / |\n/, qx{(cd $DHLIB/debian$package_class && ls)};
729
741
        foreach $filename (@filenames)
730
742
        {
731
743
                if ( $filename=~/^rules/ )
735
747
                                next;
736
748
                        }
737
749
                }
738
 
                process_file("$DHLIB/debian$package_type/$filename", $filename);
 
750
                process_file("$DHLIB/debian$package_class/$filename", $filename);
739
751
        }
740
752
}
741
753
 
767
779
}
768
780
 
769
781
# kernel-patch kpatch file name
770
 
rename "kpatches", "$package_name.kpatches" if $package_type eq "n";
 
782
rename "kpatches", "$package_name.kpatches" if $package_class eq "n";
771
783
 
772
784
if ( -f "docs" )
773
785
{
836
848
        print "Done. Please edit the files in the debian/ subdirectory now. You should also\n";
837
849
        print "check that the $package_name Makefiles install into \$DESTDIR and not in / .\n";
838
850
}
839
 
if ($package_type eq 'l')
 
851
if ($package_class eq 'l')
840
852
{
841
853
        print "Make sure you change the package name from $package_name"."BROKEN to something\n".
842
854
                  "else, such as $package_name"."1 in the debian/control file.\n";