Changeset 6 for trunk


Ignore:
Timestamp:
10/31/05 17:58:40 (19 years ago)
Author:
kdeugau
Message:

/trunk

Checkpoint

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/debbuild

    r5 r6  
    1212
    1313use strict;
     14use warnings;
    1415
    1516# Program flow:
     
    3233my $tarball;
    3334my $srcpkg;
     35
     36# Initialized globals
    3437my $verbosity = 0;
    3538my %cmdopts = (type => '',
     
    3740                short => 'n'
    3841        );
     42my $topdir = "/usr/src/debian";
     43
     44# "Constants"
    3945my %targets = ('p' => 'Prep',
    4046                'c' => 'Compile',
     
    4551                's' => 'Build source'
    4652        );
    47 my $topdir = "/usr/src/debian";
     53my $scriptletbase =
     54q(#!/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);
    4875
    4976# Package data
     
    5178# meta includes Summary, Name, Version, Release, Group, Copyright,
    5279#       Source, URL, Packager, BuildRoot, Description
     80# 10/31/2005 Maybe this should be flatter?  -kgd
    5381my %pkgdata;
     82
     83# Scriptlets
     84my $prepscript;
     85my $buildscript;
     86my $installscript;
    5487
    5588# Functions
     
    228261    if ($pkgdata{main}{source} =~ /(.+)\.tar\.gz$/) {
    229262      -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}";
    231264    } elsif ($pkgdata{main}{source} =~ /(.+)\.tar\.bz2$/) {
    232265      -e "$topdir/BUILD/$1" && system "rm -rf $topdir/BUILD/$1";
    233       system "cd $topdir/BUILD;tar -jxvf $topdir/SOURCES/$pkgdata{main}{source}";
     266      system "cd $topdir/BUILD;tar -jxvvf $topdir/SOURCES/$pkgdata{main}{source}";
    234267    } else {
    235268      die "Unknown source tarball format\n";
     
    245278  open SPECFILE,"<$specfile";
    246279
    247   while (<SPECFILE>) {
     280LINE: while (<SPECFILE>) {
    248281    next if /^#/;
    249282    next if /^\s+$/;
    250283    if (/^\%/) {
    251284      # 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
     296PREPSCRIPT: 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      }
    252323      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!
    254345      }
    255346    } else {
     
    272363      } elsif (/^source:\s+(.+)/i) {
    273364        $pkgdata{main}{source} = $1;
     365        die "Unknown tarball format $1\n" if $1 !~ /\.tar\.(?:gz|bz2)$/;
    274366      }
    275367#Name: suwrap
Note: See TracChangeset for help on using the changeset viewer.