| 266 | | // 1) make the source directory |
|---|
| 267 | | char[] srcDir = scratchPrefix ~ std.path.sep ~ "DSSS_" ~ args[1]; |
|---|
| 268 | | char[] tmpDir = srcDir; |
|---|
| 269 | | mkdirP(srcDir); |
|---|
| 270 | | writefln("Working in %s", srcDir); |
|---|
| 271 | | |
|---|
| 272 | | // 2) chdir |
|---|
| 273 | | char[] origcwd = getcwd(); |
|---|
| 274 | | chdir(srcDir); |
|---|
| 275 | | |
|---|
| 276 | | // make sure the directory gets removed |
|---|
| 277 | | scope(exit) { |
|---|
| 278 | | chdir(origcwd); |
|---|
| 279 | | rmRecursive(tmpDir); |
|---|
| 280 | | } |
|---|
| 281 | | |
|---|
| 282 | | // 3) get sources |
|---|
| 283 | | if (!getSources(args[1], conf)) return 1; |
|---|
| 284 | | srcDir = getcwd(); |
|---|
| 285 | | |
|---|
| 286 | | // if we're just fetching, make the archive |
|---|
| 287 | | if (args[0] == "fetch") { |
|---|
| 288 | | char[] archname = args[1] ~ ".tar.gz"; |
|---|
| | 278 | foreach (packageName; packageNames) { |
|---|
| | 279 | // 1) make the source directory |
|---|
| | 280 | char[] srcDir = scratchPrefix ~ std.path.sep ~ "DSSS_" ~ packageName; |
|---|
| | 281 | char[] tmpDir = srcDir; |
|---|
| | 282 | mkdirP(srcDir); |
|---|
| | 283 | writefln("Working in %s", srcDir); |
|---|
| 322 | | // 5) install prerequisites |
|---|
| 323 | | char[][] netcmd; |
|---|
| 324 | | netcmd ~= "deps"; |
|---|
| 325 | | int netret = net(netcmd); |
|---|
| 326 | | if (netret) return netret; |
|---|
| 327 | | chdir(srcDir); |
|---|
| 328 | | |
|---|
| 329 | | // 6) build |
|---|
| 330 | | DSSSConf dconf = readConfig(null); |
|---|
| 331 | | int buildret = build(args[2..$], dconf); |
|---|
| 332 | | if (buildret) return buildret; |
|---|
| 333 | | |
|---|
| 334 | | // 7) install |
|---|
| 335 | | return install(args[2..$]); |
|---|
| | 299 | // if we're just fetching, make the archive |
|---|
| | 300 | if (args[0] == "fetch") { |
|---|
| | 301 | char[] archname = packageName ~ ".tar.gz"; |
|---|
| | 302 | |
|---|
| | 303 | // compress |
|---|
| | 304 | version (Windows) { |
|---|
| | 305 | // CyberShadow 2007.02.21: this code actually works now |
|---|
| | 306 | char[][] files = listdir(""); |
|---|
| | 307 | auto regexp = RegExp(r"^[^\.]"); |
|---|
| | 308 | char[] cmdline = "bsdtar -zcf " ~ archname; |
|---|
| | 309 | foreach(file;files) |
|---|
| | 310 | if(regexp.test(file)) |
|---|
| | 311 | cmdline ~= " " ~ file; |
|---|
| | 312 | saySystemDie(cmdline); |
|---|
| | 313 | } else { |
|---|
| | 314 | saySystemDie("tar -cf - * | gzip -c > " ~ archname); |
|---|
| | 315 | } |
|---|
| | 316 | |
|---|
| | 317 | // move into place |
|---|
| | 318 | try { |
|---|
| | 319 | std.file.rename(archname, |
|---|
| | 320 | origcwd ~ std.path.sep ~ archname); |
|---|
| | 321 | } catch (Exception x) { |
|---|
| | 322 | // can't rename, copy |
|---|
| | 323 | std.file.copy(archname, |
|---|
| | 324 | origcwd ~ std.path.sep ~ archname); |
|---|
| | 325 | std.file.remove(archname); |
|---|
| | 326 | } |
|---|
| | 327 | |
|---|
| | 328 | writefln("Archive %s created.", archname); |
|---|
| | 329 | return 0; |
|---|
| | 330 | } else { |
|---|
| | 331 | // 4) make sure it's not installed |
|---|
| | 332 | if (packageName != "dsss") |
|---|
| | 333 | uninstall([ packageName, args[2] ], true); |
|---|
| | 334 | |
|---|
| | 335 | // 5) install prerequisites |
|---|
| | 336 | char[][] netcmd; |
|---|
| | 337 | netcmd ~= "deps"; |
|---|
| | 338 | int netret = net(netcmd); |
|---|
| | 339 | if (netret) return netret; |
|---|
| | 340 | chdir(srcDir); |
|---|
| | 341 | |
|---|
| | 342 | // 6) build |
|---|
| | 343 | DSSSConf dconf = readConfig(null); |
|---|
| | 344 | int buildret = build([ packageName ] ~ args[2..$], dconf); |
|---|
| | 345 | if (buildret) return buildret; |
|---|
| | 346 | |
|---|
| | 347 | // 7) install |
|---|
| | 348 | return install([ packageName ] ~ args[2..$]); |
|---|
| | 349 | } |
|---|