/** * Generate pkgs.list from source.list. * * Authors: * Gregor Richards * * License: * Copyright (c) 2006 Gregor Richards * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ module pkgslist; import std.file; import std.path; import std.process; import std.stdio; import std.string; import sss.conf; import sss.net; int main(char[][] args) { char[] mirrordir = getcwd() ~ std.path.sep ~ ".." ~ std.path.sep ~ "mirror" ~ std.path.sep; getPrefix(args[0]); srcListPrefix = getcwd(); char[] srclist = cast(char[]) read("source.list"); char[][] srces = split(srclist, "\n"); char[] pkgs, curpkg; NetConfig nconf = ReadNetConfig(); foreach (src; srces) { if (src.length == 0 || src[0] == '#') continue; char[][] info = split(src, " "); if (info.length < 3) continue; // check if we've already ran over it if (exists(mirrordir ~ info[0] ~ std.path.sep ~ "pkg.list")) { // just take whatever data is there pkgs ~= cast(char[]) std.file.read(mirrordir ~ info[0] ~ std.path.sep ~ "pkg.list"); continue; } curpkg = ""; // haven't done it yet, so do it mkdir(mirrordir ~ info[0]); chdir(mirrordir ~ info[0]); // retrieve source getSources(info[0], nconf); // read config void handleDir() { DSSSConf conf = readConfig(null); char[] vers = conf.settings[""]["version"]; // then get the list of modules foreach (section; conf.sections) { if (conf.settings[section]["type"] == "library" || conf.settings[section]["type"] == "sourcelibrary") { char[][] files = targetToFiles(section, conf); foreach (file; files) { curpkg ~= file ~ " " ~ vers ~ " " ~ info[0] ~ "\n"; } } else if (conf.settings[section]["type"] == "subdir") { char[] origcwd = getcwd(); chdir(section); handleDir(); chdir(origcwd); } } } handleDir(); // and add the package itself DSSSConf conf = readConfig(null); char[] vers = conf.settings[""]["version"]; curpkg ~= info[0] ~ " " ~ vers; if ("requires" in conf.settings[""]) { curpkg ~= " " ~ std.string.join( std.string.split(conf.settings[""]["requires"]), " "); } curpkg ~= "\n"; // write out the package info chdir(mirrordir ~ info[0]); write("pkg.list", curpkg); pkgs ~= curpkg; // remove garbage system("rm -f src.*"); system("find . -name .svn | xargs rm -rf"); // compress it system("tar -cf - * | gzip -9 > ../" ~ info[0] ~ ".tar.gz"); // cd back chdir(srcListPrefix); } write("pkgs.list", cast(char[]) pkgs); return 0; }