Changeset 5
- Timestamp:
- 10/28/05 18:04:31 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/debbuild
r4 r5 10 10 # Last update by $Author$ 11 11 ### 12 13 use strict; 12 14 13 15 # Program flow: … … 45 47 my $topdir = "/usr/src/debian"; 46 48 49 # Package data 50 # This is the form of $pkgdata{pkgname}{meta} 51 # meta includes Summary, Name, Version, Release, Group, Copyright, 52 # Source, URL, Packager, BuildRoot, Description 53 my %pkgdata; 54 55 # Functions 56 sub prep; 57 sub parse_spec; 58 59 die "Not enough arguments\n" if #$argv == 0; 60 47 61 load_userconfig(); 48 62 parse_cmd(); … … 77 91 # Needs to handle "other files" 78 92 sub load_userconfig { 79 (undef,undef,undef,undef,undef,undef,undef,$homedir,undef) = getpwuid($<);93 my (undef,undef,undef,undef,undef,undef,undef,$homedir,undef) = getpwuid($<); 80 94 if (-e "$homedir/.debmacros") { 81 95 open USERMACROS,"<$homedir/.debmacros"; … … 83 97 # And we also only handle the %_topdir macro at the moment. 84 98 if (/^\%_topdir/) { 85 (undef,$tmp) = split /\s+/, $_; 99 my (undef,$tmp) = split /\s+/, $_; 100 $topdir = $tmp; 86 101 } 87 102 } … … 111 126 if (/^--short-circuit/) { 112 127 $cmdopts{short} = 'y'; 128 } elsif (/^--rebuild/) { 129 $cmdopts{type} = 's'; 113 130 } else { 114 131 print "Long opt $_\n"; 115 132 } 116 133 } else { 117 if (/^-[bts]/) { 118 ($cmdopts{stage}) = (/^-[bts]([pcilabs])/); 119 ($cmdopts{type}) = (/^-([bts])[pcilabs]/); 134 if (/^-[bt]/) { 135 if ($cmdopts{stage} eq 's') { 136 # Mutually exclusive options. 137 die "Can't use $_ with --rebuild\n"; 138 } else { 139 ($cmdopts{stage}) = (/^-[bt]([pcilabs])/); 140 ($cmdopts{type}) = (/^-([bt])[pcilabs]/); 141 } 120 142 } elsif (/^-v/) { 121 143 # bump verbosity. Not sure what I'll actually do here... … … 125 147 } 126 148 } else { 127 print "Non-option arg $_\n"; 149 # --buildroot is the only option that takes an argument 150 # Therefore, any *other* bare arguments are the spec file, 151 # tarball, or source package we're operating on - depending 152 # on which one we meet. 153 if ($prevopt eq '--buildroot') { 154 # Set buildroot 155 } else { 156 if ($cmdopts{type} eq 's') { 157 # Source package 158 if (!/\.src\.(deb|rpm)$/) { 159 die "Can't --rebuild with $_\n"; 160 } 161 } elsif ($cmdopts{type} eq 'b') { 162 $specfile = $_; 163 # Spec file 164 } else { 165 # Tarball 166 } 167 } 128 168 } 129 169 } … … 175 215 # Unpacks the tarball from the SOURCES directory to the BUILD directory. 176 216 # Speaks gzip and bzip2. 177 # Requires the "package name"178 217 # Finishes by applying patches in %prep section of spec file 179 218 sub prep { 180 my $pkgname = shift; 181 219 if ($cmdopts{type} eq 'b') { 220 # Need to read the spec file to find the tarball 221 parse_spec(); 222 223 # Need to find the filename part of the tarball. In theory, we 224 # could go out to the URL and retrieve it, but that's Messy. 225 # want to make this local 226 $pkgdata{main}{source} =~ s|.+/([^/]+)$|$1|; 227 228 if ($pkgdata{main}{source} =~ /(.+)\.tar\.gz$/) { 229 -e "$topdir/BUILD/$1" && system "rm -rf $topdir/BUILD/$1"; 230 system "cd $topdir/BUILD;tar -zxvf $topdir/SOURCES/$pkgdata{main}{source}"; 231 } elsif ($pkgdata{main}{source} =~ /(.+)\.tar\.bz2$/) { 232 -e "$topdir/BUILD/$1" && system "rm -rf $topdir/BUILD/$1"; 233 system "cd $topdir/BUILD;tar -jxvf $topdir/SOURCES/$pkgdata{main}{source}"; 234 } else { 235 die "Unknown source tarball format\n"; 236 } 237 # And now for patches. (not) 238 } 182 239 } # end prep() 183 240 184 241 185 sub build {} 242 ## parse_spec() 243 # Parse the .spec file once we've.... uh.... 244 sub parse_spec { 245 open SPECFILE,"<$specfile"; 246 247 while (<SPECFILE>) { 248 next if /^#/; 249 next if /^\s+$/; 250 if (/^\%/) { 251 # A macro that needs further processing. 252 if (/^\%build/) { 253 # %build. This is pretty much just a shell script. 254 } 255 } else { 256 if (/^summary:\s+(.+)/i) { 257 $pkgdata{main}{summary} = $1; 258 } elsif (/^name:\s+(.+)/i) { 259 $pkgdata{main}{name} = $1; 260 } elsif (/^version:\s+(.+)/i) { 261 $pkgdata{main}{version} = $1; 262 } elsif (/^release:\s+(.+)/i) { 263 $pkgdata{main}{release} = $1; 264 } elsif (/^group:\s+(.+)/i) { 265 $pkgdata{main}{group} = $1; 266 } elsif (/^copyright:\s+(.+)/i) { 267 $pkgdata{main}{copyright} = $1; 268 } elsif (/^url:\s+(.+)/i) { 269 $pkgdata{main}{url} = $1; 270 } elsif (/^packager:\s+(.+)/i) { 271 $pkgdata{main}{packager} = $1; 272 } elsif (/^source:\s+(.+)/i) { 273 $pkgdata{main}{source} = $1; 274 } 275 #Name: suwrap 276 #Version: 0.04 277 #Release: 3 278 #Group: Applications/System 279 #Copyright: WebHart internal ONLY. :( 280 #BuildArchitectures: i386 281 #BuildRoot: /tmp/%{name}-%{version} 282 #Url: http://virtual.webhart.net 283 #Packager: Kris Deugau <kdeugau@deepnet.cx> 284 #Source: ftp://virtual.webhart.net/%{name}-%{version}.tar.gz 285 286 } 287 } 288 # Parse and replace macros in $pkgdata{}{} 289 # Start with the ones I use 290 $pkgdata{main}{source} =~ s/\%\{name\}/$pkgdata{main}{name}/; 291 $pkgdata{main}{source} =~ s/\%\{version\}/$pkgdata{main}{version}/; 292 } # end parse_spec() 293 294 295 ## build() 296 # Execute commands provided as a shell script. It may prove simpler 297 # to do as rpm does and actually create a little shell script. 298 sub build { 299 } # end build() 300 301 186 302 sub install {} 187 303 sub binpackage {}
Note:
See TracChangeset
for help on using the changeset viewer.