Changeset 6
- Timestamp:
- 10/31/05 17:58:40 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/debbuild
r5 r6 12 12 13 13 use strict; 14 use warnings; 14 15 15 16 # Program flow: … … 32 33 my $tarball; 33 34 my $srcpkg; 35 36 # Initialized globals 34 37 my $verbosity = 0; 35 38 my %cmdopts = (type => '', … … 37 40 short => 'n' 38 41 ); 42 my $topdir = "/usr/src/debian"; 43 44 # "Constants" 39 45 my %targets = ('p' => 'Prep', 40 46 'c' => 'Compile', … … 45 51 's' => 'Build source' 46 52 ); 47 my $topdir = "/usr/src/debian"; 53 my $scriptletbase = 54 q(#!/bin/sh 55 56 RPM_SOURCE_DIR="%{_topdir}/SOURCES" 57 RPM_BUILD_DIR="%{_topdir}/BUILD" 58 RPM_OPT_FLAGS="-O2 -g -march=i386 -mcpu=i686" 59 RPM_ARCH="i386" 60 RPM_OS="linux" 61 export RPM_SOURCE_DIR RPM_BUILD_DIR RPM_OPT_FLAGS RPM_ARCH RPM_OS 62 RPM_DOC_DIR="/usr/share/doc" 63 export RPM_DOC_DIR 64 RPM_PACKAGE_NAME="%{name}" 65 RPM_PACKAGE_VERSION="%{version}" 66 RPM_PACKAGE_RELEASE="%{release}" 67 export RPM_PACKAGE_NAME RPM_PACKAGE_VERSION RPM_PACKAGE_RELEASE 68 RPM_BUILD_ROOT="%{buildroot}" 69 export RPM_BUILD_ROOT 70 71 set -x 72 umask 022 73 cd %{_topdir}/BUILD 74 ); 48 75 49 76 # Package data … … 51 78 # meta includes Summary, Name, Version, Release, Group, Copyright, 52 79 # Source, URL, Packager, BuildRoot, Description 80 # 10/31/2005 Maybe this should be flatter? -kgd 53 81 my %pkgdata; 82 83 # Scriptlets 84 my $prepscript; 85 my $buildscript; 86 my $installscript; 54 87 55 88 # Functions … … 228 261 if ($pkgdata{main}{source} =~ /(.+)\.tar\.gz$/) { 229 262 -e "$topdir/BUILD/$1" && system "rm -rf $topdir/BUILD/$1"; 230 system "cd $topdir/BUILD;tar -zxvf $topdir/SOURCES/$pkgdata{main}{source}";263 # system "cd $topdir/BUILD;tar -zxvvf $topdir/SOURCES/$pkgdata{main}{source}"; 231 264 } elsif ($pkgdata{main}{source} =~ /(.+)\.tar\.bz2$/) { 232 265 -e "$topdir/BUILD/$1" && system "rm -rf $topdir/BUILD/$1"; 233 system "cd $topdir/BUILD;tar -jxv f $topdir/SOURCES/$pkgdata{main}{source}";266 system "cd $topdir/BUILD;tar -jxvvf $topdir/SOURCES/$pkgdata{main}{source}"; 234 267 } else { 235 268 die "Unknown source tarball format\n"; … … 245 278 open SPECFILE,"<$specfile"; 246 279 247 280 LINE: while (<SPECFILE>) { 248 281 next if /^#/; 249 282 next if /^\s+$/; 250 283 if (/^\%/) { 251 284 # A macro that needs further processing. 285 if (/^\%prep/) { 286 # %prep section. May have %setup macro; may include %patch tags, 287 # may be just a bare shell script. 288 289 # This really should be local-ish, but we need just the filename for the source 290 $pkgdata{main}{source} =~ s|.+/([^/]+)$|$1|; 291 292 # Replace some core macros 293 $pkgdata{main}{source} =~ s/\%\{name\}/$pkgdata{main}{name}/; 294 $pkgdata{main}{source} =~ s/\%\{version\}/$pkgdata{main}{version}/; 295 296 PREPSCRIPT: while (<SPECFILE>) { 297 if (/^\%setup/) { 298 # Parse out the %setup macro. Note that we aren't supporting 299 # most of RPM's %setup features. 300 $prepscript .= "cd $topdir/BUILD\n". 301 ( /\s+-n\s+([^\s]+)\s+/ ? 302 "rm -rf $1\n" : "rm -rf $pkgdata{main}{name}-$pkgdata{main}{version}\n" ). 303 "tar -". 304 ( $pkgdata{main}{source} =~ /\.tar\.gz$/ ? "z" : "" ). 305 ( $pkgdata{main}{source} =~ /\.tar\.bz2$/ ? "j" : "" ). 306 "x".( /\s+-q\s+/ ? '' : 'vv' )."f ". 307 "$topdir/SOURCES/$pkgdata{main}{source}\n". 308 qq(STATUS=\$?\nif [ \$STATUS -ne 0 ]; then\n exit \$STATUS\nfi\n). 309 ( /\s+-n\s+([^\s]+)\s+/ ? 310 "cd $1\n" : "cd $pkgdata{main}{name}-$pkgdata{main}{version}\n" ). 311 qq([ `/usr/bin/id -u` = '0' ] && /bin/chown -Rhf root .\n). 312 qq([ `/usr/bin/id -u` = '0' ] && /bin/chgrp -Rhf root .\n). 313 qq(/bin/chmod -Rf a+rX,g-w,o-w .\n); 314 } elsif (/^\%patch/) { 315 print "patch macro\n"; 316 } else { 317 last PREPSCRIPT if /^\%/; 318 $prepscript .= $_; 319 } 320 } 321 redo LINE; 322 } 252 323 if (/^\%build/) { 253 # %build. This is pretty much just a shell script. 324 # %build. This is pretty much just a shell script. There 325 # *are* a few macros, but we're not going to deal with them yet. 326 while (<SPECFILE>) { 327 redo LINE if /^\%/; 328 $buildscript .= $_; 329 } 330 } 331 if (/^\%install/) { 332 while (<SPECFILE>) { 333 redo LINE if /^\%/; 334 $installscript .= $_; 335 } 336 } 337 if (/^\%clean/) { 338 } 339 if (/^\%post/) { 340 } 341 if (/^\%preun/) { 342 } 343 if (/^\%files/) { 344 # Danger! Danger! 254 345 } 255 346 } else { … … 272 363 } elsif (/^source:\s+(.+)/i) { 273 364 $pkgdata{main}{source} = $1; 365 die "Unknown tarball format $1\n" if $1 !~ /\.tar\.(?:gz|bz2)$/; 274 366 } 275 367 #Name: suwrap
Note:
See TracChangeset
for help on using the changeset viewer.