source: trunk/debbuild@ 117

Last change on this file since 117 was 117, checked in by kdeugau, 17 years ago

/trunk

Gzip manpages as needed, and modify the files list(s) to match so we
don't try moving/copying files that don't exist (any more).

  • Property svn:executable set to *
  • Property svn:keywords set to Date Rev Author
File size: 56.2 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: 2007-07-19 20:33:34 +0000 (Thu, 19 Jul 2007) $
9# SVN revision $Rev: 117 $
10# Last update by $Author: kdeugau $
11###
12# Copyright 2005-2007 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
34# regex debugger
35#use re "debug";
36
37# Program flow:
38# -> Parse/execute "system" config/macros (if any - should be rare)
39# -> Parse/execute "user" config/macros (if any - *my* requirement is %_topdir)
40# -> Parse command line for options, spec file/tarball/.src.deb (NB - also accept .src.rpm)
41
42sub expandmacros;
43
44# User's prefs for dirs, environment, etc,etc,etc.
45# config file ~/.debmacros
46# Default ordered search paths for config/macros:
47# /usr/lib/rpm/rpmrc /usr/lib/rpm/redhat/rpmrc /etc/rpmrc ~/.rpmrc
48# /usr/lib/rpm/macros /usr/lib/rpm/redhat/macros /etc/rpm/macros ~/.rpmmacros
49# **NOTE: May be possible to (ab)use bits of debhelper
50
51# Build tree
52# default is /usr/src/debian/{BUILD,SOURCES,SPECS,DEBS,SDEBS}
53
54# Globals
55my $finalmessages = ''; # A place to stuff messages that I want printed at the *very* end of any processing.
56my $specfile;
57my $tarball;
58my $srcpkg;
59my $cmdbuildroot;
60my $tarballdir = '%{name}-%{version}'; # We do this in case of a spec file not using %setup...
61my %specglobals; # For %define's in specfile, among other things.
62
63$specglobals{'_vendor'} = 'debbuild';
64
65# Initialized globals
66my $verbosity = 0;
67my $NoAutoReq = 0;
68my %cmdopts = (type => '',
69 stage => 'a',
70 short => 'n'
71 );
72my $topdir = "/usr/src/debian";
73my $buildroot = "%{_tmppath}/%{name}-%{version}-%{release}.root".int(rand(99998)+1);
74
75# "Constants"
76my %targets = ('p' => 'Prep',
77 'c' => 'Compile',
78 'i' => 'Install',
79 'l' => 'Verify %files',
80 'a' => 'Build binary and source',
81 'b' => 'Build binary',
82 's' => 'Build source'
83 );
84# Ah, the joys of multiple architectures. :( Feh.
85# As copied from rpm
86my %optflags = ( 'i386' => '-O2 -g -march=i386 -mcpu=i686',
87 'amd64' => '-O2 -g'
88 );
89my $hostarch; # we set this later...
90my $scriptletbase =
91q(#!/bin/sh
92
93 RPM_SOURCE_DIR="%{_topdir}/SOURCES"
94 RPM_BUILD_DIR="%{_topdir}/BUILD"
95 RPM_OPT_FLAGS="%{optflags}"
96 RPM_ARCH="%{_arch}"
97 RPM_OS="linux"
98 export RPM_SOURCE_DIR RPM_BUILD_DIR RPM_OPT_FLAGS RPM_ARCH RPM_OS
99 RPM_DOC_DIR="/usr/share/doc"
100 export RPM_DOC_DIR
101 RPM_PACKAGE_NAME="%{name}"
102 RPM_PACKAGE_VERSION="%{version}"
103 RPM_PACKAGE_RELEASE="%{release}"
104 export RPM_PACKAGE_NAME RPM_PACKAGE_VERSION RPM_PACKAGE_RELEASE
105 RPM_BUILD_ROOT="%{buildroot}"
106 export RPM_BUILD_ROOT
107);
108foreach (`dpkg-architecture`) {
109 s/=(.+)/="$1"/;
110 $scriptletbase .= " $_";
111 ($hostarch) = (/^DEB_HOST_ARCH="(.+)"$/) if /DEB_HOST_ARCH=/;
112}
113$scriptletbase .=
114q(
115 set -x
116 umask 022
117 cd %{_topdir}/BUILD
118);
119
120# Hackery to try to bring some semblance of sanity to packages built for more
121# than one Debian version at the same time. Whee.
122# /etc/debian-version
123my %distmap = (
124 "3.1.9ubuntu7.1" => "dapper",
125 "4ubuntu2" => "feisty",
126 "3.0" => "woody",
127 "3.1" => "sarge",
128 "4" => "etch",
129 "4.0" => "lenny",
130 "4.0.0" => "sid");
131# Enh. There doesn't seem to be any better way to do this... :(
132{
133 my $basever = qx { dpkg-query --showformat '\${version}' -W base-files };
134 if ($basever =~ /^\d\.\d\.(\d)$/) {
135 $basever =~ s/\.\d$// if $1 ne '0';
136 }
137# want to do something with this... erm, what was I going to do? O_o
138 my $releasever = qx { cat /etc/debian_version };
139 chomp $releasever;
140
141 $specglobals{"debdist"} = $distmap{$basever};
142 $specglobals{"debver"} = $basever; # this may have trouble with Ubuntu versions?
143}
144
145# Package data
146# This is the form of $pkgdata{pkgname}{meta}
147# meta includes Summary, Name, Version, Release, Group, Copyright,
148# Source, URL, Packager, BuildRoot, Description, BuildReq(uires),
149# Requires, Provides
150# 10/31/2005 Maybe this should be flatter? -kgd
151my %pkgdata;
152my @pkglist = ('main'); #sigh
153# Files listing. Embedding this in %pkgdata would be, um, messy.
154my %filelist;
155my %doclist;
156my $buildreq = '';
157
158# Scriptlets
159my $prepscript = '';
160my $buildscript = '';
161# %install doesn't need the full treatment from %clean; just an empty place to install to.
162# NB - rpm doesn't do this; is it really necessary?
163my $installscript = '[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT'."\n";
164my $cleanscript = '';
165
166die "Not enough arguments\n" if #$argv == 0;
167
168# Snag some environment data
169my $tmpdir;
170if (defined $ENV{TMP} && $ENV{TMP} =~ /^(\/var)?\/tmp$/) {
171 $tmpdir = $ENV{TMP};
172} else {
173 $tmpdir = "/var/tmp";
174}
175
176##main
177
178load_userconfig();
179parse_cmd();
180
181if ($cmdopts{install}) {
182 install_sdeb();
183 exit 0;
184}
185
186# output stage of --showpkgs
187if ($cmdopts{type} eq 'd') {
188 parse_spec();
189 foreach my $pkg (@pkglist) {
190 $pkgdata{$pkg}{name} =~ tr/_/-/;
191
192 my $pkgfullname = "$pkgdata{$pkg}{name}_".
193 (defined($pkgdata{main}{epoch}) ? "$pkgdata{main}{epoch}:" : '').
194 "$pkgdata{$pkg}{version}-$pkgdata{main}{release}_$pkgdata{$pkg}{arch}.deb";
195
196 print "$pkgfullname\n" if $filelist{$pkg};
197
198 }
199 # Source package
200 print "$pkgdata{main}{name}-".
201 (defined($pkgdata{main}{epoch}) ? "$pkgdata{main}{epoch}:" : '').
202 "$pkgdata{main}{version}-$pkgdata{main}{release}.sdeb\n";
203 exit 0;
204}
205
206# Stick --rebuild handling in here - basically install_sdeb()
207# followed by tweaking options to run with -ba
208if ($cmdopts{type} eq 's') {
209 if ($srcpkg =~ /\.src\.rpm$/) {
210 my @srclist = qx { rpm -qlp $srcpkg };
211 foreach (@srclist) {
212 chomp;
213 $specfile = "$topdir/SPECS/$_" if /\.spec$/;
214 }
215 qx { rpm -i $srcpkg };
216 } else {
217 install_sdeb();
218 my @srclist = qx { pax < $srcpkg };
219 foreach (@srclist) {
220 chomp;
221 $specfile = "$topdir/$_" if /SPECS/;
222 }
223 }
224 $cmdopts{type} = 'b';
225 $cmdopts{stage} = 'a';
226}
227
228if ($cmdopts{type} eq 'b') {
229 # Need to read the spec file to find the tarball. Note that
230 # this also generates most of the shell script required.
231 parse_spec();
232 die "Can't build $pkgdata{main}{name}: build requirements not met.\n"
233 if !checkbuildreq();
234}
235
236if ($cmdopts{type} eq 't') {
237 # Need to unpack the tarball to find the spec file. Sort of the inverse of -b above.
238 # zcat $tarball |tar -t |grep .spec
239 # collect some info about the tarball
240 $specfile = "$topdir/BUILD/". qx { zcat $tarball |tar -t |grep -e '[\.]spec\$' };
241 chomp $specfile;
242 my ($fileonly, $dirname) = ($tarball =~ /(([a-zA-Z0-9._-]+)\.tar\.(?:gz|bz2))$/);
243
244 $tarball = abs_path($tarball);
245 my $unpackcmd = "cd $topdir/BUILD; tar -".
246 ( $tarball =~ /\.tar\.gz$/ ? "z" : "" ).
247 ( $tarball =~ /\.tar\.bz2$/ ? "j" : "" ). "xf $tarball";
248 system "$unpackcmd";
249 system "cp $tarball $topdir/SOURCES/$fileonly";
250 system "cp $specfile $topdir/SPECS/";
251 parse_spec();
252 die "Can't build $pkgdata{main}{name}: build requirements not met.\n"
253 if !checkbuildreq();
254}
255
256# -> srcpkg if -.s
257if ($cmdopts{stage} eq 's') {
258 srcpackage();
259 exit 0;
260}
261
262# Hokay. Need to:
263# -> prep if -.p OR (-.[cilabs] AND !--short-circuit)
264if ($cmdopts{stage} eq 'p' || ($cmdopts{stage} =~ /[cilabs]/ && $cmdopts{short} ne 'y')) {
265 prep();
266}
267# -> build if -.c OR (-.[ilabs] AND !--short-circuit)
268if ($cmdopts{stage} eq 'c' || ($cmdopts{stage} =~ /[ilabs]/ && $cmdopts{short} ne 'y')) {
269 build();
270}
271# -> install if -.[ilabs]
272#if ($cmdopts{stage} eq 'i' || ($cmdopts{stage} =~ /[labs]/ && $cmdopts{short} ne 'y')) {
273if ($cmdopts{stage} =~ /[ilabs]/) {
274 install();
275#foreach my $pkg (@pkglist) {
276# print "files in $pkg:\n ".$filelist{$pkg}."\n";
277#}
278
279}
280# -> binpkg and srcpkg if -.a
281if ($cmdopts{stage} eq 'a') {
282 binpackage();
283 srcpackage();
284 clean();
285}
286# -> binpkg if -.b
287if ($cmdopts{stage} eq 'b') {
288 binpackage();
289 clean();
290}
291
292# Spit out any closing remarks
293print $finalmessages;
294
295# Just in case.
296exit 0;
297
298
299## load_userconfig()
300# Loads user configuration (if any)
301# Currently only handles .debmacros
302# Needs to handle "other files"
303sub load_userconfig {
304 my $homedir = (getpwuid($<))[7];
305 if (-e "$homedir/.debmacros") {
306 open USERMACROS,"<$homedir/.debmacros";
307 while (<USERMACROS>) {
308 # And we also only handle a few macros at the moment.
309 if (/^\%_topdir/) {
310 my (undef,$tmp) = split /\s+/, $_;
311 $topdir = $tmp;
312 }
313 next if /^\%_/;
314 # Allow arbitrary definitions. Note that we're only doing simple defs here for now.
315 if (/^\%([a-z0-9]+)\s+(.+)$/) {
316 $specglobals{$1} = $2;
317 }
318 }
319 }
320} # end load_userconfig()
321
322
323## parse_cmd()
324# Parses command line into global hash %cmdopts, other globals
325# Options based on rpmbuild's options
326sub parse_cmd {
327 # Don't feel like coding my own option parser...
328 #use Getopt::Long;
329 # ... but I may have to: (OTOH, rpm uses popt, so maybe we can too.)
330 #use Getopt::Popt qw(:all);
331 # Or not. >:( Stupid Debian lack of findable Perl module names in packages.
332
333 # Stuff it.
334 my $prevopt = '';
335 foreach (@ARGV) {
336 chomp;
337
338 # Is it an option?
339 if (/^-/) {
340
341 # Is it a long option?
342 if (/^--/) {
343 if (/^--short-circuit/) {
344 $cmdopts{short} = 'y';
345 } elsif (/^--rebuild/) {
346 $cmdopts{type} = 's';
347 } elsif (/^--showpkgs/) {
348 $cmdopts{type} = 'd'; # d for 'diagnostic' or 'debug' or 'dump'
349 } elsif (/^--define/) {
350 # nothing to do? Can't see anything needed, we handle the actual definition later.
351 } else {
352 print "Long option $_ not handled\n";
353 }
354 } else {
355 # Not a long option
356 if (/^-[bt]/) {
357 if ($cmdopts{stage} eq 's') {
358 # Mutually exclusive options.
359 die "Can't use $_ with --rebuild\n";
360 } else {
361 # Capture the type (from "bare" files or tarball) and the stage (prep, build, etc)
362 ($cmdopts{stage}) = (/^-[bt]([pcilabs])/);
363 ($cmdopts{type}) = (/^-([bt])[pcilabs]/);
364 }
365 } elsif (/^-v/) {
366 # bump verbosity. Not sure what I'll actually do here...
367 } elsif (/^-i/) {
368 $cmdopts{install} = 1;
369 $prevopt = '-i';
370 } else {
371 die "Bad option $_\n";
372 }
373 }
374
375 } else { # Not an option argument
376
377 # --buildroot is the only option that takes an argument
378 # Therefore, any *other* bare arguments are the spec file,
379 # tarball, or source package we're operating on - depending
380 # on which one we meet.
381 if ($prevopt eq '--buildroot') {
382 $cmdbuildroot = $_;
383 } elsif ($prevopt eq '--define') {
384 my ($macro,$value) = (/([a-z0-9_.-]+)(?:\s+(.+))?/);
385 if ($value) {
386 $specglobals{$macro} = $value;
387 } else {
388 warn "WARNING: missing value for macro $macro in --define! Ignoring.\n";
389 }
390 } elsif ($prevopt eq '-i') {
391 $srcpkg = $_;
392 } else {
393 if ($cmdopts{type} eq 's') {
394 # Source package
395 if (!/(sdeb|\.src\.rpm)$/) {
396 die "Can't --rebuild with $_\n";
397 }
398 $srcpkg = $_;
399 } elsif ($cmdopts{type} eq 'b' || $cmdopts{type} eq 'd') {
400 # Spec file
401 $specfile = $_;
402 } else {
403 # Tarball build. Need to extract tarball to find spec file. Whee.
404 $tarball = $_;
405 }
406 }
407 }
408 $prevopt = $_;
409 } # foreach @ARGV
410
411 # Some cross-checks. rpmbuild limits --short-circuit to just
412 # the "compile" and "install" targets - with good reason IMO.
413 # Note that --short-circuit with -.p is not really an error, just redundant.
414 # NB - this is NOT fatal, just ignored!
415 if ($cmdopts{short} eq 'y' && $cmdopts{stage} =~ /[labs]/) {
416 warn "Can't use --short-circuit for $targets{$cmdopts{stage}} stage. Ignoring.\n";
417 $cmdopts{short} = 'n';
418 }
419
420 # Valid options, with example arguments (if any):
421# Build from .spec file; mutually exclusive:
422 # -bp
423 # -bc
424 # -bi
425 # -bl
426 # -ba
427 # -bb
428 # -bs
429# Build from tarball; mutually exclusive:
430 # -tp
431 # -tc
432 # -ti
433 # -ta
434 # -tb
435 # -ts
436# Build from .src.(deb|rpm)
437 # --rebuild
438 # --recompile
439
440# General options
441 # --buildroot=DIRECTORY
442 # --clean
443 # --nobuild
444 # --nodeps
445 # --nodirtokens
446 # --rmsource
447 # --rmspec
448 # --short-circuit
449 # --target=CPU-VENDOR-OS
450
451 #my $popt = new Getopt::Popt(argv => \@ARGV, options => \@optionsTable);
452
453} # end parse_cmd()
454
455
456## parse_spec()
457# Parse the .spec file.
458sub parse_spec {
459 open SPECFILE,"<$specfile" or die "specfile ($specfile) barfed: $!";
460
461 my $iflevel = 0;
462 my $buildarch = $hostarch;
463 $pkgdata{main}{arch} = $hostarch;
464
465 my $stage = 'preamble';
466 my $subname = 'main';
467 my $scriptlet;
468
469# Basic algorithm:
470# For each line
471# if it's a member of an %if construct, branch and see which segment of the
472# spec file we need to parse and which one gets discarded, then
473# short-circuit back to the top of the loop.
474# if it's a %section, bump the stage. Preparse addons to the %section line
475# (eg subpackage) and stuff them in suitable loop-global variables, then
476# short-circuit back to the top of the loop.
477# Otherwise, parse the line according to which section we're supposedly
478# parsing right now
479
480LINE: while (<SPECFILE>) {
481 next if /^#/ && $stage eq 'preamble'; # Ignore comments...
482 next if /^\s*$/ && $stage eq 'preamble'; # ... and blank lines.
483
484# preprocess %define's
485 if (my ($key, $def) = (/^\%define\s+([^\s]+)\s+(.+)$/) ) {
486 $specglobals{$key} = expandmacros($def,'g');
487 }
488
489 if (/^\%if/) {
490 s/^\%if//;
491 chomp;
492 my $expr = expandmacros($_, 'g');
493 $iflevel++;
494
495 if ($expr !~ /^\s*\d+\s*$/) {
496 # gots a logic statement we want to turn into a 1 or a 0. most likely by eval'ing it.
497
498 $expr =~ s/\s+//g;
499
500# For Great w00tness! New and Improved multilayered logic handling.
501
502 my @bits = split /\b/, $expr;
503 $expr = '';
504 foreach my $bit (@bits) {
505 next if $bit eq '"';
506 $bit =~ s/"//g;
507 $expr .= qq("$bit") if $bit =~ /^\w+$/;
508 $expr .= $bit if $bit !~ /^\w+$/;
509 }
510
511 # Done in this order so we don't cascade incorrectly. Yes, those spaces ARE correct in the replacements!
512 $expr =~ s/==/ eq /g;
513 $expr =~ s/!=/ ne /g;
514 $expr =~ s/<=>/ cmp /g;
515 $expr =~ s/<=/ le /g;
516 $expr =~ s/>=/ ge /g;
517 $expr =~ s/</ lt /g;
518 $expr =~ s/>/ gt /g;
519
520 # Turn it into something that eval's to a number. Maybe not needed? O_o
521 #$expr = "( $expr ? 1 : 0 )";
522
523 $expr = eval $expr;
524 }
525
526 next LINE if $expr != 0; # This appears to be the only case we call false.
527 while (<SPECFILE>) {
528 if (/^\%endif/) {
529 $iflevel--;
530 next LINE;
531 } elsif (/^\%else/) {
532 next LINE;
533 }
534 }
535 }
536 if (/^\%else/) {
537 while (<SPECFILE>) {
538 if (/^\%endif/) {
539 $iflevel--;
540 next LINE;
541 }
542 }
543 }
544 if (/^\%endif/) {
545 $iflevel--;
546 next LINE;
547 } # %if/%else/%endif
548
549# now we pick out the sections and set "state" to parse that section. Fugly but I can't see a better way. >:(
550
551 if (/^\%description(?:\s+(?:-n\s+)?(.+))?/) {
552 $stage = 'desc';
553 $subname = "main";
554 if ($1) { # Magic to add entries to the right package
555 my $tmp = expandmacros("$1", 'g');
556 if (/-n/) { $subname = $tmp; } else { $subname = "$pkgdata{main}{name}-$tmp"; }
557 }
558 next LINE;
559 } # %description
560
561 if (/^\%package\s+(?:-n\s+)?(.+)/) {
562 $stage = 'package';
563 if ($1) { # Magic to add entries to the right package
564 my $tmp = expandmacros("$1", 'g');
565 if (/-n/) { $subname = $tmp; } else { $subname = "$pkgdata{main}{name}-$tmp"; }
566 }
567 push @pkglist, $subname;
568 $pkgdata{$subname}{name} = $subname;
569 $pkgdata{$subname}{version} = $pkgdata{main}{version};
570 # Build "same arch as previous package found" by default. Where rpm just picks the
571 # *very* last one, we want to allow arch<native>+arch-all
572 # (eg, Apache is i386, but apache-manual is all)
573 $pkgdata{$subname}{arch} = $buildarch; # Since it's likely subpackages will NOT have a BuildArch line...
574 next LINE;
575 } # %package
576
577 if (/^\%prep/) {
578 $stage = 'prep';
579 # This really should be local-ish, but we need just the filename for the source
580 $pkgdata{main}{source} =~ s|.+/([^/]+)$|$1|;
581 # Replace some core macros
582 $pkgdata{main}{source} = expandmacros($pkgdata{main}{source},'gp');
583 next LINE;
584 } # %prep
585
586 if (/^\%build/) {
587 $stage = 'build';
588 $buildscript .= "cd $tarballdir\n";
589 next LINE;
590 } # %build
591
592 if (/^\%install/) {
593 $stage = 'install';
594 $installscript .= "cd $tarballdir\n";
595 next LINE;
596 } # %install
597
598 if (/^\%clean/) {
599 $stage = 'clean';
600 $cleanscript .= "cd $tarballdir\n";
601 next LINE;
602 } # %clean
603
604 if (/^\%(pre|post|preun|postun)\b(?:\s+(?:-n\s+)?(.+))?/i) {
605 $stage = 'prepost';
606 $scriptlet = lc $1;
607 $subname = 'main';
608 if ($2) { # Magic to add entries to the right package
609 my $tmp = expandmacros("$2", 'g');
610 if (/-n/) { $subname = $tmp; } else { $subname = "$pkgdata{main}{name}-$tmp"; }
611 }
612 next LINE;
613 } # %pre/%post/%preun/%postun
614
615 if (/^\%files(?:\s+(?:-n\s+)?(.+))?/) {
616 $stage = 'files';
617 $subname = 'main';
618 if ($1) { # Magic to add entries to the right list of files
619 my $tmp = expandmacros("$1", 'g');
620 if (/-n/) { $subname = $tmp; } else { $subname = "$pkgdata{main}{name}-$tmp"; }
621 }
622 next LINE;
623 } # %files
624
625 if (/^\%changelog/) {
626 $stage = 'changelog';
627 $pkgdata{main}{changelog} = '';
628 next LINE;
629 }
630
631# now we handle individual lines from the various sections
632
633 if ($stage eq 'desc') {
634 $pkgdata{$subname}{desc} .= " $_";
635 } # description
636
637 if ($stage eq 'package') {
638 # gotta expand %defines here. Whee.
639 if (my ($dname,$dvalue) = (/^(Summary|Group|Version|Requires|Provides|BuildArch(?:itecture)?):\s+(.+)$/i)) {
640 $dname =~ tr/[A-Z]/[a-z]/;
641 if ($dname =~ /^BuildArch/i) {
642 $dvalue =~ s/^noarch/all/ig;
643 $buildarch = $dvalue; # Emulate rpm's behaviour to a degree
644 $dname = 'arch';
645 }
646 $pkgdata{$subname}{$dname} = expandmacros($dvalue, 'gp');
647 }
648 } # package
649
650 if ($stage eq 'prep') {
651 # Actual handling for %prep section. May have %setup macro; may
652 # include %patch tags, may be just a bare shell script.
653 if (/^\%setup/) {
654 # Parse out the %setup macro. Note that we aren't supporting
655 # many of RPM's %setup features.
656 $prepscript .= "cd $topdir/BUILD\n";
657 if ( /\s+-n\s+([^\s]+)\s+/ ) {
658 $tarballdir = $1;
659 }
660 $tarballdir = expandmacros($tarballdir,'gp');
661 $prepscript .= "rm -rf $tarballdir\n";
662 if (/\s+-c\s+/) {
663 $prepscript .= "mkdir $tarballdir\ncd $tarballdir\n";
664 }
665 $prepscript .= "tar -".
666 ( $pkgdata{main}{source} =~ /\.tar\.gz$/ ? "z" : "" ).
667 ( $pkgdata{main}{source} =~ /\.tar\.bz2$/ ? "j" : "" ).
668 ( /\s+-q\s+/ ? '' : 'vv' )."xf ".
669 "$topdir/SOURCES/$pkgdata{main}{source}\n".
670 qq(STATUS=\$?\nif [ \$STATUS -ne 0 ]; then\n exit \$STATUS\nfi\n).
671 "cd $topdir/BUILD/$tarballdir\n".
672 qq([ `/usr/bin/id -u` = '0' ] && /bin/chown -Rhf root .\n).
673 qq([ `/usr/bin/id -u` = '0' ] && /bin/chgrp -Rhf root .\n).
674 qq(/bin/chmod -Rf a+rX,g-w,o-w .\n);
675 } elsif ( my ($patchnum,$patchopts) = (/^\%patch([^\s]+)(\s+.+)?$/) ) {
676 chomp $patchnum;
677 $prepscript .= qq(echo "Patch #$patchnum ($pkgdata{main}{"patch$patchnum"}):"\n).
678 "patch ";
679 # If there are options passed, use'em.
680 # Otherwise, catch a bare %patch and ASS-U-ME it's '-p0'-able.
681 # Will break on options that don't provide -pnn, but what the hell.
682 $prepscript .= $patchopts if $patchopts;
683 $prepscript .= "-p0" if !$patchopts;
684 $prepscript .= " -s <$topdir/SOURCES/".$pkgdata{main}{"patch$patchnum"}."\n";
685 } else {
686 $prepscript .= expandmacros($_,'gp');
687 }
688 next LINE;
689 } # prep
690
691 if ($stage eq 'build') {
692 # %build. This is pretty much just a shell script. There
693 # aren't many local macros to deal with.
694 if (/^\%configure/) {
695 $buildscript .= expandmacros($_,'cgbp');
696 } elsif (/^\%\{__make\}/) {
697 $buildscript .= expandmacros($_,'mgbp');
698 } else {
699 $buildscript .= expandmacros($_,'gp');
700 }
701 next LINE;
702 } # build
703
704 if ($stage eq 'install') {
705 if (/^\%makeinstall/) {
706 $installscript .= expandmacros($_,'igbp');
707 } else {
708 $installscript .= expandmacros($_,'gp');
709 }
710 next LINE;
711 } # install
712
713 if ($stage eq 'clean') {
714 $cleanscript .= expandmacros($_,'gp');
715 next LINE;
716 } # clean
717
718 if ($stage eq 'prepost') {
719 $pkgdata{$subname}{$scriptlet} .= expandmacros($_,'gp');
720 next LINE;
721 } # prepost
722
723 if ($stage eq 'files') {
724 # need to update this to deal (properly) with %dir, %attr, etc
725 next LINE if /^\%dir/;
726 next LINE if /^\%defattr/;
727 # Debian dpkg doesn't speak "%docdir". Meh.
728 next LINE if /^\%docdir/;
729 # dunno what to do with this; not sure if there's space in Debian's package structure for it.
730 next LINE if /^\%ghost/;
731##fixme
732# Note that big chunks of this section don't match rpm's behaviour; among other things,
733# rpm accepts more than one %-directive on one line for a file or set of files.
734 # make sure files get suitable permissions and so on
735 if (/^\%attr/) {
736 # We're going to collapse whitespace before processing. PTHBT.
737 # While this breaks pathnames with spaces, anyone expecting command-line
738 # tools with spaces to work (never mind work *properly* or *well*) under
739 # any *nix has their head so far up their ass they can see out their mouth.
740 my ($args,$filelist) = split /\)/;
741 $filelist{$subname} .= " $filelist";
742 $args =~ s/\s+//g;
743 $args =~ s/"//g; # don't think quotes are ever necessary, but they're *allowed*
744 my ($perms,$owner,$group) = ($args =~ /\(([\d-]+),([a-zA-Z0-9-]+),([a-zA-Z0-9-]+)/);
745# due to Debian's total lack of real permissions-processing in its actual package
746# handling component (dpkg-deb), this can't really be done "properly". We'll have
747# to add chown/chmod commands to the postinst instead. Feh.
748 $pkgdata{$subname}{'post'} .= "chown $owner $filelist\n" if $owner ne '-';
749 $pkgdata{$subname}{'post'} .= "chgrp $group $filelist\n" if $group ne '-';
750 $pkgdata{$subname}{'post'} .= "chmod $perms $filelist\n" if $perms ne '-';
751 next LINE;
752 }
753 # %doc needs extra processing, because it can be a space-separated list, and may
754 # include both full and partial pathnames. The partial pathnames must be fiddled
755 # into place in the %install script, because Debian doesn't really have the concept
756 # of "documentation file" that rpm does. (Debian "documentation files" are files
757 # in /usr/share/doc/<packagename>.)
758 if (/^\%doc/) {
759 s/^\%doc\s+//;
760 foreach (split()) {
761 if (m|^/|) {
762 $filelist{$subname} .= " $_"; # and we process this in the processing of the install script
763 } else {
764 my $pkgname = $pkgdata{$subname}{name};
765 $pkgname =~ tr/_/-/;
766
767 $doclist{$subname} .= " $_";
768 s|^[^/]+/||g; # Gotta strip leading blah/ bits. Won't handle * (well) yet... (glob()?)
769 $filelist{$subname} .= " \%{_docdir}/$pkgname/$_";
770 }
771 }
772 next LINE;
773 }
774 # Conffiles. Note that Debian and RH have similar, but not
775 # *quite* identical ideas of what constitutes a conffile. Nrgh.
776 # Note that dpkg will always ask if you want to replace the file - noreplace
777 # is more or less permanently enabled.
778##fixme
779# also need to handle missingok (file that should be removed on uninstall)
780 if (/^\%config(?:\(noreplace\))?\s+(.+)$/) {
781 $pkgdata{$subname}{conffiles} = 1; # Flag it for later
782 my $tmp = $1; # Now we can mangleificationate it. And we probably need to. :/
783 $tmp = expandmacros($tmp, 'gp'); # Expand common macros
784 if ($tmp !~ /\s+/) {
785 # Simplest case, just a file. Whew.
786 push @{$pkgdata{$subname}{conflist}}, $tmp;
787 $filelist{$subname} .= " $tmp";
788 } else {
789 # Wot? Spaces? That means extra %-macros. Which, for the most part, can be ignored.
790 ($tmp) = ($tmp =~ /.+\s([^\s]+)/); # Strip everything before the last space
791 push @{$pkgdata{$subname}{conflist}}, $tmp;
792 $filelist{$subname} .= " $tmp";
793 }
794 next LINE;
795 }
796 # ... and finally everything else
797 $filelist{$subname} .= " $_";
798 next LINE;
799 } # files
800
801 if ($stage eq 'changelog') {
802 # this is one of the few places we do NOT generally want to replace macros...
803 $pkgdata{main}{changelog} .= $_;
804 }
805
806 if ($stage eq 'preamble') {
807 if (/^summary:\s+(.+)/i) {
808 $pkgdata{main}{summary} = $1;
809 } elsif (/^name:\s+(.+)/i) {
810 $pkgdata{main}{name} = expandmacros($1,'g');
811 } elsif (/^epoch:\s+(.+)/i) {
812 $pkgdata{main}{epoch} = expandmacros($1,'g');
813 } elsif (/^version:\s+(.+)/i) {
814 $pkgdata{main}{version} = expandmacros($1,'g');
815 } elsif (/^release:\s+(.+)/i) {
816 $pkgdata{main}{release} = expandmacros($1,'g');
817 } elsif (/^group:\s+(.+)/i) {
818 $pkgdata{main}{group} = $1;
819 } elsif (/^copyright:\s+(.+)/i) {
820 $pkgdata{main}{copyright} = $1;
821 } elsif (/^url:\s+(.+)/i) {
822 $pkgdata{main}{url} = $1;
823 } elsif (/^packager:\s+(.+)/i) {
824 $pkgdata{main}{packager} = $1;
825 } elsif (/^buildroot:\s+(.+)/i) {
826 $buildroot = $1;
827 } elsif (/^source0?:\s+(.+)/i) {
828 $pkgdata{main}{source} = $1;
829 die "Unknown tarball format $1\n" if $1 !~ /\.tar\.(?:gz|bz2)$/;
830 } elsif (/^source([0-9]+):\s+(.+)/i) {
831 $pkgdata{sources}{$1} = $2;
832 } elsif (/^patch([^:]+):\s+(.+)$/i) {
833 my $patchname = "patch$1";
834 $pkgdata{main}{$patchname} = $2;
835 if ($pkgdata{main}{$patchname} =~ /\//) {
836 # URL-style patch. Rare but not unheard-of.
837 my @patchbits = split '/', $pkgdata{main}{$patchname};
838 $pkgdata{main}{$patchname} = $patchbits[$#patchbits];
839 }
840 chomp $pkgdata{main}{$patchname};
841 } elsif (/^buildarch(?:itecture)?:\s+(.+)/i) {
842 $pkgdata{main}{arch} = $1;
843 $pkgdata{main}{arch} =~ s/^noarch$/all/;
844 $buildarch = $pkgdata{main}{arch};
845 } elsif (/^buildreq(?:uires)?:\s+(.+)/i) {
846 $buildreq .= ", $1";
847 } elsif (/^requires:\s+(.+)/i) {
848 $pkgdata{main}{requires} .= ", ".expandmacros("$1", 'gp');
849 } elsif (/^provides:\s+(.+)/i) {
850 $pkgdata{main}{provides} .= ", $1";
851 } elsif (/^conflicts:\s+(.+)/i) {
852 $pkgdata{main}{conflicts} .= ", $1";
853 } elsif (/^autoreq(?:prov)?:\s+(.+)/i) {
854 # we don't handle auto-provides (yet)
855 $NoAutoReq = 1 if $1 =~ /(?:no|0)/i;
856 }
857 next LINE;
858 } # preamble
859
860 } # while <SPEC>
861
862 # Parse and replace some more macros. More will be replaced even later.
863
864 # Expand macros as necessary.
865 $scriptletbase = expandmacros($scriptletbase,'gp');
866
867 $cleanscript = expandmacros($cleanscript,'gp');
868
869 $buildroot = $cmdbuildroot if $cmdbuildroot;
870 $buildroot = expandmacros($buildroot,'gp');
871
872 close SPECFILE;
873} # end parse_spec()
874
875
876## prep()
877# Writes and executes the %prep script (mostly) built while reading the spec file.
878sub prep {
879 # Replace some things here just to make sure.
880 $prepscript = expandmacros($prepscript,'gp');
881
882 # create script filename
883 my $prepscriptfile = "$tmpdir/deb-tmp.prep.".int(rand(99998)+1);
884 sysopen(PREPSCRIPT, $prepscriptfile, O_RDWR | O_CREAT | O_EXCL | O_NOFOLLOW)
885 or die $!;
886 print PREPSCRIPT $scriptletbase;
887 print PREPSCRIPT $prepscript;
888 close PREPSCRIPT;
889
890 # execute
891 print "Calling \%prep script $prepscriptfile...\n";
892 system("/bin/sh -e $prepscriptfile") == 0
893 or die "Can't exec: $!\n";
894
895 # and clean up
896 unlink $prepscriptfile;
897} # end prep()
898
899
900## build()
901# Writes and executes the %build script (mostly) built while reading the spec file.
902sub build {
903 # Expand the macros
904 $buildscript = expandmacros($buildscript,'cgbp');
905
906 # create script filename
907 my $buildscriptfile = "$tmpdir/deb-tmp.build.".int(rand(99998)+1);
908 sysopen(BUILDSCRIPT, $buildscriptfile, O_RDWR | O_CREAT | O_EXCL | O_NOFOLLOW)
909 or die $!;
910 print BUILDSCRIPT $scriptletbase;
911 print BUILDSCRIPT $buildscript;
912 close BUILDSCRIPT;
913
914 # execute
915 print "Calling \%build script $buildscriptfile...\n";
916 system("/bin/sh -e $buildscriptfile") == 0
917 or die "Can't exec: $!\n";
918
919 # and clean up
920 unlink $buildscriptfile;
921} # end build()
922
923
924## install()
925# Writes and executes the %install script (mostly) built while reading the spec file.
926sub install {
927
928 # munge %doc entries into place
929 # rpm handles this with a separate executed %doc script, we're not going to bother.
930 foreach my $docpkg (keys %doclist) {
931 my $pkgname = $pkgdata{$docpkg}{name};
932 $pkgname =~ s/_/-/g;
933
934 $installscript .= "DOCDIR=\$RPM_BUILD_ROOT\%{_docdir}/$pkgname\nexport DOCDIR\n";
935 $installscript .= "mkdir -p \$DOCDIR\n";
936 $doclist{$docpkg} =~ s/^\s*//;
937 foreach (split(' ',$doclist{$docpkg})) {
938 $installscript .= "cp -pr $_ \$DOCDIR/\n";
939 }
940 }
941
942 # Expand the macros
943 $installscript = expandmacros($installscript,'igbp');
944
945 # create script filename
946 my $installscriptfile = "$tmpdir/deb-tmp.inst.".int(rand(99998)+1);
947 sysopen(INSTSCRIPT, $installscriptfile, O_RDWR | O_CREAT | O_EXCL | O_NOFOLLOW)
948 or die $!;
949 print INSTSCRIPT $scriptletbase;
950 print INSTSCRIPT $installscript;
951 close INSTSCRIPT;
952
953 # execute
954 print "Calling \%install script $installscriptfile...\n";
955 system("/bin/sh -e $installscriptfile") == 0
956 or die "Can't exec: $!\n";
957
958 # and clean up
959 unlink $installscriptfile;
960} # end install()
961
962
963## binpackage()
964# Creates the binary .deb package from the installed tree in $buildroot.
965# Writes and executes a shell script to do so.
966# Creates miscellaneous files required by dpkg-deb to actually build the package file.
967# Should handle simple subpackages
968sub binpackage {
969
970 foreach my $pkg (@pkglist) {
971
972 $pkgdata{$pkg}{arch} = $hostarch if !$pkgdata{$pkg}{arch}; # Just In Case.
973
974 # Make sure we have somewhere to write the .deb file
975 if (!-e "$topdir/DEBS/$pkgdata{$pkg}{arch}") {
976 mkdir "$topdir/DEBS/$pkgdata{$pkg}{arch}";
977 }
978
979 # Skip building a package if it doesn't actually have any files. NB: This
980 # differs slightly from rpm's behaviour where a package *will* be built -
981 # even without any files - if %files is specified anywhere. I can think
982 # of odd corner cases where that *may* be desireable.
983 next if (!$filelist{$pkg} or $filelist{$pkg} =~ /^\s*$/);
984
985 # Gotta do this first, otherwise we don't have a place to move files from %files
986 mkdir "$buildroot/$pkg";
987
988 # Eliminate any lingering % macros
989 $filelist{$pkg} = expandmacros $filelist{$pkg}, 'g';
990
991 my @pkgfilelist = split ' ', $filelist{$pkg};
992 foreach my $pkgfile (@pkgfilelist) {
993 $pkgfile = expandmacros($pkgfile, 'gp');
994
995 # Feh. Manpages don't **NEED** to be gzipped, but rpmbuild does, and so shall we.
996 if ($pkgfile =~ m|/usr/share/man/man|) {
997 # need to check to see if manpage is gzipped
998 if (-e "$buildroot$pkgfile") {
999 if ($pkgfile !~ m|\.gz$|) {
1000 qx { gzip $buildroot$pkgfile };
1001 $pkgfile .= ".gz";
1002 }
1003 } else {
1004 if ($pkgfile !~ m|\.gz$|) {
1005 $pkgfile .= ".gz";
1006 } else {
1007 $pkgfile =~ s/\.gz$//;
1008 qx { gzip $buildroot$pkgfile };
1009 $pkgfile .= ".gz";
1010 }
1011 }
1012 }
1013
1014 my ($fpath,$fname) = ($pkgfile =~ m|(.+?/?)?([^/]+)$|); # We don't need $fname now, but we might.
1015 qx { mkdir -p $buildroot/$pkg$fpath }
1016 if $fpath && $fpath ne '';
1017 qx { mv $buildroot$pkgfile $buildroot/$pkg$fpath };
1018 }
1019
1020 # Get the "Depends" (Requires) a la RPM. Ish. We strip the leading
1021 # comma and space here (if needed) in case there were "Requires" specified
1022 # in the spec file - those would precede these.
1023 $pkgdata{$pkg}{requires} .= getreqs("$buildroot/$pkg") if ! $NoAutoReq;
1024
1025 # magic needed to properly version dependencies...
1026 # only provided deps will really be included
1027 $pkgdata{$pkg}{requires} =~ s/^, //; # Still have to do this here.
1028 $pkgdata{$pkg}{requires} =~ s/\s+//g;
1029 my @deps = split /,/, $pkgdata{$pkg}{requires};
1030 my $tmp = '';
1031 foreach my $dep (@deps) {
1032 # Hack up the perl(Class::SubClass) deps into something dpkg can understand.
1033 # May or may not be versioned.
1034 # We do this first so the version rewriter can do its magic next.
1035 if (my ($mod,$ver) = ($dep =~ /^perl\(([A-Za-z0-9\:\-]+)\)([><=]+.+)?/) ) {
1036 $mod =~ s/^perl\(//;
1037 $mod =~ s/\)$//;
1038 $mod =~ s/::/-/g;
1039 $mod =~ tr/A-Z/a-z/;
1040 $mod = "lib$mod-perl";
1041 $mod .= $ver if $ver;
1042 $dep = $mod;
1043 }
1044 if (my ($name,$rel,$value) = ($dep =~ /^([a-zA-Z0-9._-]+)([><=]+)([a-zA-Z0-9._-]+)$/)) {
1045 $tmp .= ", $name ($rel $value)";
1046 } else {
1047 $tmp .= ", $dep";
1048 }
1049 }
1050 ($pkgdata{$pkg}{requires} = $tmp) =~ s/^, //;
1051
1052 # Do this here since we're doing {depends}...
1053 if (defined($pkgdata{$pkg}{provides})) {
1054 $pkgdata{$pkg}{provides} =~ s/^, //;
1055 $pkgdata{$pkg}{provides} = expandmacros($pkgdata{$pkg}{provides},'gp');
1056 }
1057 if (defined($pkgdata{$pkg}{conflicts})) {
1058 $pkgdata{$pkg}{conflicts} =~ s/^, //;
1059 $pkgdata{$pkg}{conflicts} = expandmacros($pkgdata{$pkg}{conflicts},'gp');
1060 }
1061
1062 # Gotta do this next, otherwise the control file has nowhere to go. >:(
1063 mkdir "$buildroot/$pkg/DEBIAN";
1064
1065 # Hack the filename for the package into a Debian-tool-compatible format. GRRRRRR!!!!!
1066 # Have I mentioned I hate Debian Policy?
1067 $pkgdata{$pkg}{name} =~ tr/_/-/;
1068
1069 # create script filename
1070 my $debscriptfile = "$tmpdir/deb-tmp.pkg.".int(rand(99998)+1);
1071 sysopen(DEBSCRIPT, $debscriptfile, O_RDWR | O_CREAT | O_EXCL | O_NOFOLLOW)
1072 or die $!;
1073 print DEBSCRIPT $scriptletbase;
1074 print DEBSCRIPT "fakeroot dpkg-deb -b $buildroot/$pkg $topdir/DEBS/$pkgdata{$pkg}{arch}/".
1075 "$pkgdata{$pkg}{name}_".
1076 (defined($pkgdata{main}{epoch}) ? "$pkgdata{main}{epoch}:" : '').
1077 "$pkgdata{$pkg}{version}-$pkgdata{main}{release}_$pkgdata{$pkg}{arch}.deb\n";
1078 # %$&$%@#@@#%@@@ Debian and their horrible ugly package names. >:(
1079 close DEBSCRIPT;
1080
1081 my $control = "Package: $pkgdata{$pkg}{name}\n".
1082 "Version: ".
1083 (defined($pkgdata{main}{epoch}) ? "$pkgdata{main}{epoch}:" : '').
1084 "$pkgdata{$pkg}{version}-$pkgdata{main}{release}\n".
1085 "Section: $pkgdata{$pkg}{group}\n".
1086 "Priority: optional\n".
1087 "Architecture: $pkgdata{$pkg}{arch}\n".
1088 "Maintainer: $pkgdata{main}{packager}\n".
1089 ( $pkgdata{$pkg}{requires} ne '' ? "Depends: $pkgdata{$pkg}{requires}\n" : '' ).
1090 ( defined($pkgdata{$pkg}{provides}) ? "Provides: $pkgdata{$pkg}{provides}\n" : '' ).
1091 ( defined($pkgdata{$pkg}{conflicts}) ? "Conflicts: $pkgdata{$pkg}{conflicts}\n" : '' ).
1092 "Description: $pkgdata{$pkg}{summary}\n";
1093 $control .= "$pkgdata{$pkg}{desc}\n";
1094
1095 open CONTROL, ">$buildroot/$pkg/DEBIAN/control";
1096 print CONTROL $control;
1097 close CONTROL;
1098
1099 # Iff there are conffiles (as specified in the %files list(s), add'em
1100 # in so dpkg-deb can tag them.
1101 if ($pkgdata{$pkg}{conffiles}) {
1102 open CONFLIST, ">$buildroot/$pkg/DEBIAN/conffiles";
1103 foreach my $conffile (@{$pkgdata{$pkg}{conflist}}) {
1104 my @tmp = glob "$buildroot/$pkg/$conffile";
1105 foreach (@tmp) {
1106 s|$buildroot/$pkg/||g; # nrgl. gotta be a better way to do this...
1107 s/\s+/\n/g; # Not gonna support spaces in filenames. Ewww.
1108 print CONFLIST "$_\n";
1109 }
1110 }
1111 close CONFLIST;
1112 }
1113
1114 # found the point of scripts on subpackages.
1115 if ($pkgdata{$pkg}{'pre'}) {
1116 $pkgdata{$pkg}{'pre'} = expandmacros($pkgdata{$pkg}{'pre'},'gp');
1117 open PREINST, ">$buildroot/$pkg/DEBIAN/preinst";
1118 print PREINST "#!/bin/sh\nset -e\n\n";
1119 print PREINST $pkgdata{$pkg}{'pre'};
1120 close PREINST;
1121 `chmod 0755 $buildroot/$pkg/DEBIAN/preinst`;
1122 }
1123 if ($pkgdata{$pkg}{'post'}) {
1124 $pkgdata{$pkg}{'post'} = expandmacros($pkgdata{$pkg}{'post'},'gp');
1125 open PREINST, ">$buildroot/$pkg/DEBIAN/postinst";
1126 print PREINST "#!/bin/sh\nset -e\n\n";
1127 print PREINST $pkgdata{$pkg}{'post'};
1128 close PREINST;
1129 `chmod 0755 $buildroot/$pkg/DEBIAN/postinst`;
1130 }
1131 if ($pkgdata{$pkg}{'preun'}) {
1132 $pkgdata{$pkg}{'pre'} = expandmacros($pkgdata{$pkg}{'preun'},'gp');
1133 open PREINST, ">$buildroot/$pkg/DEBIAN/prerm";
1134 print PREINST "#!/bin/sh\nset -e\n\n";
1135 print PREINST $pkgdata{$pkg}{'preun'};
1136 close PREINST;
1137 `chmod 0755 $buildroot/$pkg/DEBIAN/prerm`;
1138 }
1139 if ($pkgdata{$pkg}{'postun'}) {
1140 $pkgdata{$pkg}{'postun'} = expandmacros($pkgdata{$pkg}{'postun'},'gp');
1141 open PREINST, ">$buildroot/$pkg/DEBIAN/postrm";
1142 print PREINST "#!/bin/sh\nset -e\n\n";
1143 print PREINST $pkgdata{$pkg}{'postun'};
1144 close PREINST;
1145 `chmod 0755 $buildroot/$pkg/DEBIAN/postrm`;
1146 }
1147
1148 # execute
1149 print "Calling package creation script $debscriptfile for $pkgdata{$pkg}{name}...\n";
1150 system("/bin/sh -e $debscriptfile") == 0
1151 or die "Can't exec: $!\n";
1152
1153 $finalmessages .= "Wrote binary package ".
1154 "$pkgdata{$pkg}{name}_".
1155 (defined($pkgdata{main}{epoch}) ? "$pkgdata{main}{epoch}:" : '').
1156 "$pkgdata{$pkg}{version}-$pkgdata{main}{release}_$pkgdata{$pkg}{arch}.deb".
1157 " in $topdir/DEBS/$pkgdata{$pkg}{arch}\n";
1158 # and clean up
1159 unlink $debscriptfile;
1160
1161 } # subpackage loop
1162
1163} # end binpackage()
1164
1165
1166## srcpackage()
1167# Builds a .src.deb source package. Note that Debian's idea of
1168# a "source package" is seriously flawed IMO, because you can't
1169# easily copy it as-is.
1170# Not quite identical to RPM, but Good Enough (TM).
1171sub srcpackage {
1172 # In case we were called with -bs.
1173 $pkgdata{main}{name} =~ tr/_/-/;
1174 my $pkgsrcname = "$pkgdata{main}{name}-".
1175 (defined($pkgdata{main}{epoch}) ? "$pkgdata{main}{epoch}:" : '').
1176 "$pkgdata{main}{version}-$pkgdata{main}{release}.sdeb";
1177
1178 my $paxcmd;
1179
1180 # We'll definitely need this later, and *may* need it sooner.
1181 (my $barespec = $specfile) =~ s|.+/([^/]+)$|$1|;
1182
1183 # Copy the specfile to the build tree, but only if it's not there already.
1184##buglet: need to deal with silly case where silly user has put the spec
1185# file in a subdir of %{_topdir}/SPECS. Ewww. Silly user!
1186 if (abs_path($specfile) !~ /^$topdir\/SPECS/) {
1187 $paxcmd .= "cp $specfile %{_topdir}/SPECS/; \n"
1188 }
1189
1190 # use pax -w [file] [file] ... >outfile.sdeb
1191 $paxcmd = "cd $topdir; pax -w ";
1192
1193# tweak source entry into usable form. Need it locally somewhere along the line.
1194 (my $pkgsrc = $pkgdata{main}{source}) =~ s|.+/([^/]+)$|$1|;
1195 $paxcmd .= "SOURCES/$pkgsrc ";
1196
1197 # create file list: Source[nn], Patch[nn]
1198 foreach my $specbit (keys %{$pkgdata{main}} ) {
1199 next if $specbit eq 'source';
1200 $paxcmd .= "SOURCES/$pkgdata{main}{$specbit} " if $specbit =~ /^patch/;
1201##buglet: need to deal with case where patches are listed as URLs?
1202# or other extended pathnames? Silly !@$%^&!%%!%!! user!
1203 }
1204
1205 foreach my $source (keys %{$pkgdata{sources}}) {
1206 $paxcmd .= "SOURCES/$pkgdata{sources}{$source} ";
1207 }
1208
1209 # add the spec file, source package destination, and cd back where we came from.
1210 $paxcmd .= "SPECS/$barespec > $topdir/SDEBS/$pkgsrcname; cd -";
1211
1212 # In case of %-macros...
1213 $paxcmd = expandmacros($paxcmd,'gp');
1214
1215 system "$paxcmd";
1216 $finalmessages .= "Wrote source package $pkgsrcname in $topdir/SDEBS.\n";
1217} # end srcpackage()
1218
1219
1220## clean()
1221# Writes and executes the %clean script (mostly) built while reading the spec file.
1222sub clean {
1223 # Replace some things here just to make sure.
1224 $cleanscript = expandmacros($cleanscript,'gp');
1225
1226 # create script filename
1227 my $cleanscriptfile = "$tmpdir/deb-tmp.clean.".int(rand(99998)+1);
1228 sysopen(CLEANSCRIPT, $cleanscriptfile, O_RDWR | O_CREAT | O_EXCL | O_NOFOLLOW)
1229 or die $!;
1230 print CLEANSCRIPT $scriptletbase;
1231 print CLEANSCRIPT $cleanscript;
1232 close CLEANSCRIPT;
1233
1234 # execute
1235 print "Calling \%clean script $cleanscriptfile...\n";
1236 system("/bin/sh -e $cleanscriptfile") == 0
1237 or die "Can't exec: $!\n";
1238
1239 # and clean up
1240 unlink $cleanscriptfile;
1241} # end clean()
1242
1243
1244## checkbuildreq()
1245# Checks the build requirements (if any)
1246# Spits out a rude warning and returns a true-false error if any
1247# requirements are not met.
1248sub checkbuildreq {
1249 return 1 if $buildreq eq ''; # No use doing extra work.
1250
1251 if ( ! -e "/usr/bin/dpkg-query" ) {
1252 print "**WARNING** dpkg-query not found. Can't check build-deps.\n".
1253 " Required for sucessful build:\n".$buildreq."\n".
1254 " Continuing anyway.\n";
1255 return 1;
1256 }
1257
1258 my $reqflag = 1; # unset iff a buildreq is missing
1259
1260 $buildreq =~ s/^, //; # Strip the leading comma and space
1261 my @reqlist = split /,\s+/, $buildreq;
1262
1263 foreach my $req (@reqlist) {
1264 my ($pkg,$rel,$ver);
1265
1266 # We have two classes of requirements - versioned and unversioned.
1267 if ($req =~ /[><=]/) {
1268 # Pick up the details of versioned buildreqs
1269 ($pkg,$rel,$ver) = ($req =~ /([a-z0-9._-]+)\s+([><=]+)\s+([a-z0-9._-]+)/);
1270 } else {
1271 # And the unversioned ones.
1272 $pkg = $req;
1273 $rel = '>=';
1274 $ver = 0;
1275 }
1276
1277 my @pkglist = qx { dpkg-query --showformat '\${status}\t\${version}\n' -W $pkg };
1278# need to check if no lines returned - means a bad buildreq
1279 my ($reqstat,undef,undef,$reqver) = split /\s+/, $pkglist[0];
1280 if ($reqstat !~ /install/) {
1281 print " * Missing build-dependency $pkg!\n";
1282 $reqflag = 0;
1283 } else {
1284# gotta be a better way to do this... :/
1285 if ($rel eq '>=' && !($reqver ge $ver)) {
1286 print " * Buildreq $pkg is installed, but wrong version ($reqver): Need $ver\n";
1287 $reqflag = 0;
1288 }
1289 if ($rel eq '>' && !($reqver gt $ver)) {
1290 print " * Buildreq $pkg is installed, but wrong version ($reqver): Need $ver\n";
1291 $reqflag = 0;
1292 }
1293 if ($rel eq '<=' && !($reqver le $ver)) {
1294 print " * Buildreq $pkg is installed, but wrong version ($reqver): Need $ver\n";
1295 $reqflag = 0;
1296 }
1297 if ($rel eq '<' && !($reqver lt $ver)) {
1298 print " * Buildreq $pkg is installed, but wrong version ($reqver): Need $ver\n";
1299 $reqflag = 0;
1300 }
1301 if ($rel eq '=' && !($reqver eq $ver)) {
1302 print " * Buildreq $pkg is installed, but wrong version ($reqver): Need $ver\n";
1303 $reqflag = 0;
1304 }
1305 } # end not installed/installed check
1306 } # end req loop
1307
1308 return $reqflag;
1309} # end checkbuildreq()
1310
1311
1312## getreqs()
1313# Find out which libraries/packages are required for any
1314# executables and libs in a given file tree.
1315# (Debian doesn't have soname-level deps; just package-level)
1316# Returns an empty string if the tree contains no binaries.
1317# Doesn't work well on shell scripts. but those *should* be
1318# fine anyway. (Yeah, right...)
1319sub getreqs() {
1320 my $pkgtree = $_[0];
1321
1322 print "Checking library requirements...\n";
1323 my @binlist = qx { find $pkgtree -type f -perm 755 };
1324
1325 if (scalar(@binlist) == 0) {
1326 return '';
1327 }
1328
1329 my @reqlist;
1330 foreach (@binlist) {
1331 push @reqlist, qx { ldd $_ };
1332 }
1333
1334 # Get the list of libs provided by this package. Still doesn't
1335 # handle the case where the lib gets stuffed into a subpackage. :/
1336 my @intprovlist = qx { find $pkgtree -type f -name "*.so*" };
1337 my $provlist = '';
1338 foreach (@intprovlist) {
1339 s/$pkgtree//;
1340 $provlist .= "$_";
1341 }
1342
1343 my %reqs;
1344 my $reqlibs = '';
1345
1346 foreach (@reqlist) {
1347 next if /^$pkgtree/;
1348 next if /not a dynamic executable/;
1349 next if m|/lib/ld-linux.so|; # Hack! Hack! PTHBTT! (libc suxx0rz)
1350 next if /linux-gate.so/; # Kernel hackery for teh W1n!!1!1eleventy-one!1 (Don't ask. Feh.)
1351
1352 my ($req) = (/^\s+([a-z0-9._-]+)/); # dig out the actual library (so)name
1353
1354 # Ignore libs provided by this package. Note that we don't match
1355 # on word-boundary at the *end* of the lib we're looking for, as the
1356 # looked-for lib may not have the full soname version. (ie, it may
1357 # "just" point to one of the symlinks that get created somewhere.)
1358 next if $provlist =~ /\b$req/;
1359
1360 $reqlibs .= " $req";
1361 }
1362
1363 if ($reqlibs ne '') {
1364 foreach (qx { dpkg -S $reqlibs }) {
1365 my ($libpkg,undef) = split /:\s+/;
1366 $reqs{$libpkg} = 1;
1367 }
1368 }
1369
1370 my $deplist = '';
1371 foreach (keys %reqs) {
1372 $deplist .= ", $_";
1373 }
1374
1375# For now, we're done. We're not going to meddle with versions yet.
1376# Among other things, it's messier than handling "simple" yes/no "do
1377# we have this lib?" deps. >:(
1378
1379 return $deplist;
1380} # end getreqs()
1381
1382
1383## install_sdeb()
1384# Extracts .sdeb contents to %_topdir as appropriate
1385sub install_sdeb {
1386 $srcpkg = abs_path($srcpkg);
1387
1388 my $paxcmd = "cd $topdir; pax -r <$srcpkg; cd -";
1389
1390 # In case of %-macros...
1391 $paxcmd = expandmacros($paxcmd,'gp');
1392
1393 system "$paxcmd";
1394 print "Extracted source package $srcpkg to $topdir.\n";
1395} # end install_sdeb()
1396
1397
1398## expandmacros()
1399# Expands all %{blah} macros in the passed string
1400# Split up a bit with some sections so we don't spend time trying to
1401# expand macros that are only used in a few specific places.
1402sub expandmacros {
1403 my $macrostring = shift;
1404 my $section = shift;
1405
1406 # To allow the FHS-ish %configure and %makeinstall to work The Right Way.
1407 # (Without clobbering the global $buildroot.)
1408 my $prefix = '';
1409
1410 if ($section =~ /c/) {
1411 # %configure macro
1412# Don't know what it's for, don't have a useful default replacement
1413# --program-prefix=%{_program_prefix} \
1414 $macrostring =~ s'%configure'./configure --host=$DEB_HOST_GNU_TYPE \
1415 --build=$DEB_BUILD_GNU_TYPE \
1416 --prefix=%{_prefix} \
1417 --exec-prefix=%{_exec_prefix} \
1418 --bindir=%{_bindir} \
1419 --sbindir=%{_sbindir} \
1420 --sysconfdir=%{_sysconfdir} \
1421 --datadir=%{_datadir} \
1422 --includedir=%{_includedir} \
1423 --libdir=%{_libdir} \
1424 --libexecdir=%{_libexecdir} \
1425 --localstatedir=%{_localstatedir} \
1426 --sharedstatedir=%{_sharedstatedir} \
1427 --mandir=%{_mandir} \
1428 --infodir=%{_infodir} ';
1429 } # done %configure
1430
1431 if ($section =~ /m/) {
1432 $macrostring =~ s'%{__make}'make ';
1433 } # done make
1434
1435 if ($section =~ /i/) {
1436 # This is where we need to mangle $prefix.
1437 $macrostring =~ s'%makeinstall'make %{fhs} install';
1438 $prefix = $buildroot;
1439 } # done %install and/or %makeinstall
1440
1441 # Build data
1442 # Note that these are processed in reverse order to get the substitution order right
1443 if ($section =~ /b/) {
1444# $macrostring =~ s'%{fhs}'host=$DEB_HOST_GNU_TYPE \
1445# build=$DEB_BUILD_GNU_TYPE \
1446 $macrostring =~ s'%{fhs}'prefix=%{_prefix} \
1447 exec-prefix=%{_exec_prefix} \
1448 bindir=%{_bindir} \
1449 sbindir=%{_sbindir} \
1450 sysconfdir=%{_sysconfdir} \
1451 datadir=%{_datadir} \
1452 includedir=%{_includedir} \
1453 libdir=%{_libdir} \
1454 libexecdir=%{_libexecdir} \
1455 localstatedir=%{_localstatedir} \
1456 sharedstatedir=%{_sharedstatedir} \
1457 mandir=%{_mandir} \
1458 infodir=%{_infodir} \
1459';
1460
1461 # Note that the above regex terminates with the extra space
1462 # "Just In Case" of user additions, which will then get neatly
1463 # tagged on the end where they take precedence (supposedly)
1464 # over the "default" ones.
1465
1466 # Now we cascade the macros introduced above. >_<
1467 # Wot ot to go theah:
1468 $macrostring =~ s|%{_mandir}|%{_datadir}/man|g; #/usr/share/man
1469 $macrostring =~ s|%{_infodir}|%{_datadir}/info|g; #/usr/share/info
1470 $macrostring =~ s|%{_oldincludedir}|/usr/include|g; #/usr/include
1471 $macrostring =~ s|%{_includedir}|%{_prefix}/include|g; #/usr/include
1472 $macrostring =~ s|%{_libdir}|%{_exec_prefix}/%{_lib}|g; #/usr/lib
1473 $macrostring =~ s|%{_lib}|lib|g; #?
1474 $macrostring =~ s|%{_localstatedir}|/var|g; #/var
1475 $macrostring =~ s|%{_sharedstatedir}|%{_prefix}/com|g; #/usr/com WTF?
1476 $macrostring =~ s|%{_sysconfdir}|/etc|g; #/etc
1477 $macrostring =~ s|%{_datadir}|%{_prefix}/share|g; #/usr/share
1478 $macrostring =~ s|%{_libexecdir}|%{_exec_prefix}/libexec|g; #/usr/libexec
1479 $macrostring =~ s|%{_sbindir}|%{_exec_prefix}/sbin|g; #/usr/sbin
1480 $macrostring =~ s|%{_bindir}|%{_exec_prefix}/bin|g; #/usr/bin
1481 $macrostring =~ s|%{_exec_prefix}|%{_prefix}|g; #/usr
1482 $macrostring =~ s|%{_prefix}|/usr|g; #/usr
1483 } # done with config section
1484
1485 # Package data
1486 if ($section =~ /p/) {
1487 $macrostring =~ s/\%\{buildroot\}/$buildroot/gi;
1488 foreach my $source (keys %{$pkgdata{sources}}) {
1489 $macrostring =~ s/\%\{source$source\}/$topdir\/SOURCES\/$pkgdata{sources}{$source}/gi;
1490 }
1491 $macrostring =~ s/\%\{name\}/$pkgdata{main}{name}/gi;
1492 $macrostring =~ s/\%\{version\}/$pkgdata{main}{version}/gi;
1493 $macrostring =~ s/\%\{release\}/$pkgdata{main}{release}/gi;
1494 }
1495
1496 # Globals, and not-so-globals
1497 if ($section =~ /g/) {
1498
1499 $macrostring =~ s|%{_builddir}|%{_topdir}/BUILD|g;
1500 $macrostring =~ s|%{_topdir}|$topdir|g;
1501 $macrostring =~ s|%{_tmppath}|$tmpdir|g;
1502 $macrostring =~ s'%{_docdir}'%{_datadir}/doc'g;
1503
1504 # Standard FHS locations. More or less.
1505 $macrostring =~ s'%{_bindir}'/usr/bin'g;
1506 $macrostring =~ s'%{_sbindir}'/usr/sbin'g;
1507 $macrostring =~ s'%{_mandir}'%{_datadir}/man'g;
1508 $macrostring =~ s'%{_includedir}'/usr/include'g;
1509 $macrostring =~ s'%{_libdir}'/usr/lib'g;
1510 $macrostring =~ s'%{_sysconfdir}'/etc'g;
1511 $macrostring =~ s'%{_localstatedir}'/var'g;
1512
1513 # FHS-ish locations that aren't quite actually FHS-specified.
1514 $macrostring =~ s'%{_datadir}'/usr/share'g;
1515
1516 # special %define's. Handle the general case where we eval anything.
1517 # Even more general: %(...) is a spec-parse-time shell code wrapper.
1518 # Prime example:
1519 #%define perl_vendorlib %(eval "`perl -V:installvendorlib`"; echo $installvendorlib)
1520 if ($macrostring =~ /\%\((.+)\)/) {
1521 my $shellstr = $1;
1522 # Oy vey this gets silly for the perl bits. Executing a shell to
1523 # call Perl to get the vendorlib/sitelib/whatever "core" globals.
1524 # This can do more, but... eww.
1525 $shellstr = qx { /bin/sh -c '$shellstr' }; # Yay! ' characters apparently get properly exscapededed.
1526 $macrostring =~ s/\%\(.+\)/$shellstr/;
1527 }
1528
1529 # support for **some** %if constructs. Note that this breaks somewhat if
1530 # there's no value specified... but so does rpm.
1531my $tmpcount = 0;
1532 while ($macrostring =~ /\%\{(!\?|\?!|\?)([a-z0-9_.-]+)(?:\:([a-z0-9_.-]+))?\}/g) { #Whew....
1533 my $qex = $1;
1534 my $macro = $2;
1535 my $value = $3;
1536
1537 my $neg = '1' if $qex =~ /\!/;
1538 if ($specglobals{$macro}) {
1539 $value = '' if $neg;
1540 } else {
1541 $value = '' if !$neg;
1542 }
1543 $macrostring =~ s/\%\{!?\?\!?[a-z0-9_.-]+(?:\:[a-z0-9_.-]+)?\}/$value/;
1544
1545# not certain about this, but I don't want to run away. It *can* happen if planned carefully. :/
1546$tmpcount++;
1547die "excessive recursive macro replacement; dying.\n" if $tmpcount > 6;
1548
1549 } # while()
1550
1551# should probably stick a "no runaway" flag in here... Just In Case...
1552 # %define's
1553 while (my ($key) = ($macrostring =~ /%{([a-z0-9]+)}/i) ) {
1554 $macrostring =~ s|%{$key}|$specglobals{$key}|g;
1555 # wanna limit this to "... if $specglobals{$key}", but need more magic
1556 }
1557
1558 # system programs. RPM uses a global config file for these; we'll just
1559 # ASS-U-ME and make life a little simpler.
1560 if ($macrostring =~ /\%\{\_\_([a-z0-9_-]+)\}/) {
1561 $macrostring =~ s|%{__([a-z0-9_-]+)}|$1|g;
1562 }
1563
1564 # Misc expansions
1565 $macrostring =~ s|%{_arch}|$hostarch|g;
1566 $macrostring =~ s|%{optflags}|$optflags{$hostarch}|g;
1567
1568 # Perl @INC/...lib locations, and other related bits.
1569 $macrostring =~ s|%{perl_archlib}|$Config{installarchlib}|g;
1570 $macrostring =~ s|%{perl_sitelib}|$Config{installsitelib}|g;
1571 $macrostring =~ s|%{perl_sitearch}|$Config{installsitearch}|g;
1572 $macrostring =~ s|%{perl_vendorlib}|$Config{installvendorlib}|g;
1573 $macrostring =~ s|%{perl_vendorarch}|$Config{installvendorarch}|g;
1574
1575 } # done with globals section
1576
1577 return $macrostring;
1578} # end expandmacros()
1579
1580
1581
1582__END__
1583
1584
1585
1586=head1 NAME
1587
1588debbuild - Build Debian-compatible packages from RPM spec files
1589
1590=head1 SYNOPSIS
1591
1592 debbuild {-ba|-bb|-bp|-bc|-bi|-bl|-bs} [build-options] file.spec
1593
1594 debbuild {-ta|-tb|-tp|-tc|-ti|-tl|-ts} [build-options] file.tar.{gz|bz2}
1595
1596 debbuild --rebuild file.{src.rpm|sdeb}
1597
1598 debbuild --showpkgs
1599
1600=head1 DESCRIPTION
1601
1602This script attempts to build Debian-friendly semi-native packages from RPM spec files,
1603RPM-friendly tarballs, and RPM source packages (.src.rpm files). It accepts I<most> of the
1604options rpmbuild does, and should be able to interpret most spec files usefully. Perl
1605modules should be handled via CPAN+dh-make-perl instead; Debian's conventions for such
1606things do not lend themselves to automated conversion.
1607
1608As far as possible, the command-line options are identical to those from rpmbuild, although
1609several rpmbuild options are not supported:
1610
1611 --recompile
1612 --showrc
1613 --buildroot
1614 --clean
1615 --nobuild
1616 --rmsource
1617 --rmspec
1618 --sign
1619 --target
1620
1621Some of these could probably be trivially added. Feel free to send me a patch. ;)
1622
1623Complex spec files will most likely not work well, if at all. Rewrite them from scratch -
1624you'll have to make heavy modifications anyway.
1625
1626If you see something you don't like, mail me. Send a patch if you feel inspired. I don't
1627promise I'll do anything other than say "Yup, that's broken" or "Got your message".
1628
1629=head1 ASSUMPTIONS
1630
1631As with rpmbuild, debbuild makes some assumptions about your system.
1632
1633=over 4
1634
1635=item *
1636
1637Either you have rights to do as you please under /usr/src/debian, or you have created a file
1638~/.debmacros containing a suitable %_topdir definition.
1639
1640Both rpmbuild and debbuild require the directories %_topdir/{BUILD,SOURCES,SPECS}. However,
1641where rpmbuild requires the %_topdir/{RPMS,SRPMS} directories, debbuild
1642requires %_topdir/{DEBS,SDEBS} instead. Create them in advance;
1643some subdirectories are created automatically as needed, but most are not.
1644
1645=item *
1646
1647/var/tmp must allow script execution - rpmbuild and debbuild both rely on creating and
1648executing shell scripts for much of their functionality. By default, debbuild also creates
1649install trees under /var/tmp - however this is (almost) entirely under the control of the
1650package's .spec file.
1651
1652=item *
1653
1654If you wish to --rebuild a .src.rpm, your %_topdir for both debbuild and rpmbuild must either
1655match, or be suitably symlinked one direction or another so that both programs are effectively
1656working in the same tree. (Or you could just manually wrestle files around your system.)
1657
1658You could symlink ~/.rpmmacros to ~/.debmacros (or vice versa) and save yourself some hassle
1659if you need to rebuild .src.rpm packages on a regular basis. Currently debbuild only uses the
1660%_topdir macro definition, although there are many more things that rpmbuild can use from
1661~/.rpmmacros.
1662
1663=back
1664
1665=head1 ERRATA
1666
1667debbuild deliberately does a few things differently from rpm.
1668
1669=head2 BuildArch or BuildArchitecture
1670
1671rpm takes the last BuildArch entry it finds in the .spec file, whatever it is, and runs with
1672that for all packages. Debian's repository system is fairly heavily designed around the
1673assumption that a single source package may generate small binary (executable) packages
1674for each arch, and large binary arch-all packages containing shared data.
1675
1676debbuild allows this by using the architecture specified by (in order of preference):
1677
1678=over 4
1679
1680=item * Host architecture
1681
1682=item * BuildArch specified in .spec file preamble
1683
1684=item * "Last specified" BuildArch for packages with several subpackages
1685
1686=item * BuildArch specified in the %package section for that subpackage
1687
1688=back
1689
1690=head2 Finding out what packages should be built (--showpkgs)
1691
1692rpmbuild does not include any convenient method I know of to list the packages a spec file
1693will produce. Since I needed this ability for another tool, I added it.
1694
1695It requires the .spec file for the package, and produces a list of full package filenames
1696(without path data) that would be generated by one of --rebuild, -ta, -tb, -ba, or -bb.
1697This includes the .sdeb source package.
1698
1699=head1 AUTHOR
1700
1701debbuild was written by Kris Deugau <kdeugau@deepnet.cx>. A version that approximates
1702current is available at http://www.deepnet.cx/debbuild/.
1703
1704=head1 BUGS
1705
1706Funky Things Happen if you forget a command-line option or two. I've been too lazy to bother
1707fixing this.
1708
1709Many macro expansions are unsupported or incompletely supported.
1710
1711The generated scriptlets don't quite match those from rpmbuild exactly. There are extra
1712environment variables and preprocessing that I haven't needed (yet).
1713
1714Dcumentation, such as it is, will likely remain perpetually out of date.
1715
1716%_topdir and the five "working" directories under %_topdir could arguably be created by
1717debbuild. However, rpmbuild doesn't create these directories either.
1718
1719=head1 SEE ALSO
1720
1721rpm(8), rpmbuild(8), and pretty much any document describing how to write a .spec file.
1722
1723=cut
Note: See TracBrowser for help on using the repository browser.