- Timestamp:
- 10/25/05 16:59:09 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/debbuild
r3 r4 31 31 my $srcpkg; 32 32 my $verbosity = 0; 33 my %cmdopts = (type => '', 34 stage => 'a', 35 short => 'n' 36 ); 37 my %targets = ('p' => 'Prep', 38 'c' => 'Compile', 39 'i' => 'Install', 40 'l' => 'Verify %files', 41 'a' => 'Build binary and source', 42 'b' => 'Build binary', 43 's' => 'Build source' 44 ); 45 my $topdir = "/usr/src/debian"; 33 46 47 load_userconfig(); 34 48 parse_cmd(); 35 49 50 # Hokay. Need to: 51 # Execute prep if *not* --short-circuit 52 prep() if ($cmdopts{short} ne 'y'); 53 54 if ($cmdopts{stage} =~ /ciab/) { 55 # Execute build if bc 56 # Execute build if bi, ba, bb and NOT --short-circuit 57 build() if ( ($cmdopts{stage} eq 'c') || 58 (($cmdopts{stage} =~ /iab/) && ($cmdopts{short} ne 'y')) 59 ); 60 61 # -> Execute 62 install() if ($cmdopts{short} ne 'y'); 63 binpackage(); 64 } 65 66 srcpackage(); 67 68 69 70 # Just in case. 71 exit 0; 72 73 74 ## load_userconfig() 75 # Loads user configuration (if any) 76 # Currently only handles .debmacros 77 # Needs to handle "other files" 78 sub load_userconfig { 79 (undef,undef,undef,undef,undef,undef,undef,$homedir,undef) = getpwuid($<); 80 if (-e "$homedir/.debmacros") { 81 open USERMACROS,"<$homedir/.debmacros"; 82 while (<USERMACROS>) { 83 # And we also only handle the %_topdir macro at the moment. 84 if (/^\%_topdir/) { 85 (undef,$tmp) = split /\s+/, $_; 86 } 87 } 88 } 89 } # end load_userconfig() 90 91 36 92 ## parse_cmd() 37 # Parses command line into internal option (array|hash)93 # Parses command line into global hash %cmdopts, other globals 38 94 # Options based on rpmbuild's options 39 95 sub parse_cmd { … … 42 98 # ... but I may have to: (OTOH, rpm uses popt, so maybe we can too.) 43 99 #use Getopt::Popt qw(:all); 100 # Or not. >:( Stupid Debian lack of findable Perl module names in packages. 44 101 45 102 # Stuff it. 103 my $prevopt = ''; 46 104 foreach (@ARGV) { 47 105 chomp; 106 $prevopt = $_; 48 107 # Is it an option? 49 108 if (/^-/) { 50 109 # Is it a long option? 51 110 if (/^--/) { 52 print "Long opt $_\n"; 111 if (/^--short-circuit/) { 112 $cmdopts{short} = 'y'; 113 } else { 114 print "Long opt $_\n"; 115 } 53 116 } else { 54 print "Short opt $_\n"; 117 if (/^-[bts]/) { 118 ($cmdopts{stage}) = (/^-[bts]([pcilabs])/); 119 ($cmdopts{type}) = (/^-([bts])[pcilabs]/); 120 } elsif (/^-v/) { 121 # bump verbosity. Not sure what I'll actually do here... 122 } else { 123 die "Bad option $_\n"; 124 } 55 125 } 56 126 } else { 57 127 print "Non-option arg $_\n"; 58 128 } 129 } 130 131 # Some cross-checks. rpmbuild limits --short-circuit to just 132 # the "compile" and "install" targets - with good reason IMO. 133 # NB - this is NOT fatal, just ignored! 134 if ($cmdopts{short} eq 'y') { 135 warn "Can't use --short-circuit for $targets{$cmdopts{stage}} stage. Ignoring.\n"; 136 $cmdopts{short} = 'n'; 59 137 } 60 138 # Valid options, with example arguments (if any): … … 93 171 } # end parse_cmd() 94 172 95 ## unpack() 173 174 ## prep() 96 175 # Unpacks the tarball from the SOURCES directory to the BUILD directory. 97 176 # Speaks gzip and bzip2. 98 177 # Requires the "package name" 99 sub unpack(){} 178 # Finishes by applying patches in %prep section of spec file 179 sub prep { 180 my $pkgname = shift; 181 182 } # end prep() 100 183 101 sub patch(){} 102 sub configure(){} 103 sub build(){} 104 sub install(){} 105 sub package(){} 106 sub srcpackage(){} 184 185 sub build {} 186 sub install {} 187 sub binpackage {} 188 sub srcpackage {}
Note:
See TracChangeset
for help on using the changeset viewer.