source: trunk/debbuild@ 190

Last change on this file since 190 was 190, checked in by kdeugau, 9 years ago

/trunk

Tweak warnings and extend handling of dependency tags a little

  • add semisupport for "Supplements:" converted to "Enhances:" (since .deb packages do not yet support "Supplements:")
  • not sure why I missed "Obsoletes", but it's the rpm-native version of Debian-specific Replaces
  • Property svn:executable set to *
  • Property svn:keywords set to Date Rev Author
File size: 75.3 KB
Line 
1#!/usr/bin/perl -w
2# debbuild script
3# Shamelessly steals interface from rpm's "rpmbuild" to create
4# Debian packages. Please note that such packages are highly
5# unlikely to conform to "Debian Policy".
6###
7# SVN revision info
8# $Date: 2015-07-12 03:29:33 +0000 (Sun, 12 Jul 2015) $
9# SVN revision $Rev: 190 $
10# Last update by $Author: kdeugau $
11###
12# Copyright (C) 2005-2013 Kris Deugau <kdeugau@deepnet.cx>
13#
14# This program is free software; you can redistribute it and/or modify
15# it under the terms of the GNU General Public License as published by
16# the Free Software Foundation; either version 2 of the License, or
17# (at your option) any later version.
18#
19# This program is distributed in the hope that it will be useful,
20# but WITHOUT ANY WARRANTY; without even the implied warranty of
21# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22# GNU General Public License for more details.
23#
24# You should have received a copy of the GNU General Public License
25# along with this program; if not, write to the Free Software
26# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27
28use strict;
29use warnings;
30use Fcntl; # for sysopen flags
31use Cwd 'abs_path'; # for finding where files really are
32use Config;
33
34my $version = "0.10.1"; #VERSION#
35
36# regex debugger
37#use re "debug";
38
39# Behavioural compatibility FTW! Yes, rpmbuild does this too.
40die "No .spec file to work with! Exiting.\n" if scalar(@ARGV) == 0;
41
42# Program flow:
43# -> Parse/execute "system" config/macros (if any - should be rare)
44# -> Parse/execute "user" config/macros (if any - *my* requirement is %_topdir)
45# -> Parse command line for options, spec file/tarball/.src.deb (NB - also accept .src.rpm)
46
47sub expandmacros;
48
49# User's prefs for dirs, environment, etc,etc,etc.
50# config file ~/.debmacros
51# Default ordered search paths for config/macros:
52# /usr/lib/rpm/rpmrc /usr/lib/rpm/redhat/rpmrc /etc/rpmrc ~/.rpmrc
53# /usr/lib/rpm/macros /usr/lib/rpm/redhat/macros /etc/rpm/macros ~/.rpmmacros
54# **NOTE: May be possible to (ab)use bits of debhelper
55
56# Build tree
57# default is /usr/src/debian/{BUILD,SOURCES,SPECS,DEBS,SDEBS}
58
59# Globals
60my $finalmessages = ''; # A place to stuff messages that I want printed at the *very* end of any processing.
61my $specfile;
62my $tarball;
63my $srcpkg;
64my $cmdbuildroot;
65my $tarballdir = '%{name}-%{version}'; # We do this in case of a spec file not using %setup...
66my %specglobals; # For %define's in specfile, among other things.
67
68$specglobals{'_vendor'} = 'debbuild';
69# this can be changed by the Vendor: header in the spec file
70$specglobals{'vendor'} = 'debbuild';
71
72# Initialized globals
73my $verbosity = 0;
74my $NoAutoReq = 0;
75my %cmdopts = (type => '',
76 stage => 'a',
77 short => 'n'
78 );
79my $topdir = "/usr/src/debian";
80#my $specglobals{buildroot} = "%{_tmppath}/%{name}-%{version}-%{release}.root".int(rand(99998)+1);
81$specglobals{buildroot} = '%{_topdir}/BUILDROOT/%{name}-%{version}-%{release}';
82
83# "Constants"
84my %targets = ('p' => 'Prep',
85 'c' => 'Compile',
86 'i' => 'Install',
87 'l' => 'Verify %files',
88 'a' => 'Build binary and source',
89 'b' => 'Build binary',
90 's' => 'Build source'
91 );
92# Ah, the joys of multiple architectures. :( Feh.
93# As copied from rpm
94my %optflags = ( 'i386' => '-O2 -g -march=i386 -mcpu=i686',
95 'amd64' => '-O2 -g'
96 );
97my $hostarch; # we set this later...
98my $scriptletbase =
99q(#!/bin/bash
100
101 RPM_SOURCE_DIR="%{_topdir}/SOURCES"
102 RPM_BUILD_DIR="%{_topdir}/BUILD"
103 RPM_OPT_FLAGS="%{optflags}"
104 RPM_ARCH="%{_arch}"
105 RPM_OS="linux"
106 export RPM_SOURCE_DIR RPM_BUILD_DIR RPM_OPT_FLAGS RPM_ARCH RPM_OS
107 RPM_DOC_DIR="/usr/share/doc"
108 export RPM_DOC_DIR
109 RPM_PACKAGE_NAME="%{name}"
110 RPM_PACKAGE_VERSION="%{version}"
111 RPM_PACKAGE_RELEASE="%{release}"
112 export RPM_PACKAGE_NAME RPM_PACKAGE_VERSION RPM_PACKAGE_RELEASE
113 LANG=C
114 export LANG
115 unset CDPATH DISPLAY ||:
116 RPM_BUILD_ROOT="%{buildroot}"
117 export RPM_BUILD_ROOT
118
119 PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:/usr/lib64/pkgconfig:/usr/share/pkgconfig"
120 export PKG_CONFIG_PATH
121);
122
123if (-e '/usr/bin/dpkg-architecture') {
124 foreach (`dpkg-architecture`) {
125 s/=(.+)/="$1"/;
126 $scriptletbase .= " $_";
127 ($hostarch) = (/^DEB_HOST_ARCH="(.+)"$/) if /DEB_HOST_ARCH=/;
128 }
129} else {
130 warn "Missing dpkg-architecture, DEB_HOST_ARCH will not be set!\n";
131}
132
133$scriptletbase .=
134q(
135 set -x
136 umask 022
137 cd "%{_topdir}/BUILD"
138);
139
140# Hackery to try to bring some semblance of sanity to packages built for more
141# than one Debian version at the same time. Whee.
142# /etc/debian-version and/or version of base-files package
143my %distmap = (
144 "3.1.9ubuntu7.1" => "dapper",
145 "4ubuntu2" => "feisty",
146 "3.0" => "woody",
147 "3.1" => "sarge",
148 "4" => "etch",
149 "5" => "lenny",
150 "6.0" => "squeeze",
151 "7.0" => "wheezy",
152 "8.0" => "jessie",
153 "99" => "sid");
154# Enh. There doesn't seem to be any better way to do this... :(
155{
156# could theoretically also do something with this... it's about as stable as "dpkg-query ..." below... :(
157# my $releasever = qx { cat /etc/debian_version };
158# chomp $releasever;
159 my $basever;
160
161 if ( ! -e '/usr/bin/dpkg-query' ) {
162 # call it woody, since sarge and newer have dpkg-query, and we don't much care about obsolete^n releases
163 $basever = "3.0";
164 } else {
165
166# *eyeroll* there *really* has to be a better way to go about this. You
167# can't sanely build packages for multiple distro targets if you can't
168# programmatically figure out which one you're building on.
169
170# note that we care only about major release numbers; tracking minor or point
171# releases would be... exponentially more painful.
172
173 # for the lazy copy-paster: dpkg-query --showformat '${version}\n' -W base-files
174 # avoid shellisms
175 if (open BASEGETTER, "-|", "dpkg-query", "--showformat", '${version}', "-W", "base-files") {
176 $basever = <BASEGETTER>;
177 close BASEGETTER;
178
179 ($basever) = ($basever =~ /^(\d(?:\.\d)?)/);
180 }
181
182 } # got dpkg-query?
183
184 $specglobals{"debdist"} = $distmap{$basever};
185 $specglobals{"debver"} = $basever; # this may have trouble with Ubuntu versions?
186
187} # done trying to set debian dist/version
188
189# Package data
190# This is the form of $pkgdata{pkgname}{meta}
191# meta includes Summary, Name, Version, Release, Group, Copyright,
192# Source, URL, Packager, BuildRoot, Description, BuildRequires,
193# Requires, Provides
194# 10/31/2005 Maybe this should be flatter? -kgd
195my %pkgdata = (main => {source => ''});
196my @pkglist = ('main'); #sigh
197# Files listing. Embedding this in %pkgdata would be, um, messy.
198my %filelist;
199my %doclist;
200my $buildreq = '';
201
202# Scriptlets
203my $prepscript = '';
204my $buildscript = '';
205# %install doesn't need the full treatment from %clean; just an empty place to install to.
206# NB - rpm doesn't do this; is it really necessary?
207my $installscript = '[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT'."\n";
208my $cleanscript = '';
209
210# Snag some environment data
211my $tmpdir;
212if (defined $ENV{TMP} && $ENV{TMP} =~ /^(\/var)?\/tmp$/) {
213 $tmpdir = $ENV{TMP};
214} else {
215 $tmpdir = "/var/tmp";
216}
217
218##main
219
220load_userconfig();
221parse_cmd();
222
223if ($cmdopts{install}) {
224 install_sdeb();
225 exit 0;
226}
227
228# output stage of --showpkgs
229if ($cmdopts{type} eq 'd') {
230 parse_spec();
231 foreach my $pkg (@pkglist) {
232 $pkgdata{$pkg}{name} =~ tr/_/-/;
233
234 my $pkgfullname = "$pkgdata{$pkg}{name}_".
235 (defined($pkgdata{main}{epoch}) ? "$pkgdata{main}{epoch}:" : '').
236 "$pkgdata{$pkg}{version}-$pkgdata{main}{release}_$pkgdata{$pkg}{arch}.deb";
237
238 print "$pkgfullname\n" if $filelist{$pkg};
239
240 }
241 # Source package
242 print "$pkgdata{main}{name}-".
243 (defined($pkgdata{main}{epoch}) ? "$pkgdata{main}{epoch}:" : '').
244 "$pkgdata{main}{version}-$pkgdata{main}{release}.sdeb\n";
245 exit 0;
246}
247
248# Stick --rebuild handling in here - basically install_sdeb()
249# followed by tweaking options to run with -ba
250if ($cmdopts{type} eq 's') {
251 if ($srcpkg =~ /\.src\.rpm$/) {
252 my @srclist = qx { rpm -qlp $srcpkg };
253 foreach (@srclist) {
254 chomp;
255 $specfile = "$topdir/SPECS/$_" if /\.spec$/;
256 }
257 qx { rpm -i $srcpkg };
258 } else {
259 install_sdeb();
260 my @srclist = qx { pax < $srcpkg };
261 foreach (@srclist) {
262 chomp;
263 $specfile = "$topdir/$_" if /SPECS/;
264 }
265 }
266 $cmdopts{type} = 'b';
267 $cmdopts{stage} = 'a';
268}
269
270if ($cmdopts{type} eq 'b') {
271 # Need to read the spec file to find the tarball. Note that
272 # this also generates most of the shell script required.
273 parse_spec();
274 die "Can't build $pkgdata{main}{name}: build requirements not met.\n"
275 if !checkbuildreq();
276}
277
278if ($cmdopts{type} eq 't') {
279 # Need to unpack the tarball to find the spec file. Sort of the inverse of -b above.
280 # zcat $tarball |tar -t |grep .spec
281 # collect some info about the tarball
282 $specfile = "$topdir/BUILD/". qx { zcat $tarball |tar -t |grep -e '[\.]spec\$' };
283 chomp $specfile;
284 my ($fileonly, $dirname) = ($tarball =~ /(([a-zA-Z0-9._-]+)\.tar\.(?:gz|bz2|xz))$/);
285
286 $tarball = abs_path($tarball);
287##fixme: use macro expansions for the executables
288 my $unpackcmd = "cd $topdir/BUILD; ".
289 ( $tarball =~ /\.tar\.gz$/ ? "/bin/gzip" : "" ).
290 ( $tarball =~ /\.tar\.bz2$/ ? "/bin/bzip2" : "" ).
291 ( $tarball =~ /\.tar\.(?:gz|Z)$/ ? "/usr/bin/xz" : "" ).
292 " -dc $tarball |/bin/tar -xf -";
293
294 system "$unpackcmd";
295 system "cp $tarball $topdir/SOURCES/$fileonly";
296 system "cp $specfile $topdir/SPECS/";
297 parse_spec();
298 die "Can't build $pkgdata{main}{name}: build requirements not met.\n"
299 if !checkbuildreq();
300}
301
302# -> srcpkg if -.s
303if ($cmdopts{stage} eq 's') {
304 srcpackage();
305 print $finalmessages;
306 exit 0;
307}
308
309# Hokay. Need to:
310# -> prep if -.p OR (-.[cilabs] AND !--short-circuit)
311if ($cmdopts{stage} eq 'p' || ($cmdopts{stage} =~ /[cilabs]/ && $cmdopts{short} ne 'y')) {
312 prep();
313}
314# -> build if -.c OR (-.[ilabs] AND !--short-circuit)
315if ($cmdopts{stage} eq 'c' || ($cmdopts{stage} =~ /[ilabs]/ && $cmdopts{short} ne 'y')) {
316 build();
317}
318# -> install if -.[ilabs]
319#if ($cmdopts{stage} eq 'i' || ($cmdopts{stage} =~ /[labs]/ && $cmdopts{short} ne 'y')) {
320if ($cmdopts{stage} =~ /[ilabs]/) {
321 install();
322#foreach my $pkg (@pkglist) {
323# print "files in $pkg:\n ".$filelist{$pkg}."\n";
324#}
325
326}
327# -> binpkg and srcpkg if -.a
328if ($cmdopts{stage} eq 'a') {
329 binpackage();
330 srcpackage();
331 clean();
332}
333# -> binpkg if -.b
334if ($cmdopts{stage} eq 'b') {
335 binpackage();
336 clean();
337}
338
339# Spit out any closing remarks
340print $finalmessages;
341
342# Just in case.
343exit 0;
344
345
346## load_userconfig()
347# Loads user configuration (if any)
348# Currently only handles .debmacros
349# Needs to handle "other files"
350sub load_userconfig {
351 my $homedir = (getpwuid($<))[7];
352 if (-e "$homedir/.debmacros") {
353 open USERMACROS,"<$homedir/.debmacros";
354 while (<USERMACROS>) {
355 # And we also only handle a few macros at the moment.
356 if (/^\%_topdir/) {
357 my (undef,$tmp) = split /\s+/, $_;
358 $topdir = $tmp;
359 }
360 next if /^\%_/;
361 # Allow arbitrary definitions. Note that we're only doing simple defs here for now.
362 if (/^\%([a-z0-9]+)\s+(.+)$/) {
363 $specglobals{$1} = $2;
364 }
365 }
366 }
367} # end load_userconfig()
368
369
370## parse_cmd()
371# Parses command line into global hash %cmdopts, other globals
372# Options based on rpmbuild's options
373sub parse_cmd {
374 # Don't feel like coding my own option parser...
375 #use Getopt::Long;
376 # ... but I may have to: (OTOH, rpm uses popt, so maybe we can too.)
377 #use Getopt::Popt qw(:all);
378 # Or not. >:( Stupid Debian lack of findable Perl module names in packages.
379
380 # ... also note, single-character options are mostly not flags, so they can't be
381 # sanely combined the way most other programs' single-character flag options can.
382
383 # Stuff it.
384 my $prevopt = '';
385 foreach (@ARGV) {
386 chomp;
387
388 # Is it an option?
389 if (/^-/) {
390
391 # Is it a long option?
392 if (/^--/) {
393 if (/^--short-circuit/) {
394 $cmdopts{short} = 'y';
395 } elsif (/^--rebuild/) {
396 $cmdopts{type} = 's';
397 } elsif (/^--showpkgs/) {
398 $cmdopts{type} = 'd'; # d for 'diagnostic' or 'debug' or 'dump'
399 } elsif (/^--help/) {
400 print "debbuild v$version".q{
401Copyright 2005-2012 Kris Deugau <kdeugau@deepnet.cx>
402
403Build .deb packages from RPM-style .spec files
404debbuild supports most package-building options rpmbuild does.
405
406Build options with [ <specfile> | <tarball> | <source package> ]:
407 -bp build through %prep (unpack sources and apply patches) from <specfile>
408 -bc build through %build (%prep, then compile) from <specfile>
409 -bi build through %install (%prep, %build, then install) from <specfile>
410 -bl verify %files section from <specfile>
411 -ba build source and binary packages from <specfile>
412 -bb build binary package only from <specfile>
413 -bs build source package only from <specfile>
414 -tp build through %prep (unpack sources and apply patches) from <tarball>
415 -tc build through %build (%prep, then compile) from <tarball>
416 -ti build through %install (%prep, %build, then install) from <tarball>
417 -ta build source and binary packages from <tarball>
418 -tb build binary package only from <tarball>
419 -ts build source package only from <tarball>
420 --rebuild build binary package from <source package>
421 --buildroot=DIRECTORY override build root
422 --short-circuit skip straight to specified stage (only for c,i)
423
424Common options:
425 -D, --define='MACRO EXPR' define MACRO with value EXPR
426
427debbuild-specific options:
428 -i Unpack a .sdeb in the %_topdir tree
429 --showpkgs Show package names that would be built. Only works with .spec files.
430
431};
432 exit;
433
434 } elsif (/^--define/) {
435 # nothing to do? Can't see anything needed, we handle the actual definition later.
436##fixme
437# add --self-package here
438# deps build-essential pax fakeroot
439 } else {
440 print "Long option $_ not handled\n";
441 }
442 } else {
443 # Not a long option
444 if (/^-[bt]/) {
445 if ($cmdopts{stage} eq 's') {
446 # Mutually exclusive options.
447 die "Can't use $_ with --rebuild\n";
448 } else {
449 # Capture the type (from "bare" files or tarball) and the stage (prep, build, etc)
450 ($cmdopts{stage}) = (/^-[bt]([pcilabs])/);
451 ($cmdopts{type}) = (/^-([bt])[pcilabs]/);
452 }
453 } elsif (/^-v/) {
454 # bump verbosity. Not sure what I'll actually do here...
455 } elsif (/^-i/) {
456 $cmdopts{install} = 1;
457 $prevopt = '-i';
458 } elsif (/^-D/) {
459 # --define. nothing to do on this round; actual work is done next time.
460 } else {
461 die "Bad option $_\n";
462 }
463 }
464
465 } else { # Not an option argument
466
467 # --buildroot is the only option that takes an argument
468 # Therefore, any *other* bare arguments are the spec file,
469 # tarball, or source package we're operating on - depending
470 # on which one we meet.
471 if ($prevopt eq '--buildroot') {
472 $cmdbuildroot = $_;
473 } elsif ($prevopt eq '--define' || $prevopt eq '-D') {
474 my ($macro,$value) = (/([a-z0-9_.-]+)(?:\s+(.+))?/i);
475 if ($value ne '') {
476 $specglobals{$macro} = $value;
477 } else {
478 warn "WARNING: missing value for macro $macro in --define! Ignoring.\n";
479 }
480 } elsif ($prevopt eq '-i') {
481 $srcpkg = $_;
482 } else {
483 if ($cmdopts{type} eq 's') {
484 # Source package
485 if (!/(sdeb|\.src\.rpm)$/) {
486 die "Can't --rebuild with $_\n";
487 }
488 $srcpkg = $_;
489 } elsif ($cmdopts{type} eq 'b' || $cmdopts{type} eq 'd') {
490 # Spec file
491 $specfile = $_;
492 } else {
493 # Tarball build. Need to extract tarball to find spec file. Whee.
494 $tarball = $_;
495 }
496 }
497 }
498 $prevopt = $_;
499 } # foreach @ARGV
500
501 # Some cross-checks. rpmbuild limits --short-circuit to just
502 # the "compile" and "install" targets - with good reason IMO.
503 # Note that --short-circuit with -.p is not really an error, just redundant.
504 # NB - this is NOT fatal, just ignored!
505 if ($cmdopts{short} eq 'y' && $cmdopts{stage} =~ /[labs]/) {
506 warn "Can't use --short-circuit for $targets{$cmdopts{stage}} stage. Ignoring.\n";
507 $cmdopts{short} = 'n';
508 }
509
510 # Valid options, with example arguments (if any):
511# Build from .spec file; mutually exclusive:
512 # -bp
513 # -bc
514 # -bi
515 # -bl
516 # -ba
517 # -bb
518 # -bs
519# Build from tarball; mutually exclusive:
520 # -tp
521 # -tc
522 # -ti
523 # -ta
524 # -tb
525 # -ts
526# Build from .src.(deb|rpm)
527 # --rebuild
528 # --recompile
529
530# General options
531 # --buildroot=DIRECTORY
532 # --clean
533 # --nobuild
534 # --nodeps
535 # --nodirtokens
536 # --rmsource
537 # --rmspec
538 # --short-circuit
539 # --target=CPU-VENDOR-OS
540
541 #my $popt = new Getopt::Popt(argv => \@ARGV, options => \@optionsTable);
542
543} # end parse_cmd()
544
545
546## parse_spec()
547# Parse the .spec file.
548sub parse_spec {
549 die "No .spec file specified! Exiting.\n" if !$specfile;
550 open SPECFILE,"<$specfile" or die "specfile ($specfile) barfed: $!";
551
552 my $iflevel = 0;
553 my $buildarch = $hostarch;
554 $pkgdata{main}{arch} = $hostarch;
555
556 my $stage = 'preamble';
557 my $subname = 'main';
558 my $scriptlet;
559
560# Basic algorithm:
561# For each line
562# if it's a member of an %if construct, branch and see which segment of the
563# spec file we need to parse and which one gets discarded, then
564# short-circuit back to the top of the loop.
565# if it's a %section, bump the stage. Preparse addons to the %section line
566# (eg subpackage) and stuff them in suitable loop-global variables, then
567# short-circuit back to the top of the loop.
568# Otherwise, parse the line according to which section we're supposedly
569# parsing right now
570
571LINE: while (<SPECFILE>) {
572 next if /^#/ && $stage eq 'preamble'; # Ignore comments...
573 next if /^\s*$/ && $stage eq 'preamble'; # ... and blank lines.
574
575# no sense in continuing if we find something we don't grok
576 # Yes, this is really horribly fugly. But it's a cheap crosscheck against invalid
577 # %-tags which also make rpmbuild barf. In theory.
578# notes: some of these are not *entirely* case-sensitive (%ifxxx), but most are.
579 # Extracted from the Maximum RPM online doc via:
580 # grep -h %[a-z] *|perl -e 'while (<>) { /\%([a-z0-9]+)\b/; print "$1|\n"; }'|sort -u
581 if (/^%[a-z]/ &&
582 $_ !~ /^%(?:attr|build|changelog|check|clean|config|configure|defattr|define|description|
583 dir|doc|docdir|else|endif|files|ghost|if|ifarch|ifn|ifnarch|ifnos|ifnxxx|fos|ifxxx|
584 install|makeinstall|package|patch\d+|post|postun|pre|prep|preun|readme|setup[^\s]*|
585 triggerin|triggerpostun|triggerun|verify|verifyscript)\b/x
586 ) {
587 my ($badtag) = (/^%([a-z]+)/i);
588 die "Unknown tag \%$badtag at line $. of $specfile\n";
589 }
590
591# preprocess %define's
592 if (my ($key, $def) = (/^\%define\s+([^\s]+)\s+(.+)$/) ) {
593 $specglobals{$key} = expandmacros($def,'g');
594 }
595
596 if (/^\%if/) {
597 s/^\%if//;
598 chomp;
599 my $expr = expandmacros($_, 'g');
600 $iflevel++;
601
602 if ($expr !~ /^\s*\d+\s*$/) {
603 # gots a logic statement we want to turn into a 1 or a 0. most likely by eval'ing it.
604
605 $expr =~ s/\s+//g;
606
607# For Great w00tness! New and Improved multilayered logic handling.
608
609 my @bits = split /\b/, $expr;
610 $expr = '';
611 foreach my $bit (@bits) {
612 next if $bit eq '"';
613 $bit =~ s/"//g;
614 $expr .= qq("$bit") if $bit =~ /^\w+$/;
615 $expr .= $bit if $bit !~ /^\w+$/;
616 }
617
618 # Done in this order so we don't cascade incorrectly. Yes, those spaces ARE correct in the replacements!
619 $expr =~ s/==/ eq /g;
620 $expr =~ s/!=/ ne /g;
621 $expr =~ s/<=>/ cmp /g;
622 $expr =~ s/<=/ le /g;
623 $expr =~ s/>=/ ge /g;
624 $expr =~ s/</ lt /g;
625 $expr =~ s/>/ gt /g;
626
627 # Turn it into something that eval's to a number. Maybe not needed? O_o
628 #$expr = "( $expr ? 1 : 0 )";
629
630 $expr = eval $expr;
631 }
632
633 next LINE if $expr != 0; # This appears to be the only case we call false.
634 while (<SPECFILE>) {
635 if (/^\%endif/) {
636 $iflevel--;
637 next LINE;
638 } elsif (/^\%else/) {
639 next LINE;
640 }
641 }
642 }
643 if (/^\%else/) {
644 while (<SPECFILE>) {
645 if (/^\%endif/) {
646 $iflevel--;
647 next LINE;
648 }
649 }
650 }
651 if (/^\%endif/) {
652 $iflevel--;
653 next LINE;
654 } # %if/%else/%endif
655
656 if (/^\%{echo:(.+)}/) {
657 my $output = expandmacros($1, 'gp');
658 print "$output";
659 }
660
661# now we pick out the sections and set "state" to parse that section. Fugly but I can't see a better way. >:(
662
663 if (/^\%description(?:\s+(?:-n\s+)?(.+))?/) {
664 $stage = 'desc';
665 $subname = "main";
666 if ($1) { # Magic to add entries to the right package
667 my $tmp = expandmacros("$1", 'gp');
668 if (/-n/) { $subname = $tmp; } else { $subname = "$pkgdata{main}{name}-$tmp"; }
669 }
670 next LINE;
671 } # %description
672
673 if (/^\%package\s+(?:-n\s+)?(.+)/) {
674 $stage = 'package';
675 if ($1) { # Magic to add entries to the right package
676 my $tmp = expandmacros("$1", 'gp');
677 if (/-n/) { $subname = $tmp; } else { $subname = "$pkgdata{main}{name}-$tmp"; }
678 }
679 push @pkglist, $subname;
680 $pkgdata{$subname}{name} = $subname;
681 $pkgdata{$subname}{version} = $pkgdata{main}{version};
682 # Build "same arch as previous package found" by default. Where rpm just picks the
683 # *very* last one, we want to allow arch<native>+arch-all
684 # (eg, Apache is i386, but apache-manual is all)
685 $pkgdata{$subname}{arch} = $buildarch; # Since it's likely subpackages will NOT have a BuildArch line...
686 next LINE;
687 } # %package
688
689 if (/^\%prep/) {
690 $stage = 'prep';
691 # Replace some core macros
692 $pkgdata{main}{source} = expandmacros($pkgdata{main}{source},'gp');
693 next LINE;
694 } # %prep
695
696 if (/^\%build/) {
697 $stage = 'build';
698 $buildscript .= "cd '$tarballdir'\n" if $pkgdata{main}{hassetup};
699 next LINE;
700 } # %build
701
702 if (/^\%install/) {
703 $stage = 'install';
704 $installscript .= "cd '$tarballdir'\n" if $pkgdata{main}{hassetup};
705 next LINE;
706 } # %install
707
708 if (/^\%clean/) {
709 $stage = 'clean';
710 $cleanscript .= "cd '$tarballdir'\n" if $pkgdata{main}{hassetup};
711 next LINE;
712 } # %clean
713
714 if (/^\%(pre|post|preun|postun)\b(?:\s+(?:-n\s+)?(.+))?/i) {
715 $stage = 'prepost';
716 $scriptlet = lc $1;
717 $subname = 'main';
718 if ($2) { # Magic to add entries to the right package
719 my $tmp = expandmacros("$2", 'g');
720 if (/-n/) { $subname = $tmp; } else { $subname = "$pkgdata{main}{name}-$tmp"; }
721 }
722 next LINE;
723 } # %pre/%post/%preun/%postun
724
725 if (/^\%files(?:\s+(?:-n\s+)?(.+))?/) {
726 $stage = 'files';
727 $subname = 'main';
728 if ($1) { # Magic to add entries to the right list of files
729 my $tmp = expandmacros("$1", 'gp');
730 if (/-n/) { $subname = $tmp; } else { $subname = "$pkgdata{main}{name}-$tmp"; }
731 }
732 next LINE;
733 } # %files
734
735 if (/^\%changelog/) {
736 $stage = 'changelog';
737 $pkgdata{main}{changelog} = '';
738 next LINE;
739 }
740
741# now we handle individual lines from the various sections
742
743 if ($stage eq 'desc') {
744 next LINE if /^\s*#/;
745 $pkgdata{$subname}{desc} .= " $_";
746 } # description
747
748 if ($stage eq 'package') {
749 # gotta expand %defines here. Whee.
750# Note that we look for the Debian-specific Recommends, Suggests, and Replaces,
751# although they will have to be wrapped in '%if %{_vendor} == "debbuild"' for
752# an rpmbuild-compatible .spec file
753# NB: NOT going to support Pre-Depends, since it's a "Don't Use" (mis)feature, and
754# RPM's support for a similar tag (PreReq) has been recently dropped.
755 if (my ($dname,$dvalue) = (/^(Recommends|Suggests|Enhances|Replaces|Summary|Group|Version|Requires|Conflicts|Provides|BuildArch(?:itecture)?):\s+(.+)$/i)) {
756 $dname =~ tr/[A-Z]/[a-z]/;
757 if ($dname =~ /^BuildArch/i) {
758 $dvalue =~ s/^noarch/all/ig;
759 $buildarch = $dvalue; # Emulate rpm's behaviour to a degree
760 $dname = 'arch';
761 }
762 if ($dname =~ /recommends|suggests|enhances|replaces|requires|conflicts|provides/) {
763 $pkgdata{$subname}{$dname} .= ", ".expandmacros($dvalue, 'gp');
764 } else {
765 $pkgdata{$subname}{$dname} = expandmacros($dvalue, 'gp');
766 }
767 }
768 } # package
769
770 if ($stage eq 'prep') {
771 # Actual handling for %prep section. May have %setup macro; may
772 # include %patch tags, may be just a bare shell script.
773 if (/^\%setup/) {
774 $pkgdata{main}{hassetup} = 1; # flag the fact that we've got %setup
775 # Parse out the %setup macro.
776 chomp;
777 # rpmbuild doesn't complain about gibberish immediately following %setup, but we will
778 warn "Suspect \%setup tag '$_', continuing\n" if ! /^\%setup(?:\s|$)/;
779
780 # Prepare some flags
781 my $changedir = 0;
782 my $deldir = 1;
783 my $quietunpack = 0;
784 my $deftarball = 1;
785 my $snum = '';
786 my $sbefore;
787 my $safter;
788 my $altsource = 0;
789
790 # yes, really. It's not clear how this cascades down to %build or %install
791 my $thistarballdir = $tarballdir;
792
793 my @sbits = split /\s+/;
794 shift @sbits;
795 while (my $sopt = shift @sbits) {
796 if ($sopt eq '-n') {
797 $thistarballdir = shift @sbits;
798 } elsif ($sopt eq '-a') {
799 # shift, next opt must be numeric (which sourcenn:)
800 $sopt = shift @sbits;
801 die "Argument for \%setup -a must be numeric at $specfile line $.\n" if $sopt !~ /^\d+$/;
802 $safter = $sopt;
803 $snum = $sopt;
804 $altsource = 1;
805 } elsif ($sopt eq '-b') {
806 # shift, next opt must be numeric (which sourcenn:)
807 $sopt = shift @sbits;
808 die "Argument for \%setup -b must be numeric at $specfile line $.\n" if $sopt !~ /^\d+$/;
809 $sbefore = $sopt;
810 $snum = $sopt;
811 $altsource = 2;
812 } elsif ($sopt eq '-c') {
813 # flag, create and change directory before unpack
814 $changedir = 1;
815 } elsif ($sopt eq '-D') {
816 # flag, do not delete directory before unpack
817 $deldir = 0;
818 } elsif ($sopt eq '-T') {
819 # flag, do not unpack first source
820 $deftarball = 0;
821 } elsif ($sopt eq '-q') {
822 # SSSH! Unpack quietly
823 $quietunpack = 1;
824 }
825 } # $sopt = shift @sbits
826
827# Note that this is an incomplete match to rpmbuild's full %setup expression.
828# Still known to do:
829# - Match implementation of -a and -b if both are specified.
830# Looks to be "expand -a into $aftersource and expand -b into $beforesource inside the while()"
831# instead of treating them as flags like the other arguments.
832# - -q appears to be somewhat positional
833
834 $prepscript .= "cd '$topdir/BUILD'\n";
835 $tarballdir = expandmacros($tarballdir,'gp');
836 $prepscript .= "rm -rf '$thistarballdir'\n" if $deldir;
837 $prepscript .= "/bin/mkdir -p $thistarballdir\n" if $changedir;
838
839 if ($deftarball) {
840 $prepscript .= "cd '$thistarballdir'\n" if $changedir;
841 $prepscript .=
842 ( $pkgdata{main}{source} =~ /\.tar\.gz$/ ? "/bin/gzip" : "" ).
843 ( $pkgdata{main}{source} =~ /\.tar\.bz2$/ ? "/bin/bzip2" : "" ).
844 ( $pkgdata{main}{source} =~ /\.tar\.xz$/ ? "/usr/bin/xz" : "" ).
845 " -dc '$topdir/SOURCES/$pkgdata{main}{source}' | /bin/tar -x".
846 ( $quietunpack ? '' : 'vv' )."f -\n".
847 qq(STATUS=\$?\nif [ \$STATUS -ne 0 ]; then\n exit \$STATUS\nfi\n);
848 }
849
850 if ($altsource) {
851 if ($altsource == 1) { # -a
852 $prepscript .= "cd '$thistarballdir'\n";
853 $prepscript .=
854 ( $pkgdata{sources}{$snum} =~ /\.tar\.gz$/ ? "/bin/gzip" : "" ).
855 ( $pkgdata{sources}{$snum} =~ /\.tar\.bz2$/ ? "/bin/bzip2" : "" ).
856 ( $pkgdata{sources}{$snum} =~ /\.tar\.xz$/ ? "/usr/bin/xz" : "" ).
857 " -dc '$topdir/SOURCES/$pkgdata{sources}{$snum}' | /bin/tar -x".
858 ( $quietunpack ? '' : 'vv' )."f -\n".
859 qq(STATUS=\$?\nif [ \$STATUS -ne 0 ]; then\n exit \$STATUS\nfi\n);
860 } # $altsource == 1
861
862 if ($altsource == 2) { # -b
863 $prepscript .=
864 ( $pkgdata{sources}{$snum} =~ /\.tar\.gz$/ ? "/bin/gzip" : "" ).
865 ( $pkgdata{sources}{$snum} =~ /\.tar\.bz2$/ ? "/bin/bzip2" : "" ).
866 ( $pkgdata{sources}{$snum} =~ /\.tar\.xz$/ ? "/usr/bin/xz" : "" ).
867 " -dc '$topdir/SOURCES/$pkgdata{sources}{$snum}' | /bin/tar -x".
868 ( $quietunpack ? '' : 'vv' )."f -\n".
869 qq(STATUS=\$?\nif [ \$STATUS -ne 0 ]; then\n exit \$STATUS\nfi\n);
870 $prepscript .= "cd '$thistarballdir'\n";
871 } # $altsource == 2
872 }
873
874# rpm doesn't seem to do the chowns any more
875# qq([ `/usr/bin/id -u` = '0' ] && /bin/chown -Rhf root .\n).
876# qq([ `/usr/bin/id -u` = '0' ] && /bin/chgrp -Rhf root .\n).
877 $prepscript .=
878 qq(/bin/chmod -Rf a+rX,u+w,g-w,o-w .\n);
879
880 } elsif ( my ($patchnum,$patchopts) = (/^\%patch([^\s]+)(\s+.+)?$/) ) {
881 chomp $patchnum;
882 $prepscript .= qq(echo "Patch #$patchnum ($pkgdata{main}{"patch$patchnum"}):"\n);
883 # If there are options passed, use'em.
884 # Otherwise, catch a bare %patch and ASS-U-ME it's '-p0'-able.
885 # Will break on options that don't provide -pnn, but what the hell.
886 # Need to decompress .bz2 and .gz patches on the fly. Not sure why one
887 # would ever have such things, but there they are... and rpmbuild supports 'em
888 # patch originally suggested by Lucian Cristian for .bz2
889 # reworked and expanded to support .Z/.gz/.xz as well
890 if ( $pkgdata{main}{"patch$patchnum"} =~ /\.(?:Z|gz|bz2|xz)$/ ) {
891 my $decompressor;
892 $decompressor = 'gzip' if $pkgdata{main}{"patch$patchnum"} =~ /\.(?:Z|gz)$/;
893 $decompressor = 'bzip2' if $pkgdata{main}{"patch$patchnum"} =~ /\.bz2$/;
894 $decompressor = 'xz' if $pkgdata{main}{"patch$patchnum"} =~ /\.xz$/;
895 $prepscript .= qq(/bin/$decompressor -d < $topdir/SOURCES/$pkgdata{main}{"patch$patchnum"} | patch );
896 $prepscript .= $patchopts if $patchopts;
897 $prepscript .= "-p0" if !$patchopts;
898 $prepscript .= qq( -s\nSTATUS=\$?\nif [ \$STATUS -ne 0 ]; then\n exit \$STATUS\nfi\n);
899 } else {
900 $prepscript .= "patch ";
901 $prepscript .= $patchopts if $patchopts;
902 $prepscript .= "-p0" if !$patchopts;
903 $prepscript .= " -s <$topdir/SOURCES/".$pkgdata{main}{"patch$patchnum"}."\n";
904 }
905 } else {
906 $prepscript .= expandmacros($_,'gp');
907 }
908 next LINE;
909 } # prep
910
911 if ($stage eq 'build') {
912 # %build. This is pretty much just a shell script. There
913 # aren't many local macros to deal with.
914 if (/^\%configure/) {
915 $buildscript .= expandmacros($_,'cgbp');
916 } elsif (/^\%\{__make\}/) {
917 $buildscript .= expandmacros($_,'mgbp');
918 } else {
919 $buildscript .= expandmacros($_,'gp');
920 }
921 next LINE;
922 } # build
923
924 if ($stage eq 'install') {
925 if (/^\%makeinstall/) {
926 $installscript .= expandmacros($_,'igbp');
927 } else {
928 $installscript .= expandmacros($_,'gp');
929 }
930 next LINE;
931 } # install
932
933 if ($stage eq 'clean') {
934 $cleanscript .= expandmacros($_,'gp');
935 next LINE;
936 } # clean
937
938 if ($stage eq 'prepost') {
939 $pkgdata{$subname}{$scriptlet} .= expandmacros($_,'gp');
940 next LINE;
941 } # prepost
942
943 if ($stage eq 'files') {
944 # need to deal with these someday
945 next LINE if /^\%dir/;
946 next LINE if /^\%defattr/;
947 next LINE if /^\%verify/;
948 # dunno what to do with this; not sure if there's space in Debian's package structure for it.
949 next LINE if /^\%ghost/;
950 # Debian dpkg doesn't speak "%docdir". Meh.
951 next LINE if /^\%docdir/;
952# my $singleton = 0; # don't recall what this was for
953 next LINE if /^\s*#/;
954 next LINE if /^\s*$/;
955
956# create and initialize flags
957 my ($perms, $owner, $group, $conf, $filesline);
958 $perms = $owner = $group = $conf = '-';
959
960 $filesline = $_;
961
962 # strip and flag %attr constructs
963 if ($filesline =~ /\%attr\b/) {
964 # Extract %attr...
965 my ($args) = (/(\%attr\s*\(\s*[\d-]+\s*,\s*["a-zA-Z0-9-]+\s*,\s*["a-zA-Z0-9-]+\s*\))/);
966 $args =~ s/\s+//g;
967 $args =~ s/"//g; # don't think quotes are ever necessary, but they're *allowed*
968 # ... and parse it ...
969 ($perms,$owner,$group) = ($args =~ /\(([\d-]+),([a-zA-Z0-9-]+),([a-zA-Z0-9-]+)/);
970 # ... and wipe it when we're done.
971 $filesline =~ s/\%attr\s*\(\s*[\d-]+\s*,\s*["a-zA-Z0-9-]+\s*,\s*["a-zA-Z0-9-]+\s*\)//;
972 }
973
974 # Conffiles. Note that Debian and RH have similar, but not
975 # *quite* identical ideas of what constitutes a conffile. Nrgh.
976 # Note that dpkg will always ask if you want to replace the file - noreplace
977 # is more or less permanently enabled.
978##fixme
979# also need to handle missingok (file that doesn't exist, but should be removed on uninstall)
980# hmm. not sure if such is **POSSIBLE** with Debian... maybe an addition to %post?
981 if ($filesline =~ /\%config\b(?:\s*\(\s*noreplace\s*\)\s*)?/) {
982 $pkgdata{$subname}{conffiles} = 1; # Flag it for later
983 $conf = 'y';
984 $filesline =~ s/\%config\b(?:\s*\(\s*noreplace\s*\)\s*)?//;
985 }
986
987 # %doc needs extra processing, because it can be a space-separated list, and may
988 # include both full and partial pathnames. The partial pathnames must be fiddled
989 # into place in the %install script, because Debian doesn't really have the concept
990 # of "documentation file" that rpm does. (Debian "documentation files" are files
991 # in /usr/share/doc/<packagename>.)
992##fixme: unhandled case: %doc %defattr. Eeep.
993# don't really know what to do with %defattr, generally. :(
994 if ($filesline =~ /\%doc\b/) {
995 $filesline =~ s/\s*\%doc\s+//;
996
997# this could probably go elsewhere.
998 my $pkgname = $pkgdata{$subname}{name};
999 $pkgname =~ tr/_/-/;
1000
1001 # have to extract the partial pathnames that %doc installs automagically
1002 foreach (split /\s+/, $filesline) {
1003 if (! (/^\%/ or m|^/|) ) {
1004 $doclist{$subname} .= " $_";
1005 my ($element) = m|([^/\s]+/?)$|;
1006 $filesline =~ s|$_|\%{_docdir}/$pkgname/$element|;
1007 }
1008 }
1009 } # $filesline =~ /\%doc\b/
1010
1011 $filesline =~ s/^\s*//; # Just In Case. For, uh, neatness.
1012
1013# due to Debian's total lack of real permissions-processing in its actual package
1014# handling component (dpkg-deb), this can't really be done "properly". We'll have
1015# to add chown/chmod commands to the postinst instead. Feh.
1016 $pkgdata{$subname}{'post'} .= "chown $owner $filesline\n" if $owner ne '-';
1017 $pkgdata{$subname}{'post'} .= "chgrp $group $filesline\n" if $group ne '-';
1018 $pkgdata{$subname}{'post'} .= "chmod $perms $filesline\n" if $perms ne '-';
1019
1020##fixme
1021# need hackery to assure only one filespec per %config. NB: "*" is one filespec. <g>
1022 push @{$pkgdata{$subname}{conflist}}, $filesline if $conf ne '-';
1023
1024 # now that we've got the specials out of the way, we can add things to the appropriate list of files.
1025 # ... and finally everything else
1026 $filelist{$subname} .= " $filesline";
1027
1028 next LINE;
1029 } # files
1030
1031 if ($stage eq 'changelog') {
1032 # this is one of the few places we do NOT generally want to replace macros...
1033 $pkgdata{main}{changelog} .= $_;
1034 }
1035
1036 if ($stage eq 'preamble') {
1037 if (/^summary:\s*(.+)/i) {
1038 $pkgdata{main}{summary} = $1;
1039 } elsif (/^name:\s*(.+)/i) {
1040 $pkgdata{main}{name} = expandmacros($1,'g');
1041 } elsif (/^epoch:\s*(.+)/i) {
1042 $pkgdata{main}{epoch} = expandmacros($1,'g');
1043 } elsif (/^version:\s*(.+)/i) {
1044 $pkgdata{main}{version} = expandmacros($1,'g');
1045 } elsif (/^release:\s*(.+)/i) {
1046 $pkgdata{main}{release} = expandmacros($1,'g');
1047 } elsif (/^group:\s*(.+)/i) {
1048 $pkgdata{main}{group} = $1;
1049 } elsif (/^copyright:\s*(.+)/i) {
1050 $pkgdata{main}{copyright} = $1;
1051 } elsif (/^url:\s*(.+)/i) {
1052 $pkgdata{main}{url} = $1;
1053 } elsif (/^packager:\s*(.+)/i) {
1054 $pkgdata{main}{packager} = $1;
1055 } elsif (/^vendor:\s*(.+)/i) {
1056 $specglobals{vendor} = $1;
1057 } elsif (/^buildroot:\s*(.+)/i) {
1058 $specglobals{buildroot} = $1;
1059 } elsif (my ($sval) = /^source0?:\s*(.+)/i) {
1060 $sval =~ s/\s*$//;
1061 $pkgdata{main}{source} = $sval;
1062 # Do this here since we don't use any URL forms elsewhere (maybe some other time)
1063 $pkgdata{main}{source} =~ s|^.+/([^/]+)$|$1|;
1064 $pkgdata{sources}{0} = $pkgdata{main}{source};
1065 # .tar, .tar.gz, .tar.bz2, .tgz, .xz
1066 die "Unknown Source: header format $sval\n" if $sval !~ /\.(?:tar(?:\.(?:gz|bz2|xz))?|tgz)$/;
1067 } elsif (my ($srcnum, $src) = (/^source([0-9]+):\s*(.+)/i)) {
1068 $src =~ s/\s*$//;
1069 $pkgdata{sources}{$srcnum} = $src;
1070 # Do this here since we don't use any URL forms elsewhere (maybe some other time)
1071 $pkgdata{sources}{$srcnum} =~ s|^.+/([^/]+)$|$1|;
1072 } elsif (/^patch([^:]+):\s*(.+)$/i) {
1073 my $patchname = "patch$1";
1074 $pkgdata{main}{$patchname} = $2;
1075 if ($pkgdata{main}{$patchname} =~ /\//) {
1076 # URL-style patch. Rare but not unheard-of.
1077 my @patchbits = split '/', $pkgdata{main}{$patchname};
1078 $pkgdata{main}{$patchname} = $patchbits[$#patchbits];
1079 }
1080 chomp $pkgdata{main}{$patchname};
1081 } elsif (/^buildarch(?:itecture)?:\s*(.+)/i) {
1082 $pkgdata{main}{arch} = $1;
1083 $pkgdata{main}{arch} =~ s/^noarch$/all/;
1084 $buildarch = $pkgdata{main}{arch};
1085 } elsif (/^buildrequires:\s*(.+)/i) {
1086 $buildreq .= ", $1";
1087 } elsif (/^requires:\s*(.+)/i) {
1088 $pkgdata{main}{requires} .= ", ".expandmacros("$1", 'gp');
1089 } elsif (/^provides:\s*(.+)/i) {
1090 $pkgdata{main}{provides} .= ", $1";
1091 } elsif (/^conflicts:\s*(.+)/i) {
1092 $pkgdata{main}{conflicts} .= ", $1";
1093 } elsif (/^recommends:\s*(.+)/i) {
1094 $pkgdata{main}{recommends} .= ", $1";
1095 warn "Warning: Debian-specific 'Recommends:' outside \%if wrapper\n" if $iflevel == 0;
1096# As of sometime between RHEL 6 and RHEL 7 or so, support was added for Recommends: and Enhances:,
1097# along with shiny new tag Supplements:. We'll continue to warn about them for a while.
1098 } elsif (/^suggests:\s*(.+)/i) {
1099 $pkgdata{main}{suggests} .= ", $1";
1100 warn "Warning: 'Suggests:' outside \%if wrapper\n" if $iflevel == 0;
1101 } elsif (/^enhances:\s*(.+)/i) {
1102 $pkgdata{main}{enhances} .= ", $1";
1103 warn "Warning: 'Enhances:' outside \%if wrapper\n" if $iflevel == 0;
1104 } elsif (/^supplements:\s*(.+)/i) {
1105 $pkgdata{main}{enhances} .= ", $1";
1106 warn "Warning: 'Supplements:' is not natively supported by .deb packages. Downgrading relationship to Enhances:.\n";
1107 } elsif (/^replaces:\s*(.+)/i) {
1108 $pkgdata{main}{replaces} .= ", $1";
1109 warn "Warning: 'Replaces:' outside \%if wrapper\n" if $iflevel == 0;
1110 } elsif (/^obsoletes:\s*(.+)/i) {
1111 $pkgdata{main}{replaces} .= ", $1";
1112 } elsif (/^autoreq(?:prov)?:\s*(.+)/i) {
1113 # we don't handle auto-provides (yet)
1114 $NoAutoReq = 1 if $1 =~ /(?:no|0)/i;
1115 }
1116 next LINE;
1117 } # preamble
1118
1119 } # while <SPEC>
1120
1121 # Parse and replace some more macros. More will be replaced even later.
1122
1123 # Expand macros as necessary.
1124 $scriptletbase = expandmacros($scriptletbase,'gp');
1125
1126 $cleanscript = expandmacros($cleanscript,'gp');
1127
1128 $specglobals{buildroot} = $cmdbuildroot if $cmdbuildroot;
1129 $specglobals{buildroot} = expandmacros($specglobals{buildroot},'gp');
1130
1131 close SPECFILE;
1132} # end parse_spec()
1133
1134
1135## prep()
1136# Writes and executes the %prep script (mostly) built while reading the spec file.
1137sub prep {
1138 # Replace some things here just to make sure.
1139 $prepscript = expandmacros($prepscript,'gp');
1140
1141 # create script filename
1142 my $prepscriptfile = "$tmpdir/deb-tmp.prep.".int(rand(99998)+1);
1143 sysopen(PREPSCRIPT, $prepscriptfile, O_RDWR | O_CREAT | O_EXCL | O_NOFOLLOW)
1144 or die "Can't open/create prep script file $prepscriptfile: $!\n";
1145 print PREPSCRIPT $scriptletbase;
1146 print PREPSCRIPT $prepscript;
1147 close PREPSCRIPT;
1148
1149 # execute
1150 print "Calling \%prep script $prepscriptfile...\n";
1151 system("/bin/sh -e $prepscriptfile") == 0
1152 or die "Can't exec: $!\n";
1153
1154 # and clean up
1155 unlink $prepscriptfile;
1156} # end prep()
1157
1158
1159## build()
1160# Writes and executes the %build script (mostly) built while reading the spec file.
1161sub build {
1162 # Expand the macros
1163 $buildscript = expandmacros($buildscript,'cgbp');
1164
1165 # create script filename
1166 my $buildscriptfile = "$tmpdir/deb-tmp.build.".int(rand(99998)+1);
1167 sysopen(BUILDSCRIPT, $buildscriptfile, O_RDWR | O_CREAT | O_EXCL | O_NOFOLLOW)
1168 or die "Can't open/create build script file $buildscriptfile: $!\n";
1169 print BUILDSCRIPT $scriptletbase;
1170 print BUILDSCRIPT $buildscript;
1171 close BUILDSCRIPT;
1172
1173 # execute
1174 print "Calling \%build script $buildscriptfile...\n";
1175 system("/bin/sh -e $buildscriptfile") == 0
1176 or die "Can't exec: $!\n";
1177
1178 # and clean up
1179 unlink $buildscriptfile;
1180} # end build()
1181
1182
1183## install()
1184# Writes and executes the %install script (mostly) built while reading the spec file.
1185sub install {
1186
1187 # munge %doc entries into place
1188 # rpm handles this with a separate executed %doc script, we're not going to bother.
1189 foreach my $docpkg (keys %doclist) {
1190 my $pkgname = $pkgdata{$docpkg}{name};
1191 $pkgname =~ s/_/-/g;
1192
1193 $installscript .= "DOCDIR=\$RPM_BUILD_ROOT\%{_docdir}/$pkgname\nexport DOCDIR\n";
1194 $installscript .= "mkdir -p \$DOCDIR\n";
1195 $doclist{$docpkg} =~ s/^\s*//;
1196 foreach (split(' ',$doclist{$docpkg})) {
1197 $installscript .= "cp -pr $_ \$DOCDIR/\n";
1198 }
1199 }
1200
1201 # Expand the macros
1202 $installscript = expandmacros($installscript,'igbp');
1203
1204 # create script filename
1205 my $installscriptfile = "$tmpdir/deb-tmp.inst.".int(rand(99998)+1);
1206 sysopen(INSTSCRIPT, $installscriptfile, O_RDWR | O_CREAT | O_EXCL | O_NOFOLLOW)
1207 or die "Can't open/create install script file $installscriptfile: $!\n";
1208 print INSTSCRIPT $scriptletbase;
1209 print INSTSCRIPT $installscript;
1210 close INSTSCRIPT;
1211
1212 # execute
1213 print "Calling \%install script $installscriptfile...\n";
1214 system("/bin/sh -e $installscriptfile") == 0
1215 or die "Can't exec: $!\n";
1216
1217 # and clean up
1218 unlink $installscriptfile;
1219
1220 # final bit: compress manpages if present
1221 # done here cuz I don't grok shell well
1222 # should probably error-check all kinds of things. <g>
1223 if (opendir MANROOT, "$specglobals{buildroot}/usr/share/man") {
1224 my @mansects = readdir MANROOT;
1225 closedir MANROOT;
1226 foreach my $mandir (@mansects) {
1227 next if $mandir !~ /^man/;
1228 opendir MANPAGES, "$specglobals{buildroot}/usr/share/man/$mandir";
1229 my @pagelist = readdir MANPAGES;
1230 closedir MANPAGES; # Slightly safer to to this; no accidental recursion. O_o
1231 foreach my $manpage (@pagelist) {
1232 $manpage = "$specglobals{buildroot}/usr/share/man/$mandir/$manpage";
1233 if ( -f $manpage) {
1234 if ($manpage =~ /^(.+)\.(?:Z|gz|bz2)\n?$/) {
1235 my $newpage = $1;
1236 `gunzip $manpage` if $manpage =~ /\.(?:Z|gz)$/;
1237 `bunzip2 $manpage` if $manpage =~ /\.bz2$/;
1238 $manpage = $newpage;
1239 }
1240 `gzip -9 -n $manpage`;
1241 } elsif ( -l $manpage) {
1242 my $linkdest = readlink $manpage;
1243 $linkdest =~ s/\.(?:Z|gz|bz2)//;
1244 unlink $manpage;
1245 $manpage =~ s/\.(?:Z|gz|bz2)//;
1246 symlink "$linkdest.gz", "$manpage.gz" or print "DEBUG: wibble: symlinking manpage failed: $!\n";
1247 }
1248 }
1249 }
1250 } # if opendir MANROOT
1251} # end install()
1252
1253
1254## binpackage()
1255# Creates the binary .deb package from the installed tree in $specglobals{buildroot}.
1256# Writes and executes a shell script to do so.
1257# Creates miscellaneous files required by dpkg-deb to actually build the package file.
1258# Should handle simple subpackages
1259sub binpackage {
1260
1261 foreach my $pkg (@pkglist) {
1262
1263 $pkgdata{$pkg}{arch} = $hostarch if !$pkgdata{$pkg}{arch}; # Just In Case.
1264
1265 # Make sure we have somewhere to write the .deb file
1266 if (!-e "$topdir/DEBS/$pkgdata{$pkg}{arch}") {
1267 mkdir "$topdir/DEBS/$pkgdata{$pkg}{arch}";
1268 }
1269
1270 # Skip building a package that doesn't have any files or dependencies. True
1271 # metapackages don't have any files, but they depend on a bunch of things.
1272 # Packages with neither have, essentially, no content.
1273 next if
1274 (!$filelist{$pkg} or $filelist{$pkg} =~ /^\s*$/) &&
1275 (!$pkgdata{$pkg}{requires});
1276 $filelist{$pkg} = '' if !$filelist{$pkg};
1277
1278 # Gotta do this first, otherwise we don't have a place to move files from %files
1279 mkdir "$specglobals{buildroot}/$pkg";
1280
1281 # Eliminate any lingering % macros
1282 $filelist{$pkg} = expandmacros $filelist{$pkg}, 'gp';
1283
1284 my @pkgfilelist = split ' ', $filelist{$pkg};
1285 foreach my $pkgfile (@pkgfilelist) {
1286 $pkgfile = expandmacros($pkgfile, 'gp');
1287
1288 # Feh. Manpages don't **NEED** to be gzipped, but rpmbuild does, and so shall we.
1289 # ... and your little info page too!
1290 if ($pkgfile =~ m{/usr/share/(?:man/man|info)}) {
1291 # need to check to see if manpage is gzipped
1292 if (-e "$specglobals{buildroot}$pkgfile") {
1293 # if we've just been pointed to a manpage section with "many" pages,
1294 # we need to gzip them all.
1295 # fortunately, we do NOT need to explicitly track each file for the
1296 # purpose of stuffing them in the package... the original %files
1297 # entry will do just fine.
1298 if ( -d "$specglobals{buildroot}$pkgfile") {
1299 foreach my $globfile (glob("$specglobals{buildroot}$pkgfile/*")) {
1300 gzip $globfile if $globfile !~ m|\.gz$|;
1301 }
1302 } else {
1303 if ($pkgfile !~ m|\.gz$|) {
1304 qx { gzip $specglobals{buildroot}$pkgfile };
1305 $pkgfile .= ".gz";
1306 }
1307 }
1308 } else {
1309 if ($pkgfile !~ m|\.gz$|) {
1310 $pkgfile .= ".gz";
1311 } else {
1312 $pkgfile =~ s/\.gz$//;
1313 qx { gzip $specglobals{buildroot}$pkgfile };
1314 $pkgfile .= ".gz";
1315 }
1316 }
1317 }
1318
1319 my ($fpath,$fname) = ($pkgfile =~ m|(.+?/?)?([^/]+/?)$|); # We don't need $fname now, but we might.
1320 qx { mkdir -p $specglobals{buildroot}/$pkg$fpath }
1321 if $fpath && $fpath ne '';
1322 qx { mv $specglobals{buildroot}$pkgfile $specglobals{buildroot}/$pkg$fpath };
1323 }
1324
1325 # Get the "Depends" (Requires) a la RPM. Ish. We strip the leading
1326 # comma and space here (if needed) in case there were "Requires" specified
1327 # in the spec file - those would precede these.
1328 $pkgdata{$pkg}{requires} .= getreqs("$specglobals{buildroot}/$pkg") if ! $NoAutoReq;
1329
1330 # magic needed to properly version dependencies...
1331 # only provided deps will really be included
1332 $pkgdata{$pkg}{requires} =~ s/^, //; # Still have to do this here.
1333 $pkgdata{$pkg}{requires} =~ s/\s+//g;
1334 my @deps = split /,/, $pkgdata{$pkg}{requires};
1335 my $tmp = '';
1336 foreach my $dep (@deps) {
1337 # Hack up the perl(Class::SubClass) deps into something dpkg can understand.
1338 # May or may not be versioned.
1339 # We do this first so the version rewriter can do its magic next.
1340 if (my ($mod,$ver) = ($dep =~ /^perl\(([A-Za-z0-9\:\-]+)\)([><=]+.+)?/) ) {
1341 $mod =~ s/^perl\(//;
1342 $mod =~ s/\)$//;
1343 $mod =~ s/::/-/g;
1344 $mod =~ tr/A-Z/a-z/;
1345 $mod = "lib$mod-perl";
1346 $mod .= $ver if $ver;
1347 $dep = $mod;
1348 }
1349 if (my ($name,$rel,$value) = ($dep =~ /^([a-zA-Z0-9._-]+)([><=]+)([a-zA-Z0-9._-]+)$/)) {
1350 $tmp .= ", $name ($rel $value)";
1351 } else {
1352 $tmp .= ", $dep";
1353 }
1354 }
1355 ($pkgdata{$pkg}{requires} = $tmp) =~ s/^, //;
1356
1357 # Do this here since we're doing {depends}...
1358 if (defined($pkgdata{$pkg}{provides})) {
1359 $pkgdata{$pkg}{provides} =~ s/^, //;
1360 $pkgdata{$pkg}{provides} = expandmacros($pkgdata{$pkg}{provides},'gp');
1361 }
1362 if (defined($pkgdata{$pkg}{conflicts})) {
1363 $pkgdata{$pkg}{conflicts} =~ s/^, //;
1364 $pkgdata{$pkg}{conflicts} = expandmacros($pkgdata{$pkg}{conflicts},'gp');
1365 }
1366
1367# These are Debian-specific!
1368 if (defined($pkgdata{$pkg}{recommends})) {
1369 $pkgdata{$pkg}{recommends} =~ s/^, //;
1370 $pkgdata{$pkg}{recommends} = expandmacros($pkgdata{$pkg}{recommends},'gp');
1371 }
1372 if (defined($pkgdata{$pkg}{suggests})) {
1373 $pkgdata{$pkg}{suggests} =~ s/^, //;
1374 $pkgdata{$pkg}{suggests} = expandmacros($pkgdata{$pkg}{suggests},'gp');
1375 }
1376 if (defined($pkgdata{$pkg}{enhances})) {
1377 $pkgdata{$pkg}{enhances} =~ s/^, //;
1378 $pkgdata{$pkg}{enhances} = expandmacros($pkgdata{$pkg}{enhances},'gp');
1379 }
1380 if (defined($pkgdata{$pkg}{replaces})) {
1381 $pkgdata{$pkg}{replaces} =~ s/^, //;
1382 $pkgdata{$pkg}{replaces} = expandmacros($pkgdata{$pkg}{replaces},'gp');
1383 }
1384
1385 # Gotta do this next, otherwise the control file has nowhere to go. >:(
1386 mkdir "$specglobals{buildroot}/$pkg/DEBIAN";
1387
1388 # Hack the filename for the package into a Debian-tool-compatible format. GRRRRRR!!!!!
1389 # Have I mentioned I hate Debian Policy?
1390 $pkgdata{$pkg}{name} =~ tr/_/-/;
1391
1392 # create script filename
1393 my $debscriptfile = "$tmpdir/deb-tmp.pkg.".int(rand(99998)+1);
1394 sysopen(DEBSCRIPT, $debscriptfile, O_RDWR | O_CREAT | O_EXCL | O_NOFOLLOW)
1395 or die "Can't open/create package-creation script file $debscriptfile: $!\n";
1396 print DEBSCRIPT $scriptletbase;
1397 print DEBSCRIPT "fakeroot -- dpkg-deb -b $specglobals{buildroot}/$pkg $topdir/DEBS/$pkgdata{$pkg}{arch}/".
1398 "$pkgdata{$pkg}{name}_".
1399 (defined($pkgdata{main}{epoch}) ? "$pkgdata{main}{epoch}:" : '').
1400 "$pkgdata{$pkg}{version}-$pkgdata{main}{release}_$pkgdata{$pkg}{arch}.deb\n";
1401 # %$&$%@#@@#%@@@ Debian and their horrible ugly package names. >:(
1402 close DEBSCRIPT;
1403
1404 $pkgdata{$pkg}{summary} = expandmacros($pkgdata{$pkg}{summary}, 'gp');
1405 my $control = "Package: $pkgdata{$pkg}{name}\n".
1406 "Version: ".(defined($pkgdata{main}{epoch}) ? "$pkgdata{main}{epoch}:" : '').
1407 "$pkgdata{$pkg}{version}-$pkgdata{main}{release}\n".
1408 "Section: ".($pkgdata{$pkg}{group} ? $pkgdata{$pkg}{group} : $pkgdata{main}{group})."\n".
1409 "Priority: optional\n".
1410 "Architecture: $pkgdata{$pkg}{arch}\n".
1411 "Maintainer: $pkgdata{main}{packager}\n".
1412 ( $pkgdata{$pkg}{requires} ne '' ? "Depends: $pkgdata{$pkg}{requires}\n" : '' ).
1413 ( defined($pkgdata{$pkg}{provides}) ? "Provides: $pkgdata{$pkg}{provides}\n" : '' ).
1414 ( defined($pkgdata{$pkg}{conflicts}) ? "Conflicts: $pkgdata{$pkg}{conflicts}\n" : '' ).
1415 ( defined($pkgdata{$pkg}{recommends}) ? "Recommends: $pkgdata{$pkg}{recommends}\n" : '' ).
1416 ( defined($pkgdata{$pkg}{suggests}) ? "Suggests: $pkgdata{$pkg}{suggests}\n" : '' ).
1417 ( defined($pkgdata{$pkg}{enhances}) ? "Enhances: $pkgdata{$pkg}{enhances}\n" : '' ).
1418 ( defined($pkgdata{$pkg}{replaces}) ? "Replaces: $pkgdata{$pkg}{replaces}\n" : '' ).
1419 "Description: $pkgdata{$pkg}{summary}\n";
1420 $pkgdata{$pkg}{desc} = expandmacros($pkgdata{$pkg}{desc}, 'gp');
1421 # Munge things so that Debian tools don't choke on errant blank lines
1422 $pkgdata{$pkg}{desc} =~ s/\s+$//g; # Trim trailing blanks
1423 $pkgdata{$pkg}{desc} =~ s/^ $/ ./mg; # Replace lines consisting of " \n" with " .\n"
1424 $control .= "$pkgdata{$pkg}{desc}\n";
1425
1426 open CONTROL, ">$specglobals{buildroot}/$pkg/DEBIAN/control";
1427 print CONTROL $control;
1428 close CONTROL;
1429
1430 # Iff there are conffiles (as specified in the %files list(s), add'em
1431 # in so dpkg-deb can tag them.
1432 if ($pkgdata{$pkg}{conffiles}) {
1433 open CONFLIST, ">$specglobals{buildroot}/$pkg/DEBIAN/conffiles";
1434 foreach my $conffile (@{$pkgdata{$pkg}{conflist}}) {
1435 $conffile = expandmacros($conffile, 'g');
1436 my @tmp = glob "$specglobals{buildroot}/$pkg/$conffile";
1437 foreach (@tmp) {
1438 s|$specglobals{buildroot}/$pkg/||g; # nrgl. gotta be a better way to do this...
1439 s/\s+/\n/g; # Not gonna support spaces in filenames. Ewww.
1440 print CONFLIST "$_\n";
1441 }
1442 }
1443 close CONFLIST;
1444 }
1445
1446 # found the point of scripts on subpackages.
1447 if ($pkgdata{$pkg}{'pre'}) {
1448 $pkgdata{$pkg}{'pre'} = expandmacros($pkgdata{$pkg}{'pre'},'gp');
1449 open PREINST, ">$specglobals{buildroot}/$pkg/DEBIAN/preinst";
1450 print PREINST "#!/bin/sh\nset -e\n\n";
1451 print PREINST $pkgdata{$pkg}{'pre'};
1452 close PREINST;
1453 chmod 0755, "$specglobals{buildroot}/$pkg/DEBIAN/preinst";
1454 }
1455 if ($pkgdata{$pkg}{'post'}) {
1456 $pkgdata{$pkg}{'post'} = expandmacros($pkgdata{$pkg}{'post'},'gp');
1457 open POSTINST, ">$specglobals{buildroot}/$pkg/DEBIAN/postinst";
1458 print POSTINST "#!/bin/sh\nset -e\n\n";
1459 print POSTINST $pkgdata{$pkg}{'post'};
1460 close POSTINST;
1461 chmod 0755, "$specglobals{buildroot}/$pkg/DEBIAN/postinst";
1462 }
1463 if ($pkgdata{$pkg}{'preun'}) {
1464 $pkgdata{$pkg}{'pre'} = expandmacros($pkgdata{$pkg}{'preun'},'gp');
1465 open PREUNINST, ">$specglobals{buildroot}/$pkg/DEBIAN/prerm";
1466 print PREUNINST "#!/bin/sh\nset -e\n\n";
1467 print PREUNINST $pkgdata{$pkg}{'preun'};
1468 close PREUNINST;
1469 chmod 0755, "$specglobals{buildroot}/$pkg/DEBIAN/prerm";
1470 }
1471 if ($pkgdata{$pkg}{'postun'}) {
1472 $pkgdata{$pkg}{'postun'} = expandmacros($pkgdata{$pkg}{'postun'},'gp');
1473 open POSTUNINST, ">$specglobals{buildroot}/$pkg/DEBIAN/postrm";
1474 print POSTUNINST "#!/bin/sh\nset -e\n\n";
1475 print POSTUNINST $pkgdata{$pkg}{'postun'};
1476 close POSTUNINST;
1477 chmod 0755, "$specglobals{buildroot}/$pkg/DEBIAN/postrm";
1478 }
1479
1480 # execute
1481 print "Calling package creation script $debscriptfile for $pkgdata{$pkg}{name}...\n";
1482 system("/bin/sh -e $debscriptfile") == 0
1483 or die "Can't exec: $!\n";
1484
1485 $finalmessages .= "Wrote binary package ".
1486 "$pkgdata{$pkg}{name}_".
1487 (defined($pkgdata{main}{epoch}) ? "$pkgdata{main}{epoch}:" : '').
1488 "$pkgdata{$pkg}{version}-$pkgdata{main}{release}_$pkgdata{$pkg}{arch}.deb".
1489 " in $topdir/DEBS/$pkgdata{$pkg}{arch}\n";
1490 # and clean up
1491 unlink $debscriptfile;
1492
1493 } # subpackage loop
1494
1495} # end binpackage()
1496
1497
1498## srcpackage()
1499# Builds a .src.deb source package. Note that Debian's idea of
1500# a "source package" is seriously flawed IMO, because you can't
1501# easily copy it as-is.
1502# Not quite identical to RPM, but Good Enough (TM).
1503sub srcpackage {
1504 # In case we were called with -bs.
1505 $pkgdata{main}{name} =~ tr/_/-/;
1506 my $pkgsrcname = "$pkgdata{main}{name}-".
1507 (defined($pkgdata{main}{epoch}) ? "$pkgdata{main}{epoch}:" : '').
1508 "$pkgdata{main}{version}-$pkgdata{main}{release}.sdeb";
1509
1510 my $paxcmd;
1511
1512 # We'll definitely need this later, and *may* need it sooner.
1513 (my $barespec = $specfile) =~ s|.+/([^/]+)$|$1|;
1514
1515 # Copy the specfile to the build tree, but only if it's not there already.
1516##buglet: need to deal with silly case where silly user has put the spec
1517# file in a subdir of %{_topdir}/SPECS. Ewww. Silly user!
1518 if (abs_path($specfile) !~ /^$topdir\/SPECS/) {
1519 $paxcmd .= "cp $specfile %{_topdir}/SPECS/; \n"
1520 }
1521
1522 # use pax -w [file] [file] ... >outfile.sdeb
1523 $paxcmd = "cd $topdir; pax -w ";
1524
1525 # some packages may not have a "main" source.
1526 $paxcmd .= "SOURCES/$pkgdata{main}{source} " if $pkgdata{main}{source};
1527
1528 # create file list: Source[nn], Patch[nn]
1529 foreach my $specbit (keys %{$pkgdata{main}} ) {
1530 next if $specbit eq 'source';
1531 $paxcmd .= "SOURCES/$pkgdata{main}{$specbit} " if $specbit =~ /^patch/;
1532##buglet: need to deal with case where patches are listed as URLs?
1533# or other extended pathnames? Silly !@$%^&!%%!%!! user!
1534 }
1535
1536 foreach my $source (keys %{$pkgdata{sources}}) {
1537 # Skip Source0, since it's also $pkgdata{main}{source}. Could arguably
1538 # just remove that instead, but I think that might backfire.
1539 next if $source eq '0';
1540 $paxcmd .= "SOURCES/$pkgdata{sources}{$source} ";
1541 }
1542
1543 # add the spec file, source package destination, and cd back where we came from.
1544 $paxcmd .= "SPECS/$barespec > $topdir/SDEBS/$pkgsrcname; cd -";
1545
1546 # In case of %-macros...
1547 $paxcmd = expandmacros($paxcmd,'gp');
1548
1549 system "$paxcmd";
1550 $finalmessages .= "Wrote source package $pkgsrcname in $topdir/SDEBS.\n";
1551} # end srcpackage()
1552
1553
1554## clean()
1555# Writes and executes the %clean script (mostly) built while reading the spec file.
1556sub clean {
1557 # Replace some things here just to make sure.
1558 $cleanscript = expandmacros($cleanscript,'gp');
1559
1560 # create script filename
1561 my $cleanscriptfile = "$tmpdir/deb-tmp.clean.".int(rand(99998)+1);
1562 sysopen(CLEANSCRIPT, $cleanscriptfile, O_RDWR | O_CREAT | O_EXCL | O_NOFOLLOW)
1563 or die $!;
1564 print CLEANSCRIPT $scriptletbase;
1565 print CLEANSCRIPT $cleanscript;
1566 close CLEANSCRIPT;
1567
1568 # execute
1569 print "Calling \%clean script $cleanscriptfile...\n";
1570 system("/bin/sh -e $cleanscriptfile") == 0
1571 or die "Can't exec: $!\n";
1572
1573 # and clean up
1574 unlink $cleanscriptfile;
1575} # end clean()
1576
1577
1578## checkbuildreq()
1579# Checks the build requirements (if any)
1580# Spits out a rude warning and returns a true-false error if any
1581# requirements are not met.
1582sub checkbuildreq {
1583 return 1 if $buildreq eq ''; # No use doing extra work.
1584
1585 # expand macros
1586 $buildreq = expandmacros($buildreq,'gp');
1587
1588 if ( ! -e "/usr/bin/dpkg-query" ) {
1589 print "**WARNING** dpkg-query not found. Can't check build-deps.\n".
1590 " Required for sucessful build:\n".$buildreq."\n".
1591 " Continuing anyway.\n";
1592 return 1;
1593 }
1594
1595 my $reqflag = 1; # unset iff a buildreq is missing
1596
1597 $buildreq =~ s/^, //; # Strip the leading comma and space
1598 my @reqlist = split /,\s+/, $buildreq;
1599
1600 my @missinglist;
1601 foreach my $req (@reqlist) {
1602 # from rpmbuild error message
1603 # Dependency tokens must begin with alpha-numeric, '_' or '/'
1604##fixme: check for suitable whitespace around $rel
1605 my ($pkg,$rel,$ver);
1606
1607 # We have two classes of requirements - versioned and unversioned.
1608 if ($req =~ /[><=]/) {
1609 # Pick up the details of versioned buildreqs
1610 ($pkg,$rel,$ver) = ($req =~ /([a-z0-9._-]+)\s+([><=]+)\s+([a-z0-9._-]+)/);
1611 } else {
1612 # And the unversioned ones.
1613 $pkg = $req;
1614 $rel = '>=';
1615 $ver = 0;
1616 }
1617
1618## Apparently a package that has been installed, then uninstalled, has a "known" dpkg status of
1619## "unknown ok not-installed" vs a package that has never been installed which returns nothing. O_o
1620## Virtual packages, of course, *also* show as "not installed" like this (WTF?)
1621## This causes real packages to be misdetected as installed "possible virtual packages" instead of "missing
1622## packages". I don't think there's really a solution until/unless Debian's tools properly register virtual
1623## packages as installed.
1624 my @pkglist = qx { dpkg-query --showformat '\${status}\t\${version}\n' -W $pkg };
1625 if (!$pkglist[0]) {
1626 print " * Missing build-dependency $pkg!\n $pkglist[0]";
1627 $reqflag = 0;
1628 push @missinglist, $pkg;
1629 } else {
1630# real package, installed
1631#kdeugau:~$ dpkg-query --showformat '${status}\t${version}\n' -W libc-client2007e-dev 2>&1
1632#install ok installed 8:2007f~dfsg-1
1633# virtual package, provided by ???
1634#kdeugau:~$ dpkg-query --showformat '${status}\t${version}\n' -W libc-client-dev 2>&1
1635#unknown ok not-installed
1636# real package or virtual package not installed or provided
1637#kdeugau:~$ dpkg-query --showformat '${status}\t${version}\n' -W libdb4.8-dbg 2>&1
1638#dpkg-query: no packages found matching libdb4.8-dbg
1639
1640 my ($reqstat,undef,undef,$reqver) = split /\s+/, $pkglist[0];
1641 if ($reqstat =~ /^unknown/) {
1642 # this seems to be a virtual package.
1643 print " * Warning: $pkg is probably installed but seems to be a virtual package.\n";
1644 } elsif ($reqstat =~ /^install/) {
1645 my ($resp) = qx { dpkg --compare-versions $reqver '$rel' $ver && echo "ok" };
1646 if ($resp !~ /^ok/) {
1647 $reqflag = 0;
1648 print " * Buildreq $pkg is installed, but wrong version ($reqver): Need $ver\n"
1649 }
1650 } else {
1651 # whatever state it's in, it's not completely installed, therefore it's missing.
1652 print " * Missing build-dependency $pkg!\n $pkglist[0]";
1653 $reqflag = 0;
1654 push @missinglist, $pkg;
1655 } # end not installed/installed check
1656 }
1657 } # end req loop
1658
1659 print "To install all missing dependencies, run 'apt-get install ".join(' ', @missinglist)."'.\n" unless $reqflag;
1660
1661 return $reqflag;
1662} # end checkbuildreq()
1663
1664
1665## getreqs()
1666# Find out which libraries/packages are required for any
1667# executables and libs in a given file tree.
1668# (Debian doesn't have soname-level deps; just package-level)
1669# Returns an empty string if the tree contains no binaries.
1670# Doesn't work well on shell scripts. but those *should* be
1671# fine anyway. (Yeah, right...)
1672sub getreqs() {
1673 my $pkgtree = $_[0];
1674
1675 print "Checking library requirements...\n";
1676 my @binlist = qx { find $pkgtree -type f -perm 755 };
1677
1678 if (scalar(@binlist) == 0) {
1679 return '';
1680 }
1681
1682 my @reqlist;
1683 foreach (@binlist) {
1684 push @reqlist, qx { LANG=C ldd $_ };
1685 }
1686
1687 # Get the list of libs provided by this package. Still doesn't
1688 # handle the case where the lib gets stuffed into a subpackage. :/
1689 my @intprovlist = qx { find $pkgtree -type f -name "*.so*" };
1690 my $provlist = '';
1691 foreach (@intprovlist) {
1692 s/$pkgtree//;
1693 $provlist .= "$_";
1694 }
1695
1696 my %reqs;
1697 my $reqlibs = '';
1698 my %reqliblist;
1699
1700 foreach (@reqlist) {
1701 next if /^$pkgtree/;
1702 next if /not a dynamic executable/;
1703 next if m|/lib(?:64)?/ld-linux|; # Hack! Hack! PTHBTT! (libc suxx0rz)
1704 next if /linux-gate.so/; # Kernel hackery for teh W1n!!1!1eleventy-one!1 (Don't ask. Feh.)
1705 next if /linux-vdso.so/; # More kernel hackery. Whee!
1706
1707 # Whee! more hackery to detect provided-here libs. Some apparently return from ldd as "not found".
1708 my ($a,$b) = split / => /;
1709 $a =~ s/\s*//g;
1710 if ($b =~ /not found/) {
1711 next if qx { find $specglobals{buildroot} -name "*$a" };
1712 }
1713
1714 my ($req) = (m|=\>\s+([a-zA-Z0-9._/+-]+)|); # dig out the actual library (so)name.
1715 # And feh, we need the *path*, since I've discovered a new edge case where
1716 # the same libnnn.1.2.3 *file*name is found across *several* lib dirs. >:(
1717
1718 # Ignore libs provided by this package. Note that we don't match
1719 # on word-boundary at the *end* of the lib we're looking for, as the
1720 # looked-for lib may not have the full soname version. (ie, it may
1721 # "just" point to one of the symlinks that get created somewhere.)
1722 next if $provlist =~ /\b$req/;
1723
1724 $reqlibs .= " $req";
1725 $reqliblist{$req} = 1;
1726 }
1727
1728 if (%reqliblist) {
1729 foreach my $rlib (keys %reqliblist) {
1730 my $libpkg = qx { dpkg -S $rlib };
1731 ($libpkg,undef) = split /:/, $libpkg;
1732 $reqs{$libpkg} = 1;
1733 }
1734 }
1735
1736 my $deplist = '';
1737 foreach (keys %reqs) {
1738 $deplist .= ", $_";
1739 }
1740
1741# For now, we're done. We're not going to meddle with versions yet.
1742# Among other things, it's messier than handling "simple" yes/no "do
1743# we have this lib?" deps. >:(
1744
1745 return $deplist;
1746} # end getreqs()
1747
1748
1749## install_sdeb()
1750# Extracts .sdeb contents to %_topdir as appropriate
1751sub install_sdeb {
1752 $srcpkg = abs_path($srcpkg);
1753
1754 my $paxcmd = "cd $topdir; pax -r <$srcpkg; cd -";
1755
1756 # In case of %-macros...
1757 $paxcmd = expandmacros($paxcmd,'gp');
1758
1759 system "$paxcmd";
1760 print "Extracted source package $srcpkg to $topdir.\n";
1761} # end install_sdeb()
1762
1763
1764## expandmacros()
1765# Expands all %{blah} macros in the passed string
1766# Split up a bit with some sections so we don't spend time trying to
1767# expand macros that are only used in a few specific places.
1768sub expandmacros {
1769 my $macrostring = shift;
1770 my $section = shift;
1771
1772 # To allow the FHS-ish %configure and %makeinstall to work The Right Way.
1773 # (Without clobbering the global $specglobals{buildroot}.)
1774 my $prefix = '';
1775
1776 if ($section =~ /c/) {
1777 # %configure macro
1778# Don't know what it's for, don't have a useful default replacement
1779# --program-prefix=%{_program_prefix} \
1780 $macrostring =~ s'%configure'./configure --host=$DEB_HOST_GNU_TYPE \
1781 --build=$DEB_BUILD_GNU_TYPE \
1782 --prefix=%{_prefix} \
1783 --exec-prefix=%{_exec_prefix} \
1784 --bindir=%{_bindir} \
1785 --sbindir=%{_sbindir} \
1786 --sysconfdir=%{_sysconfdir} \
1787 --datadir=%{_datadir} \
1788 --includedir=%{_includedir} \
1789 --libdir=%{_libdir} \
1790 --libexecdir=%{_libexecdir} \
1791 --localstatedir=%{_localstatedir} \
1792 --sharedstatedir=%{_sharedstatedir} \
1793 --mandir=%{_mandir} \
1794 --infodir=%{_infodir} ';
1795 } # done %configure
1796
1797 if ($section =~ /m/) {
1798 $macrostring =~ s'%{__make}'make ';
1799 } # done make
1800
1801# %makeinstall expands with recursive macros in rpm. whee.
1802 if ($section =~ /i/) {
1803 # This is where we need to mangle $prefix.
1804 $macrostring =~ s'%makeinstall'make \
1805 prefix=%{?buildroot:%{buildroot}}%{_prefix} \
1806 exec_prefix=%{?buildroot:%{buildroot}}%{_exec_prefix} \
1807 bindir=%{?buildroot:%{buildroot}}%{_bindir} \
1808 sbindir=%{?buildroot:%{buildroot}}%{_sbindir} \
1809 sysconfdir=%{?buildroot:%{buildroot}}%{_sysconfdir} \
1810 datadir=%{?buildroot:%{buildroot}}%{_datadir} \
1811 includedir=%{?buildroot:%{buildroot}}%{_includedir} \
1812 libdir=%{?buildroot:%{buildroot}}%{_libdir} \
1813 libexecdir=%{?buildroot:%{buildroot}}%{_libexecdir} \
1814 localstatedir=%{?buildroot:%{buildroot}}%{_localstatedir} \
1815 sharedstatedir=%{?buildroot:%{buildroot}}%{_sharedstatedir} \
1816 mandir=%{?buildroot:%{buildroot}}%{_mandir} \
1817 infodir=%{?buildroot:%{buildroot}}%{_infodir} \
1818 install ';
1819 $prefix = $specglobals{buildroot};
1820 } # done %install and/or %makeinstall
1821
1822 # Build data
1823 # Note that these are processed in reverse order to get the substitution order right
1824 if ($section =~ /b/) {
1825# $macrostring =~ s'%{fhs}'host=$DEB_HOST_GNU_TYPE \
1826# build=$DEB_BUILD_GNU_TYPE \
1827 $macrostring =~ s'%{fhs}'prefix=%{_prefix} \
1828 exec-prefix=%{_exec_prefix} \
1829 bindir=%{_bindir} \
1830 sbindir=%{_sbindir} \
1831 sysconfdir=%{_sysconfdir} \
1832 datadir=%{_datadir} \
1833 includedir=%{_includedir} \
1834 libdir=%{_libdir} \
1835 libexecdir=%{_libexecdir} \
1836 localstatedir=%{_localstatedir} \
1837 sharedstatedir=%{_sharedstatedir} \
1838 mandir=%{_mandir} \
1839 infodir=%{_infodir} \
1840';
1841
1842 # Note that the above regex terminates with the extra space
1843 # "Just In Case" of user additions, which will then get neatly
1844 # tagged on the end where they take precedence (supposedly)
1845 # over the "default" ones.
1846
1847 # Now we cascade the macros introduced above. >_<
1848 # Wot ot to go theah:
1849 $macrostring =~ s|%{_mandir}|%{_datadir}/man|g; #/usr/share/man
1850 $macrostring =~ s|%{_infodir}|%{_datadir}/info|g; #/usr/share/info
1851 $macrostring =~ s|%{_oldincludedir}|/usr/include|g; #/usr/include
1852 $macrostring =~ s|%{_includedir}|%{_prefix}/include|g; #/usr/include
1853 $macrostring =~ s|%{_libdir}|%{_exec_prefix}/%{_lib}|g; #/usr/lib
1854 $macrostring =~ s|%{_lib}|lib|g; #?
1855 $macrostring =~ s|%{_localstatedir}|/var|g; #/var
1856 $macrostring =~ s|%{_sharedstatedir}|%{_prefix}/com|g; #/usr/com WTF?
1857 $macrostring =~ s|%{_sysconfdir}|/etc|g; #/etc
1858 $macrostring =~ s|%{_datadir}|%{_prefix}/share|g; #/usr/share
1859 $macrostring =~ s|%{_libexecdir}|%{_exec_prefix}/libexec|g; #/usr/libexec
1860 $macrostring =~ s|%{_sbindir}|%{_exec_prefix}/sbin|g; #/usr/sbin
1861 $macrostring =~ s|%{_bindir}|%{_exec_prefix}/bin|g; #/usr/bin
1862 $macrostring =~ s|%{_exec_prefix}|%{_prefix}|g; #/usr
1863 $macrostring =~ s|%{_prefix}|/usr|g; #/usr
1864 } # done with config section
1865
1866 # Package data
1867 if ($section =~ /p/) {
1868 $macrostring =~ s/\%\{buildroot\}/$specglobals{buildroot}/gi;
1869 $macrostring =~ s/\%\{source0?}/$topdir\/SOURCES\/$pkgdata{main}{source}/gi;
1870 foreach my $source (keys %{$pkgdata{sources}}) {
1871 $macrostring =~ s/\%\{source$source\}/$topdir\/SOURCES\/$pkgdata{sources}{$source}/gi;
1872 }
1873 $macrostring =~ s/\%\{name\}/$pkgdata{main}{name}/gi;
1874 $macrostring =~ s/\%\{version\}/$pkgdata{main}{version}/gi;
1875 $macrostring =~ s/\%\{release\}/$pkgdata{main}{release}/gi;
1876 }
1877
1878 # Globals, and not-so-globals
1879 if ($section =~ /g/) {
1880
1881 $macrostring =~ s|%{_builddir}|%{_topdir}/BUILD|g;
1882# no longer a valid macro/tag
1883# $macrostring =~ s|%{buildsubdir}|$tarballdir|g;
1884 $macrostring =~ s|%{_topdir}|$topdir|g;
1885 $macrostring =~ s|%{_tmppath}|$tmpdir|g;
1886 $macrostring =~ s'%{_docdir}'%{_datadir}/doc'g;
1887
1888 # Standard FHS locations. More or less.
1889 $macrostring =~ s'%{_bindir}'/usr/bin'g;
1890 $macrostring =~ s'%{_sbindir}'/usr/sbin'g;
1891 $macrostring =~ s'%{_mandir}'%{_datadir}/man'g;
1892 $macrostring =~ s'%{_infodir}'%{_datadir}/info'g;
1893 $macrostring =~ s'%{_includedir}'/usr/include'g;
1894 $macrostring =~ s'%{_libdir}'/usr/lib'g;
1895 $macrostring =~ s'%{_sysconfdir}'/etc'g;
1896 $macrostring =~ s'%{_localstatedir}'/var'g;
1897 $macrostring =~ s'%{_prefix}'/usr'g;
1898
1899 # FHS-ish locations that aren't quite actually FHS-specified.
1900 $macrostring =~ s'%{_datadir}'/usr/share'g;
1901
1902 # special %define's. Handle the general case where we eval anything.
1903 # Even more general: %(...) is a spec-parse-time shell code wrapper.
1904 # Prime example:
1905 #%define perl_vendorlib %(eval "`perl -V:installvendorlib`"; echo $installvendorlib)
1906 if ($macrostring =~ /\%\((.+)\)/) {
1907 my $shellstr = $1;
1908 # Oy vey this gets silly for the perl bits. Executing a shell to
1909 # call Perl to get the vendorlib/sitelib/whatever "core" globals.
1910 # This can do more, but... eww.
1911 $shellstr = qx { /bin/sh -c '$shellstr' }; # Yay! ' characters apparently get properly exscapededed.
1912 $macrostring =~ s/\%\(.+\)/$shellstr/;
1913 }
1914
1915 # support for **some** %if constructs. Note that this breaks somewhat if
1916 # there's no value specified... but so does rpm.
1917
1918 my $tmpcount = 0; # runaway shutdown. Not really sure how else to avoid getting stuck.
1919 while ($macrostring =~ m/\%\{([?!]+)([a-z0-9_.-]+)(?:\:([a-z0-9_.\/\-\\]+)?)?\}/g) { #Whew....
1920 my $qex = $1;
1921 my $macro = $2;
1922 my $value = (defined($3) ? $3 : '');
1923
1924 my $neg = '1' if $qex =~ /\!/;
1925 if ($specglobals{$macro}) {
1926 $value = '' if $neg;
1927 } else {
1928 $value = '' if !$neg;
1929 }
1930 $macrostring =~ s/\%\{[?!]+[a-z0-9_.-]+(?:\:([a-z0-9_.\/\-\\]+)?)?\}/$value/;
1931
1932# not certain about this, but I don't want to run away. It *can* happen if planned carefully. :/
1933$tmpcount++;
1934# %makeinstall has 13 occurrences. D'Oh!
1935die "excessive recursive macro replacement; dying.\n" if $tmpcount > 14;
1936
1937 } # while()
1938
1939 # Misc expansions
1940 $macrostring =~ s|%{_arch}|$hostarch|g;
1941 $macrostring =~ s|%{optflags}|$optflags{$hostarch}|g;
1942 $macrostring =~ s|%{_vendor}|$specglobals{'_vendor'}|g;
1943
1944 # system programs. RPM uses a global config file for these; we'll just
1945 # ASS-U-ME and make life a little simpler.
1946 if ($macrostring =~ /\%\{\_\_([a-z0-9_-]+)\}/) {
1947# see /usr/lib/rpm/macros for most of the list. we should arguably just parse that file, but.. ow.
1948 $macrostring =~ s|%{__([a-z0-9_-]+)}|$1|g;
1949 }
1950
1951# should probably stick a "no runaway" flag in here... Just In Case...
1952 # %define's
1953# note to self: find out valid chars for %define name/label so we can parse them
1954 while (my ($key) = ($macrostring =~ /%{([a-z0-9_]+)}/i) ) {
1955# hrm. This needs thinking.
1956#die "A horrible death! \%{$key}, '$macrostring'\n" if !$specglobals{$key};
1957 $macrostring =~ s|%{$key}|$specglobals{$key}|g;
1958 # wanna limit this to "... if $specglobals{$key}", but need more magic
1959 }
1960
1961 # Perl @INC/...lib locations, and other related bits.
1962 $macrostring =~ s|%{perl_archlib}|$Config{installarchlib}|g;
1963 $macrostring =~ s|%{perl_sitelib}|$Config{installsitelib}|g;
1964 $macrostring =~ s|%{perl_sitearch}|$Config{installsitearch}|g;
1965 $macrostring =~ s|%{perl_vendorlib}|$Config{installvendorlib}|g;
1966 $macrostring =~ s|%{perl_vendorarch}|$Config{installvendorarch}|g;
1967
1968 } # done with globals section
1969
1970 return $macrostring;
1971} # end expandmacros()
1972
1973
1974
1975__END__
1976
1977
1978
1979=head1 NAME
1980
1981debbuild - Build Debian-compatible .deb packages from RPM .spec files
1982
1983=head1 SYNOPSIS
1984
1985 debbuild {-ba|-bb|-bp|-bc|-bi|-bl|-bs} [build-options] file.spec
1986
1987 debbuild {-ta|-tb|-tp|-tc|-ti|-tl|-ts} [build-options] file.tar.{gz|bz2|xz}
1988
1989 debbuild --rebuild file.{src.rpm|sdeb}
1990
1991 debbuild --showpkgs
1992
1993 debbuild -i foo.sdeb
1994
1995=head1 DESCRIPTION
1996
1997debbuild attempts to build Debian-friendly semi-native packages from RPM spec files,
1998RPM-friendly tarballs, and RPM source packages (.src.rpm files). It accepts I<most> of the
1999options rpmbuild does, and should be able to interpret most spec files usefully. Perl
2000modules should be handled via CPAN+dh-make-perl instead as it's simpler than even tweaking
2001a .spec template.
2002
2003As far as possible, the command-line options are identical to those from rpmbuild, although
2004several rpmbuild options are not supported:
2005
2006 --recompile
2007 --showrc
2008 --buildroot
2009 --clean
2010 --nobuild
2011 --rmsource
2012 --rmspec
2013 --sign
2014 --target
2015
2016Some of these could probably be trivially added. Feel free to send me a patch. ;)
2017
2018Complex spec files will most likely not work well, if at all. Rewrite them from scratch -
2019you'll have to make heavy modifications anyway.
2020
2021If you see something you don't like, mail me. Send a patch if you feel inspired. I don't
2022promise I'll do anything other than say "Yup, that's broken" or "Got your message".
2023
2024The source package container I invented for debbuild, the .sdeb file, can be "installed"
2025with debbuild -i exactly the same way as a .src.rpm can be installed with "rpm -i". Both
2026will unpack the file and place the source(s) and .spec file in the appropriate places in
2027%_topdir/SOURCES and %_topdir/SPECS respectively.
2028
2029=head1 ASSUMPTIONS
2030
2031As with rpmbuild, debbuild makes some assumptions about your system.
2032
2033=over 4
2034
2035=item *
2036
2037Either you have rights to do as you please under /usr/src/debian, or you have created a file
2038~/.debmacros containing a suitable %_topdir definition.
2039
2040Both rpmbuild and debbuild require the directories %_topdir/{BUILD,SOURCES,SPECS}. However,
2041where rpmbuild requires the %_topdir/{RPMS,SRPMS} directories, debbuild
2042requires %_topdir/{DEBS,SDEBS} instead. Create them in advance;
2043some subdirectories are created automatically as needed, but most are not.
2044
2045=item *
2046
2047/var/tmp must allow script execution - rpmbuild and debbuild both rely on creating and
2048executing shell scripts for much of their functionality. By default, debbuild also creates
2049install trees under /var/tmp - however this is (almost) entirely under the control of the
2050package's .spec file.
2051
2052=item *
2053
2054If you wish to --rebuild a .src.rpm, your %_topdir for both debbuild and rpmbuild must either
2055match, or be suitably symlinked one direction or another so that both programs are effectively
2056working in the same tree. (Or you could just manually wrestle files around your system.)
2057
2058You could symlink ~/.rpmmacros to ~/.debmacros (or vice versa) and save yourself some hassle
2059if you need to rebuild .src.rpm packages on a regular basis. Currently debbuild only uses the
2060%_topdir macro definition, although there are many more things that rpmbuild can use from
2061~/.rpmmacros.
2062
2063=back
2064
2065=head1 ERRATA
2066
2067debbuild deliberately does a few things differently from rpm.
2068
2069=head2 BuildArch or BuildArchitecture
2070
2071rpm takes the last BuildArch entry it finds in the .spec file, whatever it is, and runs with
2072that for all packages. Debian's repository system is fairly heavily designed around the
2073assumption that a single source package may generate small binary (executable) packages
2074for each arch, and large binary arch-all packages containing shared data.
2075
2076debbuild allows this by using the architecture specified by (in order of preference):
2077
2078=over 4
2079
2080=item * Host architecture
2081
2082=item * BuildArch specified in .spec file preamble
2083
2084=item * "Last specified" BuildArch for packages with several subpackages
2085
2086=item * BuildArch specified in the %package section for that subpackage
2087
2088=back
2089
2090=head2 Finding out what packages should be built (--showpkgs)
2091
2092rpmbuild does not include any convenient method I know of to list the packages a spec file
2093will produce. Since I needed this ability for another tool, I added it.
2094
2095It requires the .spec file for the package, and produces a list of full package filenames
2096(without path data) that would be generated by one of --rebuild, -ta, -tb, -ba, or -bb.
2097This includes the .sdeb source package.
2098
2099=head1 AUTHOR
2100
2101debbuild was written by Kris Deugau <kdeugau@deepnet.cx>. A version that approximates
2102current is available at http://www.deepnet.cx/debbuild/.
2103
2104=head1 BUGS
2105
2106Funky Things Happen if you forget a command-line option or two. I've been too lazy to bother
2107fixing this.
2108
2109Many macro expansions are unsupported or incompletely supported.
2110
2111The generated scriptlets don't quite match those from rpmbuild exactly. There are extra
2112environment variables and preprocessing that I haven't needed (yet).
2113
2114Dcumentation, such as it is, will likely remain perpetually out of date.
2115
2116%_topdir and the five "working" directories under %_topdir could arguably be created by
2117debbuild. However, rpmbuild doesn't create these directories either.
2118
2119debbuild's %setup -q is arguably less buggy than rpmbuild's implementation; with rpmbuild
2120it must appear before -a or -b at least to be effective. debbuild does not care.
2121
2122%setup -c, -a, and -b should arguably throw errors if specified together; otherwise the
2123results are almost certainly not what you want to happen.
2124
2125=head1 SEE ALSO
2126
2127rpm(8), rpmbuild(8), and pretty much any document describing how to write a .spec file.
2128
2129=cut
Note: See TracBrowser for help on using the repository browser.