source: trunk/debbuild@ 55

Last change on this file since 55 was 55, checked in by kdeugau, 18 years ago

/trunk

Update POD with changes, updates, and other notes.

  • Property svn:executable set to *
  • Property svn:keywords set to Date Rev Author
File size: 37.3 KB
Line 
1#!/usr/bin/perl
2# debbuild script
3# Shamlessly steals intreface 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: 2006-04-19 19:25:29 +0000 (Wed, 19 Apr 2006) $
9# SVN revision $Rev: 55 $
10# Last update by $Author: kdeugau $
11###
12# Copyright 2005,2006 Kris Deugau <kdeugau@deepnet.cx>
13
14use strict;
15use warnings;
16use Fcntl; # for sysopen flags
17use Cwd 'abs_path'; # for finding where files really are
18
19# regex debugger
20#use re "debug";
21
22# Program flow:
23# -> Parse/execute "system" config/macros (if any - should be rare)
24# -> Parse/execute "user" config/macros (if any - *my* requirement is %_topdir)
25# -> Parse command line for options, spec file/tarball/.src.deb (NB - also accept .src.rpm)
26
27sub expandmacros;
28
29# User's prefs for dirs, environment, etc,etc,etc.
30# config file ~/.debmacros
31# Default ordered search paths for config/macros:
32# /usr/lib/rpm/rpmrc /usr/lib/rpm/redhat/rpmrc /etc/rpmrc ~/.rpmrc
33# /usr/lib/rpm/macros /usr/lib/rpm/redhat/macros /etc/rpm/macros ~/.rpmmacros
34# **NOTE: May be possible to (ab)use bits of debhelper
35
36# Build tree
37# default is /usr/src/debian/{BUILD,SOURCES,SPECS,DEBS,SDEBS}
38
39# Globals
40my $specfile;
41my $tarball;
42my $srcpkg;
43my $cmdbuildroot;
44my $tarballdir; # This should really be initialized, but the coding makes it, um, ugly.
45my %specglobals; # For %define's in specfile, among other things.
46
47# Initialized globals
48my $verbosity = 0;
49my %cmdopts = (type => '',
50 stage => 'a',
51 short => 'n'
52 );
53my $topdir = "/usr/src/debian";
54my $buildroot = "%{_tmppath}/%{name}-%{version}-%{release}.root".int(rand(99998)+1);
55
56# "Constants"
57my %targets = ('p' => 'Prep',
58 'c' => 'Compile',
59 'i' => 'Install',
60 'l' => 'Verify %files',
61 'a' => 'Build binary and source',
62 'b' => 'Build binary',
63 's' => 'Build source'
64 );
65my $scriptletbase =
66q(#!/bin/sh
67
68 RPM_SOURCE_DIR="%{_topdir}/SOURCES"
69 RPM_BUILD_DIR="%{_topdir}/BUILD"
70 RPM_OPT_FLAGS="-O2 -g -march=i386 -mcpu=i686"
71 RPM_ARCH="i386"
72 RPM_OS="linux"
73 export RPM_SOURCE_DIR RPM_BUILD_DIR RPM_OPT_FLAGS RPM_ARCH RPM_OS
74 RPM_DOC_DIR="/usr/share/doc"
75 export RPM_DOC_DIR
76 RPM_PACKAGE_NAME="%{name}"
77 RPM_PACKAGE_VERSION="%{version}"
78 RPM_PACKAGE_RELEASE="%{release}"
79 export RPM_PACKAGE_NAME RPM_PACKAGE_VERSION RPM_PACKAGE_RELEASE
80 RPM_BUILD_ROOT="%{buildroot}"
81 export RPM_BUILD_ROOT
82);
83foreach (`dpkg-architecture`) {
84 s/=(.+)/="$1"/;
85 $scriptletbase .= " $_";
86}
87$scriptletbase .=
88q(
89 set -x
90 umask 022
91 cd %{_topdir}/BUILD
92);
93
94# Package data
95# This is the form of $pkgdata{pkgname}{meta}
96# meta includes Summary, Name, Version, Release, Group, Copyright,
97# Source, URL, Packager, BuildRoot, Description, BuildReq(uires),
98# Requires, Provides
99# 10/31/2005 Maybe this should be flatter? -kgd
100my %pkgdata;
101my @pkglist = ('main'); #sigh
102# Files listing. Embedding this in %pkgdata would be, um, messy.
103my %filelist;
104my $buildreq = '';
105
106# Scriptlets
107my $prepscript = '';
108my $buildscript = '';
109# %install doesn't need the full treatment from %clean; just an empty place to install to.
110# NB - rpm doesn't do this; is it really necessary?
111my $installscript = '[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT'."\n";
112my $cleanscript = '';
113# pre/post (un)install scripts. Note that these will likely barf as-is. :/
114my $preinstscript = '';
115my $postinstscript = '';
116my $preuninstscript = '';
117my $postuninstscript = '';
118
119die "Not enough arguments\n" if #$argv == 0;
120
121# Snag some environment data
122my $tmpdir;
123if (defined $ENV{TMP} && $ENV{TMP} =~ /^(\/var)?\/tmp$/) {
124 $tmpdir = $ENV{TMP};
125} else {
126 $tmpdir = "/var/tmp";
127}
128
129##main
130
131load_userconfig();
132parse_cmd();
133
134if ($cmdopts{install}) {
135 install_sdeb();
136 exit 0;
137}
138
139# Stick --rebuild handling in here - basically install_sdeb()
140# followed by tweaking options to run with -ba
141if ($cmdopts{type} eq 's') {
142 if ($srcpkg =~ /\.src\.rpm$/) {
143 @srclist = qx { rpm -qlp $srcpkg };
144 foreach (@srclist) {
145 chomp;
146 $specfile = "$topdir/SPECS/$_" if /\.spec$/;
147 }
148 qx { rpm -i $srcpkg };
149 } else {
150 install_sdeb();
151 my @srclist = qx { pax < $srcpkg };
152 foreach (@srclist) {
153 chomp;
154 $specfile = "$topdir/$_" if /SPECS/;
155 }
156 }
157 $cmdopts{type} = 'b';
158 $cmdopts{stage} = 'a';
159}
160
161if ($cmdopts{type} eq 'b') {
162 # Need to read the spec file to find the tarball. Note that
163 # this also generates most of the shell script required.
164 parse_spec();
165 die "Can't build $pkgdata{main}{name}: build requirements not met.\n"
166 if !checkbuildreq();
167}
168
169# -> srcpkg if -.s
170if ($cmdopts{stage} eq 's') {
171 srcpackage();
172 exit 0;
173}
174
175# Hokay. Need to:
176# -> prep if -.p OR (-.[cilabs] AND !--short-circuit)
177if ($cmdopts{stage} eq 'p' || ($cmdopts{stage} =~ /[cilabs]/ && $cmdopts{short} ne 'y')) {
178 prep();
179}
180# -> build if -.c OR (-.[ilabs] AND !--short-circuit)
181if ($cmdopts{stage} eq 'c' || ($cmdopts{stage} =~ /[ilabs]/ && $cmdopts{short} ne 'y')) {
182 build();
183}
184# -> install if -.[ilabs]
185#if ($cmdopts{stage} eq 'i' || ($cmdopts{stage} =~ /[labs]/ && $cmdopts{short} ne 'y')) {
186if ($cmdopts{stage} =~ /[ilabs]/) {
187 install();
188#foreach my $pkg (@pkglist) {
189# print "files in $pkg:\n ".$filelist{$pkg}."\n";
190#}
191
192}
193# -> binpkg and srcpkg if -.a
194if ($cmdopts{stage} eq 'a') {
195 binpackage();
196 srcpackage();
197}
198# -> binpkg if -.b
199if ($cmdopts{stage} eq 'b') {
200 binpackage();
201}
202
203# Just in case.
204exit 0;
205
206
207## load_userconfig()
208# Loads user configuration (if any)
209# Currently only handles .debmacros
210# Needs to handle "other files"
211sub load_userconfig {
212 my (undef,undef,undef,undef,undef,undef,undef,$homedir,undef) = getpwuid($<);
213 if (-e "$homedir/.debmacros") {
214 open USERMACROS,"<$homedir/.debmacros";
215 while (<USERMACROS>) {
216 # And we also only handle a few macros at the moment.
217 if (/^\%_topdir/) {
218 my (undef,$tmp) = split /\s+/, $_;
219 $topdir = $tmp;
220 }
221 }
222 }
223} # end load_userconfig()
224
225
226## parse_cmd()
227# Parses command line into global hash %cmdopts, other globals
228# Options based on rpmbuild's options
229sub parse_cmd {
230 # Don't feel like coding my own option parser...
231 #use Getopt::Long;
232 # ... but I may have to: (OTOH, rpm uses popt, so maybe we can too.)
233 #use Getopt::Popt qw(:all);
234 # Or not. >:( Stupid Debian lack of findable Perl module names in packages.
235
236 # Stuff it.
237 my $prevopt = '';
238 foreach (@ARGV) {
239 chomp;
240
241 # Is it an option?
242 if (/^-/) {
243
244 # Is it a long option?
245 if (/^--/) {
246 if (/^--short-circuit/) {
247 $cmdopts{short} = 'y';
248 } elsif (/^--rebuild/) {
249 $cmdopts{type} = 's';
250 } else {
251 print "Long opt $_\n";
252 }
253 } else {
254 # Not a long option
255 if (/^-[bt]/) {
256 if ($cmdopts{stage} eq 's') {
257 # Mutually exclusive options.
258 die "Can't use $_ with --rebuild\n";
259 } else {
260 # Capture the type (from "bare" files or tarball) and the stage (prep, build, etc)
261 ($cmdopts{stage}) = (/^-[bt]([pcilabs])/);
262 ($cmdopts{type}) = (/^-([bt])[pcilabs]/);
263 }
264 } elsif (/^-v/) {
265 # bump verbosity. Not sure what I'll actually do here...
266 } elsif (/^-i/) {
267 $cmdopts{install} = 1;
268 $prevopt = '-i';
269 } else {
270 die "Bad option $_\n";
271 }
272 }
273
274 } else { # Not an option argument
275
276 # --buildroot is the only option that takes an argument
277 # Therefore, any *other* bare arguments are the spec file,
278 # tarball, or source package we're operating on - depending
279 # on which one we meet.
280 if ($prevopt eq '--buildroot') {
281 $cmdbuildroot = $_;
282 } elsif ($prevopt eq '-i') {
283 $srcpkg = $_;
284 } else {
285 if ($cmdopts{type} eq 's') {
286 # Source package
287 if (!/(sdeb|\.src\.rpm)$/) {
288 die "Can't --rebuild with $_\n";
289 }
290 $srcpkg = $_;
291 } elsif ($cmdopts{type} eq 'b') {
292 $specfile = $_;
293 # Spec file
294 } else {
295 # Tarball
296 }
297 }
298 }
299 $prevopt = $_;
300 } # foreach @ARGV
301
302 # Some cross-checks. rpmbuild limits --short-circuit to just
303 # the "compile" and "install" targets - with good reason IMO.
304 # Note that --short-circuit with -.p is not really an error, just redundant.
305 # NB - this is NOT fatal, just ignored!
306 if ($cmdopts{short} eq 'y' && $cmdopts{stage} =~ /[labs]/) {
307 warn "Can't use --short-circuit for $targets{$cmdopts{stage}} stage. Ignoring.\n";
308 $cmdopts{short} = 'n';
309 }
310
311 # Valid options, with example arguments (if any):
312# Build from .spec file; mutually exclusive:
313 # -bp
314 # -bc
315 # -bi
316 # -bl
317 # -ba
318 # -bb
319 # -bs
320# Build from tarball; mutually exclusive:
321 # -tp
322 # -tc
323 # -ti
324 # -ta
325 # -tb
326 # -ts
327# Build from .src.(deb|rpm)
328 # --rebuild
329 # --recompile
330
331# General options
332 # --buildroot=DIRECTORY
333 # --clean
334 # --nobuild
335 # --nodeps
336 # --nodirtokens
337 # --rmsource
338 # --rmspec
339 # --short-circuit
340 # --target=CPU-VENDOR-OS
341
342 #my $popt = new Getopt::Popt(argv => \@ARGV, options => \@optionsTable);
343
344} # end parse_cmd()
345
346
347## parse_spec()
348# Parse the .spec file.
349sub parse_spec {
350 open SPECFILE,"<$specfile";
351
352LINE: while (<SPECFILE>) {
353 next if /^#/; # Ignore comments...
354 next if /^\s+$/; # ... and blank lines.
355
356 if (/^\%/) {
357 # A macro that needs further processing.
358
359 if (/^\%define\s+([^\s]+)\s+([^\s]+)/) {
360 $specglobals{$1} = expandmacros($2,'g');
361 }
362
363 if (/^\%description(?:\s+(?:-n\s+)?([a-zA-Z0-9_.-]+))?/) {
364 my $subname = "main";
365 if ($1) {
366 my $tmp = $1;
367 if (/-n/) { $subname = $tmp; } else { $subname = "$pkgdata{main}{name}-$tmp"; }
368 }
369 while (<SPECFILE>) {
370 next if /^#/; # Messy. Should be possible to do better. :/
371 redo LINE if /^\%/;
372 $pkgdata{$subname}{desc} .= " $_";
373 }
374 }
375 if (/^\%package\s+(?:-n\s+)?([a-zA-Z0-9_.-]+)/) {
376 my $subname = $1;
377 if (! /-n/) { $subname = "$pkgdata{main}{name}-$1"; }
378 push @pkglist, $subname;
379 $pkgdata{$subname}{name} = $subname;
380 $pkgdata{$subname}{version} = $pkgdata{main}{version};
381 while (<SPECFILE>) {
382 redo LINE if /^\%/;
383 if (my ($dname,$dvalue) = (/^(Summary|Group|Version|Requires|Provides):\s+(.+)$/i)) {
384 $dname =~ tr/[A-Z]/[a-z]/;
385 $pkgdata{$subname}{$dname} = $dvalue;
386 }
387 }
388 }
389
390 if (/^\%prep/) {
391 # %prep section. May have %setup macro; may include %patch tags,
392 # may be just a bare shell script.
393
394 # This really should be local-ish, but we need just the filename for the source
395 $pkgdata{main}{source} =~ s|.+/([^/]+)$|$1|;
396
397 # Replace some core macros
398 $pkgdata{main}{source} = expandmacros($pkgdata{main}{source},'gp');
399
400PREPSCRIPT: while (<SPECFILE>) {
401 if (/^\%setup/) {
402 # Parse out the %setup macro. Note that we aren't supporting
403 # many of RPM's %setup features.
404 $prepscript .= "cd $topdir/BUILD\n";
405 if ( /\s+-n\s+([^\s]+)\s+/ ) {
406 $tarballdir = $1;
407 } else {
408 $tarballdir = "$pkgdata{main}{name}-$pkgdata{main}{version}";
409 }
410 $prepscript .= "rm -rf $tarballdir\ntar -".
411 ( $pkgdata{main}{source} =~ /\.tar\.gz$/ ? "z" : "" ).
412 ( $pkgdata{main}{source} =~ /\.tar\.bz2$/ ? "j" : "" ).
413 ( /\s+-q\s+/ ? '' : 'vv' )."xf ".
414 "$topdir/SOURCES/$pkgdata{main}{source}\n".
415 qq(STATUS=\$?\nif [ \$STATUS -ne 0 ]; then\n exit \$STATUS\nfi\n).
416 ( /\s+-n\s+([^\s]+)\s+/ ?
417 "cd $1\n" : "cd $pkgdata{main}{name}-$pkgdata{main}{version}\n" ).
418 qq([ `/usr/bin/id -u` = '0' ] && /bin/chown -Rhf root .\n).
419 qq([ `/usr/bin/id -u` = '0' ] && /bin/chgrp -Rhf root .\n).
420 qq(/bin/chmod -Rf a+rX,g-w,o-w .\n);
421 } elsif (/^\%patch([^:]+)\s+(.+)$/) {
422 $prepscript .= "patch $2 <$topdir/SOURCES/".$pkgdata{main}{"patch$1"}."\n";
423 } else {
424 last PREPSCRIPT if /^\%/;
425 $prepscript .= $_;
426 }
427 }
428 redo LINE;
429 }
430 if (/^\%build/) {
431 # %build. This is pretty much just a shell script. There
432 # *are* a few macros, but we're not going to deal with them yet.
433 $buildscript .= "cd $tarballdir\n";
434BUILDSCRIPT: while (<SPECFILE>) {
435 if (/^\%configure/) {
436 $buildscript .= expandmacros($_,'cgbp');
437 } elsif (/^\%\{__make\}/) {
438 $buildscript .= expandmacros($_,'mgbp');
439 } else {
440 last BUILDSCRIPT if /^\%[^{]/;
441 $buildscript .= $_;
442 }
443 }
444 redo LINE;
445 }
446 if (/^\%install/) {
447 $installscript .= "cd $tarballdir\n";
448INSTALLSCRIPT: while (<SPECFILE>) {
449 if (/^\%makeinstall/) {
450 $installscript .= expandmacros($_,'igbp');
451 } else {
452 last INSTALLSCRIPT if /^\%/;
453 $installscript .= $_;
454 }
455 }
456 redo LINE;
457 }
458 if (/^\%clean/) {
459 while (<SPECFILE>) {
460 redo LINE if /^\%/;
461 $cleanscript .= $_;
462 }
463 $cleanscript = expandmacros($cleanscript,'gp');
464 }
465
466 # pre/post (un)install scripts
467 if (/^\%pre\b/) {
468 while (<SPECFILE>) {
469 redo LINE if /^\%/;
470 $preinstscript .= $_;
471 }
472 }
473 if (/^\%post\b/) {
474 while (<SPECFILE>) {
475 redo LINE if /^\%/;
476 $postinstscript .= $_;
477 }
478 }
479 if (/^\%preun\b/) {
480 while (<SPECFILE>) {
481 redo LINE if /^\%/;
482 $preuninstscript .= $_;
483 }
484 }
485 if (/^\%postun\b/) {
486 while (<SPECFILE>) {
487 redo LINE if /^\%/;
488 $postuninstscript .= $_;
489 }
490 }
491 # done %pre/%post scripts
492
493 if (/^\%files(?:\s+(?:-n\s+)?([a-zA-z0-9]+))?/) {
494 my $pkgname = 'main';
495 if ($1) { # Magic to add entries to the right list of files
496 my $tmp = $1;
497 if (/-n/) { $pkgname = $tmp; } else { $pkgname = "$pkgdata{main}{name}-$tmp"; }
498 }
499
500 # Set this now, so it can be flipped a bit later, and used much later.
501 #$pkgdata{$pkgname}{conffiles} = 0;
502
503 while (<SPECFILE>) {
504 chomp;
505 next if /^#/;
506 # need to update this to deal (properly) with %dir, %attr, etc
507 next if /^\%dir/;
508 next if /^\%attr/;
509 next if /^\%defattr/;
510
511 # Debian dpkg doesn't speak "%docdir". Meh.
512 next if /^\%docdir/;
513
514 # Conffiles. Note that Debian and RH have similar, but not
515 # *quite* identical ideas of what constitutes a conffile. Nrgh.
516 if (/^\%config\s+(.+)$/) {
517 $pkgdata{$pkgname}{conffiles} = 1; # Flag it for later
518 my $tmp = $1; # Now we can mangleificationate it. And we probably need to. :/
519 $tmp = expandmacros($tmp, 'gp'); # Expand common macros
520 if ($tmp !~ /\s+/) {
521 # Simplest case, just a file. Whew.
522 push @{$pkgdata{$pkgname}{conflist}}, $tmp;
523 $filelist{$pkgname} .= " $tmp";
524 } else {
525 # Wot? Spaces? That means extra %-macros. Which, for the most part, can be ignored.
526 ($tmp) = ($tmp =~ /.+\s([^\s]+)/); # Strip everything before the last space
527 push @{$pkgdata{$pkgname}{conflist}}, $tmp;
528 $filelist{$pkgname} .= " $tmp";
529 }
530 next;
531 }
532
533 # and finally we can fall through %{_<FHS>}-prefixed locations...
534 if (/^\%\{_/) {
535 $filelist{$pkgname} .= " $_";
536 next;
537 }
538 # EW. Necessary to clear up %define expansions before we exit with redo.
539 $_ = expandmacros $_, 'g';
540
541 # ... unknown or "next section" % directives ...
542 redo LINE if /^\%/;
543
544 # ... and "normal" files
545 $filelist{$pkgname} .= " $_";
546 }
547 $filelist{$pkgname} = expandmacros($filelist{$pkgname}, 'gp');
548 } # done %file section
549
550 if (/^\%changelog/) {
551 $pkgdata{main}{changelog} = '';
552 while (<SPECFILE>) {
553 redo LINE if /^\%/;
554 $pkgdata{main}{changelog} .= $_;
555 }
556 }
557
558 } else { # Data from the spec file "header"
559
560 if (/^summary:\s+(.+)/i) {
561 $pkgdata{main}{summary} = $1;
562 } elsif (/^name:\s+(.+)/i) {
563 $pkgdata{main}{name} = expandmacros($1,'g');
564 } elsif (/^version:\s+(.+)/i) {
565 $pkgdata{main}{version} = expandmacros($1,'g');
566 } elsif (/^release:\s+(.+)/i) {
567 $pkgdata{main}{release} = expandmacros($1,'g');
568 } elsif (/^group:\s+(.+)/i) {
569 $pkgdata{main}{group} = $1;
570 } elsif (/^copyright:\s+(.+)/i) {
571 $pkgdata{main}{copyright} = $1;
572 } elsif (/^url:\s+(.+)/i) {
573 $pkgdata{main}{url} = $1;
574 } elsif (/^packager:\s+(.+)/i) {
575 $pkgdata{main}{packager} = $1;
576 } elsif (/^buildroot:\s+(.+)/i) {
577 $buildroot = $1;
578 } elsif (/^source:\s+(.+)/i) {
579 $pkgdata{main}{source} = $1;
580 die "Unknown tarball format $1\n" if $1 !~ /\.tar\.(?:gz|bz2)$/;
581 } elsif (/^source([0-9]+):\s+(.+)/i) {
582 $pkgdata{sources}{$1} = $2;
583 } elsif (/^patch([^:]+):\s+(.+)$/i) {
584 my $patchname = "patch$1";
585 $pkgdata{main}{$patchname} = $2;
586 if ($pkgdata{main}{$patchname} =~ /\//) {
587 # URL-style patch. Rare but not unheard-of.
588 my @patchbits = split '/', $pkgdata{main}{$patchname};
589 $pkgdata{main}{$patchname} = $patchbits[$#patchbits];
590 }
591 } elsif (/^buildreq(?:uires)?:\s+(.+)/i) {
592 $buildreq .= ", $1";
593 } elsif (/^requires:\s+(.+)/i) {
594 $pkgdata{main}{requires} .= ", $1";
595 } elsif (/^provides:\s+(.+)/i) {
596 $pkgdata{main}{provides} .= ", $1";
597 } elsif (/^conflicts:\s+(.+)/i) {
598 $pkgdata{main}{conflicts} .= ", $1";
599 }
600#Name: suwrap
601#Version: 0.04
602#Release: 3
603#Group: Applications/System
604#Copyright: WebHart internal ONLY. :(
605#BuildArchitectures: i386
606#BuildRoot: /tmp/%{name}-%{version}
607#Url: http://virtual.webhart.net
608#Packager: Kris Deugau <kdeugau@deepnet.cx>
609#Source: ftp://virtual.webhart.net/%{name}-%{version}.tar.gz
610
611 }
612 }
613
614 # Parse and replace some more macros. More will be replaced even later.
615
616 # Expand macros as necessary.
617 $scriptletbase = expandmacros($scriptletbase,'gp');
618
619 $buildroot = $cmdbuildroot if $cmdbuildroot;
620 $buildroot = expandmacros($buildroot,'gp');
621
622 close SPECFILE;
623} # end parse_spec()
624
625
626## prep()
627# Writes and executes the %prep script (mostly) built while reading the spec file.
628sub prep {
629 # Replace some things here just to make sure.
630 $prepscript = expandmacros($prepscript,'gp');
631
632#print $prepscript; exit 0;
633
634 # create script filename
635 my $prepscriptfile = "$tmpdir/deb-tmp.prep.".int(rand(99998)+1);
636 sysopen(PREPSCRIPT, $prepscriptfile, O_RDWR | O_CREAT | O_EXCL | O_NOFOLLOW)
637 or die $!;
638 print PREPSCRIPT $scriptletbase;
639 print PREPSCRIPT $prepscript;
640 close PREPSCRIPT;
641
642 # execute
643 print "Calling \%prep script $prepscriptfile...\n";
644 system("/bin/sh -e $prepscriptfile") == 0
645 or die "Can't exec: $!\n";
646
647 # and clean up
648 unlink $prepscriptfile;
649} # end prep()
650
651
652## build()
653# Writes and executes the %build script (mostly) built while reading the spec file.
654sub build {
655 # Expand the macros
656 $buildscript = expandmacros($buildscript,'cgbp');
657
658 # create script filename
659 my $buildscriptfile = "$tmpdir/deb-tmp.build.".int(rand(99998)+1);
660 sysopen(BUILDSCRIPT, $buildscriptfile, O_RDWR | O_CREAT | O_EXCL | O_NOFOLLOW)
661 or die $!;
662 print BUILDSCRIPT $scriptletbase;
663 print BUILDSCRIPT $buildscript;
664 close BUILDSCRIPT;
665
666 # execute
667 print "Calling \%build script $buildscriptfile...\n";
668 system("/bin/sh -e $buildscriptfile") == 0
669 or die "Can't exec: $!\n";
670
671 # and clean up
672 unlink $buildscriptfile;
673} # end build()
674
675
676## install()
677# Writes and executes the %install script (mostly) built while reading the spec file.
678sub install {
679 # Expand the macros
680 $installscript = expandmacros($installscript,'igbp');
681
682 # create script filename
683 my $installscriptfile = "$tmpdir/deb-tmp.inst.".int(rand(99998)+1);
684 sysopen(INSTSCRIPT, $installscriptfile, O_RDWR | O_CREAT | O_EXCL | O_NOFOLLOW)
685 or die $!;
686 print INSTSCRIPT $scriptletbase;
687# print INSTSCRIPT $cleanscript; # Clean up our install target before installing into it.
688 print INSTSCRIPT $installscript;
689 close INSTSCRIPT;
690
691 # execute
692 print "Calling \%install script $installscriptfile...\n";
693 system("/bin/sh -e $installscriptfile") == 0
694 or die "Can't exec: $!\n";
695
696 # and clean up
697 unlink $installscriptfile;
698} # end install()
699
700
701## binpackage()
702# Creates the binary .deb package from the installed tree in $buildroot.
703# Writes and executes a shell script to do so.
704# Creates miscellaneous files required by dpkg-deb to actually build the package file.
705# Should handle simple subpackages
706sub binpackage {
707 # Make sure we have somewhere to write the .deb file
708 if (!-e "$topdir/DEBS/i386") {
709 mkdir "$topdir/DEBS/i386";
710 }
711
712 foreach my $pkg (@pkglist) {
713
714 # Gotta do this first, otherwise we don't have a place to move files from %files
715 mkdir "$buildroot/$pkg";
716
717 # Eliminate any lingering % macros
718 $filelist{$pkg} = expandmacros $filelist{$pkg}, 'g';
719
720 my @pkgfilelist = split ' ', $filelist{$pkg};
721 foreach my $pkgfile (@pkgfilelist) {
722 $pkgfile = expandmacros($pkgfile, 'gp');
723 my ($fpath,$fname) = ($pkgfile =~ m|(.+?/?)?([^/]+)$|); # We don't need $fname now, but we might.
724 qx { mkdir -p $buildroot/$pkg$fpath }
725 if $fpath && $fpath ne '';
726 qx { mv $buildroot$pkgfile $buildroot/$pkg$fpath };
727 }
728
729 # Get the "Depends" (Requires) a la RPM. Ish. We strip the leading
730 # comma and space here (if needed) in case there were "Requires" specified
731 # in the spec file - those would precede these.
732 ($pkgdata{$pkg}{requires} .= getreqs("$buildroot/$pkg")) =~ s/^, //;
733
734 # Do this here since we're doing {depends}...
735 if (defined($pkgdata{$pkg}{provides})) {
736 $pkgdata{$pkg}{provides} =~ s/^, //;
737 $pkgdata{$pkg}{provides} = expandmacros($pkgdata{$pkg}{provides},'gp');
738 }
739 if (defined($pkgdata{$pkg}{conflicts})) {
740 $pkgdata{$pkg}{conflicts} =~ s/^, //;
741 $pkgdata{$pkg}{conflicts} = expandmacros($pkgdata{$pkg}{conflicts},'gp');
742 }
743
744 # Gotta do this next, otherwise the control file has nowhere to go. >:(
745 mkdir "$buildroot/$pkg/DEBIAN";
746
747 # Hack the filename for the package into a Debian-tool-compatible format. GRRRRRR!!!!!
748 # Have I mentioned I hate Debian Policy?
749 $pkgdata{$pkg}{name} =~ tr/_/-/;
750
751 # create script filename
752 my $debscriptfile = "$tmpdir/deb-tmp.pkg.".int(rand(99998)+1);
753 sysopen(DEBSCRIPT, $debscriptfile, O_RDWR | O_CREAT | O_EXCL | O_NOFOLLOW)
754 or die $!;
755 print DEBSCRIPT $scriptletbase;
756 print DEBSCRIPT "fakeroot dpkg-deb -b $buildroot/$pkg $topdir/DEBS/i386/".
757 "$pkgdata{$pkg}{name}_$pkgdata{$pkg}{version}-$pkgdata{main}{release}_i386.deb\n";
758 # %$&$%@#@@#%@@@ Debian and their horrible ugly package names. >:(
759 close DEBSCRIPT;
760
761 my $control = "Package: $pkgdata{$pkg}{name}\n".
762 "Version: $pkgdata{$pkg}{version}-$pkgdata{main}{release}\n".
763 "Section: $pkgdata{$pkg}{group}\n".
764 "Priority: optional\n".
765 "Architecture: i386\n".
766 "Maintainer: $pkgdata{main}{packager}\n".
767 ( $pkgdata{$pkg}{requires} ne '' ? "Depends: $pkgdata{$pkg}{requires}\n" : '' ).
768 ( defined($pkgdata{$pkg}{provides}) ? "Provides: $pkgdata{$pkg}{provides}\n" : '' ).
769 ( defined($pkgdata{$pkg}{conflicts}) ? "Conflicts: $pkgdata{$pkg}{conflicts}\n" : '' ).
770 "Description: $pkgdata{$pkg}{summary}\n";
771 $control .= "$pkgdata{$pkg}{desc}\n";
772
773 open CONTROL, ">$buildroot/$pkg/DEBIAN/control";
774 print CONTROL $control;
775 close CONTROL;
776
777 # Iff there are conffiles (as specified in the %files list(s), add'em
778 # in so dpkg-deb can tag them.
779 if ($pkgdata{$pkg}{conffiles}) {
780 open CONFLIST, ">$buildroot/$pkg/DEBIAN/conffiles";
781 foreach my $conffile (@{$pkgdata{$pkg}{conflist}}) {
782 print CONFLIST "$conffile\n";
783 }
784 close CONFLIST;
785 }
786
787 # Can't see much point in scripts on subpackages... although since
788 # it's *possible* I should support it at some point.
789 if ($pkg eq 'main') {
790 if ($preinstscript ne '') {
791 $preinstscript = expandmacros($preinstscript,'g');
792 open PREINST, ">$buildroot/$pkg/DEBIAN/preinst";
793 print PREINST "#!/bin/sh\nset -e\n\n";
794 print PREINST $preinstscript;
795 close PREINST;
796 `chmod 0755 $buildroot/$pkg/DEBIAN/preinst`;
797 }
798 if ($postinstscript ne '') {
799 $postinstscript = expandmacros($postinstscript,'g');
800 open POSTINST, ">$buildroot/$pkg/DEBIAN/postinst";
801 print POSTINST "#!/bin/sh\nset -e\n\n";
802 print POSTINST $postinstscript;
803 close POSTINST;
804 `chmod 0755 $buildroot/$pkg/DEBIAN/postinst`;
805 }
806 if ($preuninstscript ne '') {
807 $preuninstscript = expandmacros($preuninstscript,'g');
808 open PREUNINST, ">$buildroot/$pkg/DEBIAN/prerm";
809 print PREUNINST "#!/bin/sh\nset -e\n\n";
810 print PREUNINST $preuninstscript;
811 close PREUNINST;
812 `chmod 0755 $buildroot/$pkg/DEBIAN/prerm`;
813 }
814 if ($postuninstscript ne '') {
815 $postuninstscript = expandmacros($postuninstscript,'g');
816 open POSTUNINST, ">$buildroot/$pkg/DEBIAN/postrm";
817 print POSTUNINST "#!/bin/sh\nset -e\n\n";
818 print POSTUNINST $postuninstscript;
819 close POSTUNINST;
820 `chmod 0755 $buildroot/$pkg/DEBIAN/postrm`;
821 }
822 }
823
824 # execute
825 print "Calling package creation script $debscriptfile for $pkgdata{$pkg}{name}...\n";
826 system("/bin/sh -e $debscriptfile") == 0
827 or die "Can't exec: $!\n";
828
829 # and clean up
830 unlink $debscriptfile;
831
832 } # subpackage loop
833
834} # end binpackage()
835
836
837## srcpackage()
838# Builds a .src.deb source package. Note that Debian's idea of
839# a "source package" is seriously flawed IMO, because you can't
840# easily copy it as-is.
841# Not quite identical to RPM, but Good Enough (TM).
842sub srcpackage {
843 # In case we were called with -bs.
844 $pkgdata{main}{name} =~ tr/_/-/;
845 my $pkgsrcname = "$pkgdata{main}{name}-$pkgdata{main}{version}-$pkgdata{main}{release}.sdeb";
846
847 my $paxcmd;
848
849 # We'll definitely need this later, and *may* need it sooner.
850 (my $barespec = $specfile) =~ s|.+/([^/]+)$|$1|;
851
852 # Copy the specfile to the build tree, but only if it's not there already.
853##buglet: need to deal with silly case where silly user has put the spec
854# file in a subdir of %{_topdir}/SPECS. Ewww. Silly user!
855 if (abs_path($specfile) !~ /^$topdir\/SPECS/) {
856 $paxcmd .= "cp $specfile %{_topdir}/SPECS/; \n"
857 }
858
859 # use pax -w [file] [file] ... >outfile.sdeb
860 $paxcmd = "cd $topdir; pax -w ";
861
862# tweak source entry into usable form. Need it locally somewhere along the line.
863 (my $pkgsrc = $pkgdata{main}{source}) =~ s|.+/([^/]+)$|$1|;
864 $paxcmd .= "SOURCES/$pkgsrc ";
865
866 # create file list: Source[nn], Patch[nn]
867 foreach my $specbit (keys %{$pkgdata{main}} ) {
868 next if $specbit eq 'source';
869 $paxcmd .= "SOURCES/$pkgdata{main}{$specbit} " if $specbit =~ /^patch/;
870##buglet: need to deal with case where patches are listed as URLs?
871# or other extended pathnames? Silly !@$%^&!%%!%!! user!
872 }
873
874 foreach my $source (keys %{$pkgdata{sources}}) {
875 $paxcmd .= "SOURCES/$pkgdata{sources}{$source} ";
876 }
877
878 # add the spec file, source package destination, and cd back where we came from.
879 $paxcmd .= "SPECS/$barespec > $topdir/SDEBS/$pkgsrcname; cd -";
880
881 # In case of %-macros...
882 $paxcmd = expandmacros($paxcmd,'gp');
883
884 system "$paxcmd";
885 print "Wrote source package $pkgsrcname in $topdir/SDEBS.\n";
886}
887
888
889## checkbuildreq()
890# Checks the build requirements (if any)
891# Spits out a rude warning and returns a true-false error if any
892# requirements are not met.
893sub checkbuildreq {
894 return 1 if $buildreq eq ''; # No use doing extra work.
895
896 if ( ! -e "/usr/bin/dpkg-query" ) {
897 print "**WARNING** dpkg-query not found. Can't check build-deps.\n".
898 " Required for sucessful build:\n".$buildreq."\n".
899 " Continuing anyway.\n";
900 return 1;
901 }
902
903 my $reqflag = 1; # unset iff a buildreq is missing
904
905 $buildreq =~ s/^, //; # Strip the leading comma and space
906 my @reqlist = split /,\s+/, $buildreq;
907
908 foreach my $req (@reqlist) {
909 my ($pkg,$rel,$ver);
910
911 # We have two classes of requirements - versioned and unversioned.
912 if ($req =~ /[><=]/) {
913 # Pick up the details of versioned buildreqs
914 ($pkg,$rel,$ver) = ($req =~ /([a-z0-9._-]+)\s+([><=]+)\s+([a-z0-9._-]+)/);
915 } else {
916 # And the unversioned ones.
917 $pkg = $req;
918 $rel = '>=';
919 $ver = 0;
920 }
921
922 my @pkglist = qx { dpkg-query --showformat '\${status}\t\${version}\n' -W $pkg };
923# need to check if no lines returned - means a bad buildreq
924 my ($reqstat,undef,undef,$reqver) = split /\s+/, $pkglist[0];
925 if ($reqstat !~ /install/) {
926 print " * Missing build-dependency $pkg!\n";
927 $reqflag = 0;
928 } else {
929# gotta be a better way to do this... :/
930 if ($rel eq '>=' && !($reqver ge $ver)) {
931 print " * Buildreq $pkg is installed, but wrong version ($reqver): Need $ver\n";
932 $reqflag = 0;
933 }
934 if ($rel eq '>' && !($reqver gt $ver)) {
935 print " * Buildreq $pkg is installed, but wrong version ($reqver): Need $ver\n";
936 $reqflag = 0;
937 }
938 if ($rel eq '<=' && !($reqver le $ver)) {
939 print " * Buildreq $pkg is installed, but wrong version ($reqver): Need $ver\n";
940 $reqflag = 0;
941 }
942 if ($rel eq '<' && !($reqver lt $ver)) {
943 print " * Buildreq $pkg is installed, but wrong version ($reqver): Need $ver\n";
944 $reqflag = 0;
945 }
946 if ($rel eq '=' && !($reqver eq $ver)) {
947 print " * Buildreq $pkg is installed, but wrong version ($reqver): Need $ver\n";
948 $reqflag = 0;
949 }
950 } # end not installed/installed check
951 } # end req loop
952
953 return $reqflag;
954} # end checkbuildreq()
955
956
957## getreqs()
958# Find out which libraries/packages are required for any
959# executables and libs in a given file tree.
960# (Debian doesn't have soname-level deps; just package-level)
961# Returns an empty string if the tree contains no binaries.
962# Doesn't work well on shell scripts. but those *should* be
963# fine anyway. (Yeah, right...)
964sub getreqs() {
965 my $pkgtree = $_[0];
966
967 print "Checking library requirements...\n";
968 my @binlist = qx { find $pkgtree -type f -perm 755 };
969
970 if (scalar(@binlist) == 0) {
971 return '';
972 }
973
974 my @reqlist;
975 foreach (@binlist) {
976 push @reqlist, qx { ldd $_ };
977 }
978
979 # Get the list of libs provided by this package. Still doesn't
980 # handle the case where the lib gets stuffed into a subpackage. :/
981 my @intprovlist = qx { find $pkgtree -type f -name "*.so*" };
982 my $provlist = '';
983 foreach (@intprovlist) {
984 s/$pkgtree//;
985 $provlist .= "$_";
986 }
987
988 my %reqs;
989 my $reqlibs = '';
990
991 foreach (@reqlist) {
992 next if /^$pkgtree/;
993 next if /not a dynamic executable/;
994 next if m|/lib/ld-linux.so|; # Hack! Hack! PTHBTT! (libc suxx0rz)
995
996 my ($req) = (/^\s+([a-z0-9._-]+)/); # dig out the actual library (so)name
997
998 # Ignore libs provided by this package. Note that we don't match
999 # on word-boundary at the *end* of the lib we're looking for, as the
1000 # looked-for lib may not have the full soname version. (ie, it may
1001 # "just" point to one of the symlinks that get created somewhere.)
1002 next if $provlist =~ /\b$req/;
1003
1004 $reqlibs .= " $req";
1005 }
1006
1007 if ($reqlibs ne '') {
1008 foreach (qx { dpkg -S $reqlibs }) {
1009 my ($libpkg,undef) = split /:\s+/;
1010 $reqs{$libpkg} = 1;
1011 }
1012 }
1013
1014 my $deplist = '';
1015 foreach (keys %reqs) {
1016 $deplist .= ", $_";
1017 }
1018
1019# For now, we're done. We're not going to meddle with versions yet.
1020# Among other things, it's messier than handling "simple" yes/no "do
1021# we have this lib?" deps. >:(
1022
1023 return $deplist;
1024} # end getreqs()
1025
1026
1027## install_sdeb()
1028# Extracts .sdeb contents to %_topdir as appropriate
1029sub install_sdeb {
1030 my $paxcmd = "cd $topdir; pax -r <$srcpkg; cd -";
1031
1032 # In case of %-macros...
1033 $paxcmd = expandmacros($paxcmd,'gp');
1034
1035 system "$paxcmd";
1036 print "Extracted source package $srcpkg to $topdir.\n";
1037} # end install_sdeb()
1038
1039
1040## expandmacros()
1041# Expands all %{blah} macros in the passed string
1042# Split up a bit with some sections so we don't spend time trying to
1043# expand macros that are only used in a few specific places.
1044sub expandmacros {
1045 my $macrostring = shift;
1046 my $section = shift;
1047
1048 # To allow the FHS-ish %configure and %makeinstall to work The Right Way.
1049 # (Without clobbering the global $buildroot.)
1050 my $prefix = '';
1051
1052 if ($section =~ /c/) {
1053 # %configure macro
1054# Don't know what it's for, don't have a useful default replacement
1055# --program-prefix=%{_program_prefix} \
1056 $macrostring =~ s'%configure'./configure --host=$DEB_HOST_GNU_TYPE \
1057 --build=$DEB_BUILD_GNU_TYPE \
1058 --prefix=%{_prefix} \
1059 --exec-prefix=%{_exec_prefix} \
1060 --bindir=%{_bindir} \
1061 --sbindir=%{_sbindir} \
1062 --sysconfdir=%{_sysconfdir} \
1063 --datadir=%{_datadir} \
1064 --includedir=%{_includedir} \
1065 --libdir=%{_libdir} \
1066 --libexecdir=%{_libexecdir} \
1067 --localstatedir=%{_localstatedir} \
1068 --sharedstatedir=%{_sharedstatedir} \
1069 --mandir=%{_mandir} \
1070 --infodir=%{_infodir} ';
1071 } # done %configure
1072
1073 if ($section =~ /m/) {
1074 $macrostring =~ s'%{__make}'make ';
1075 } # done make
1076
1077 if ($section =~ /i/) {
1078 # This is where we need to mangle $prefix.
1079 $macrostring =~ s'%makeinstall'make %{fhs} install';
1080 $prefix = $buildroot;
1081 } # done %install and/or %makeinstall
1082
1083 # Build data
1084 # Note that these are processed in reverse order to get the substitution order right
1085 if ($section =~ /b/) {
1086# $macrostring =~ s'%{fhs}'host=$DEB_HOST_GNU_TYPE \
1087# build=$DEB_BUILD_GNU_TYPE \
1088 $macrostring =~ s'%{fhs}'prefix=%{_prefix} \
1089 exec-prefix=%{_exec_prefix} \
1090 bindir=%{_bindir} \
1091 sbindir=%{_sbindir} \
1092 sysconfdir=%{_sysconfdir} \
1093 datadir=%{_datadir} \
1094 includedir=%{_includedir} \
1095 libdir=%{_libdir} \
1096 libexecdir=%{_libexecdir} \
1097 localstatedir=%{_localstatedir} \
1098 sharedstatedir=%{_sharedstatedir} \
1099 mandir=%{_mandir} \
1100 infodir=%{_infodir} \
1101';
1102
1103 # Note that the above regex terminates with the extra space
1104 # "Just In Case" of user additions, which will then get neatly
1105 # tagged on the end where they take precedence (supposedly)
1106 # over the "default" ones.
1107
1108 # Now we cascade the macros introduced above. >_<
1109 # Wot ot to go theah:
1110 $macrostring =~ s|%{_mandir}|%{_datadir}/man|g; #/usr/share/man
1111 $macrostring =~ s|%{_infodir}|%{_datadir}/info|g; #/usr/share/info
1112 $macrostring =~ s|%{_oldincludedir}|/usr/include|g; #/usr/include
1113 $macrostring =~ s|%{_includedir}|%{_prefix\}/include|g; #/usr/include
1114 $macrostring =~ s|%{_libdir}|%{_exec_prefix}/%{_lib}|g; #/usr/lib
1115 $macrostring =~ s|%{_lib}|lib|g; #?
1116 $macrostring =~ s|%{_localstatedir}|/var|g; #/var
1117 $macrostring =~ s|%{_sharedstatedir}|%{_prefix}/com|g; #/usr/com WTF?
1118 $macrostring =~ s|%{_sysconfdir}|/etc|g; #/etc
1119 $macrostring =~ s|%{_datadir}|%{_prefix}/share|g; #/usr/share
1120 $macrostring =~ s|%{_libexecdir}|%{_exec_prefix}/libexec|g; #/usr/libexec
1121 $macrostring =~ s|%{_sbindir}|%{_exec_prefix}/sbin|g; #/usr/sbin
1122 $macrostring =~ s|%{_bindir}|%{_exec_prefix}/bin|g; #/usr/bin
1123 $macrostring =~ s|%{_exec_prefix}|%{_prefix}|g; #/usr
1124 $macrostring =~ s|%{_prefix}|/usr|g; #/usr
1125 } # done with config section
1126
1127 # Package data
1128 if ($section =~ /p/) {
1129 $macrostring =~ s/\%\{buildroot\}/$buildroot/gi;
1130 foreach my $source (keys %{$pkgdata{sources}}) {
1131 $macrostring =~ s/\%\{source$source\}/$topdir\/SOURCES\/$pkgdata{sources}{$source}/gi;
1132 }
1133 $macrostring =~ s/\%\{name\}/$pkgdata{main}{name}/gi;
1134 $macrostring =~ s/\%\{version\}/$pkgdata{main}{version}/gi;
1135 $macrostring =~ s/\%\{release\}/$pkgdata{main}{release}/gi;
1136 }
1137
1138 # Globals, and not-so-globals
1139 if ($section =~ /g/) {
1140 $macrostring =~ s|%{_builddir}|%{_topdir}/BUILD|g;
1141 $macrostring =~ s|%{_topdir}|$topdir|g;
1142 $macrostring =~ s|%{_tmppath}|$tmpdir|g;
1143 $macrostring =~ s'%{_docdir}'/usr/share/doc'g;
1144
1145 # Standard FHS locations. More or less.
1146 $macrostring =~ s'%{_bindir}'/usr/bin'g;
1147 $macrostring =~ s'%{_sbindir}'/usr/sbin'g;
1148 $macrostring =~ s'%{_mandir}'/usr/share/man'g;
1149 $macrostring =~ s'%{_includedir}'/usr/include'g;
1150 $macrostring =~ s'%{_libdir}'/usr/lib'g;
1151 $macrostring =~ s'%{_sysconfdir}'/etc'g;
1152 $macrostring =~ s'%{_localstatedir}'/var'g;
1153
1154 # %define's
1155 foreach my $key (keys %specglobals) {
1156 $macrostring =~ s|%{$key}|$specglobals{$key}|g;
1157 }
1158
1159 # system programs. RPM uses a global config file for these; we'll just
1160 # ASS-U-ME and make life a little simpler.
1161 if ($macrostring =~ /\%\{\_\_([a-z0-9_-]+)\}/) {
1162 $macrostring =~ s|%{__([a-z0-9_-]+)}|$1|g;
1163 }
1164 } # done with globals section
1165
1166 return $macrostring;
1167} # end expandmacros()
1168
1169
1170
1171__END__
1172
1173
1174
1175=head1 NAME
1176
1177debbuild - Build Debian-compatible packages from RPM spec files
1178
1179=head1 SYNOPSIS
1180
1181 debbuild {-ba|-bb|-bp|-bc|-bi|-bl|-bs} [build-options] file.spec
1182
1183 debbuild {-ta|-tb|-tp|-tc|-ti|-tl|-ts} [build-options] file.tar.{gz|bz2}
1184
1185 debbuild --rebuild file.{src.rpm|sdeb}
1186
1187=head1 DESCRIPTION
1188
1189This script attempts to build Debian-friendly semi-native packages from RPM spec files,
1190RPM-friendly tarballs, and RPM source packages (.src.rpm files). It accepts I<most> of the
1191options rpmbuild does, and should be able to interpret most spec files usefully. Perl
1192modules should be handled via CPAN+dh-make-perl instead; Debian's conventions for such
1193things do not lend themselves to automated conversion.
1194
1195As far as possible, the command-line options are identical to those from rpmbuild, although
1196several rpmbuild options are not supported.
1197
1198=head1 ASSUMPTIONS
1199
1200As with rpmbuild, debbuild makes some assumptions about your system.
1201
1202=over 4
1203
1204=item *
1205
1206Either you have rights to do as you please under /usr/src/debian, or you have created a file
1207~/.debmacros containing a suitable %_topdir definition.
1208
1209Where rpmbuild requires %_topdir/{BUILD,RPMS,SOURCES,SPECS,SRPMS} directories, debbuild
1210requires %_topdir/{BUILD,DEBS,SOURCES,SPECS,SDEBS} directories. Create them in advance;
1211some subdirectories are created automatically as needed, but most are not.
1212
1213=item *
1214
1215/var/tmp must allow script execution - rpmbuild and debbuild both rely on creating and
1216executing shell scripts for much of their functionality. By default, debbuild also creates
1217install trees under /var/tmp - however this is (almost) entirely under the control of the
1218package's .spec file.
1219
1220=item *
1221
1222If you wish to --rebuild a .src.rpm, your %_topdir for both debbuild and rpmbuild must either
1223match, or be suitably symlinked one direction or another so that both programs are effectively
1224working in the same tree. (Or you could just manually wrestle files around your system.)
1225
1226You could symlink ~/.rpmmacros to ~/.debmacros (or vice versa) and save yourself some hassle
1227if you need to rebuild .src.rpm packages on a regular basis. Currently debbuild only uses the
1228%_topdir macro definition, although there are many more things that rpmbuild can use from
1229~/.rpmmacros.
1230
1231=back
1232
1233=head1 SEE ALSO
1234
1235rpm(8), rpmbuild(8), and pretty much any document describing how to write a .spec file
1236
1237=head1 BUGS
1238
1239Probably plenty. If you see something objectionable in debbuild's behaviour, report it.
1240Send a patch if you feel inspired. I don't promise I'll do anything other than say "Yup,
1241that's broken." or "Got your message.".
1242
1243=cut
Note: See TracBrowser for help on using the repository browser.