root/sources/pkgslist.d

Revision 564, 4.2 kB (checked in by Gregor, 1 year ago)

dsss.conf, pkgslist.d: Very necessary updates.

Line 
1 /**
2  * Generate pkgs.list from source.list.
3  *
4  * Authors:
5  *  Gregor Richards
6  *
7  * License:
8  *  Copyright (c) 2006  Gregor Richards
9  * 
10  *  Permission is hereby granted, free of charge, to any person obtaining a
11  *  copy of this software and associated documentation files (the "Software"),
12  *  to deal in the Software without restriction, including without limitation
13  *  the rights to use, copy, modify, merge, publish, distribute, sublicense,
14  *  and/or sell copies of the Software, and to permit persons to whom the
15  *  Software is furnished to do so, subject to the following conditions:
16  * 
17  *  The above copyright notice and this permission notice shall be included in
18  *  all copies or substantial portions of the Software.
19  * 
20  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21  *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22  *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23  *  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24  *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25  *  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26  *  DEALINGS IN THE SOFTWARE.
27  */
28
29 module pkgslist;
30
31 import std.file;
32 import std.path;
33 import std.process;
34 import std.stdio;
35 import std.string;
36
37 import sss.conf;
38 import sss.net;
39
40 int main(char[][] args)
41 {
42     char[] mirrordir = getcwd() ~ std.path.sep ~
43         ".." ~ std.path.sep ~
44         "mirror" ~ std.path.sep;
45    
46     getPrefix(args[0]);
47     srcListPrefix = getcwd();
48    
49     char[] srclist = cast(char[]) read("source.list");
50     char[][] srces = split(srclist, "\n");
51     char[] pkgs, curpkg;
52     NetConfig nconf = ReadNetConfig();
53    
54     foreach (src; srces) {
55         if (src.length == 0 || src[0] == '#') continue;
56        
57         char[][] info = split(src, " ");
58         if (info.length < 3) continue;
59        
60         // check if we've already ran over it
61         if (exists(mirrordir ~ info[0] ~ std.path.sep ~ "pkg.list")) {
62             // just take whatever data is there
63             pkgs ~= cast(char[]) std.file.read(mirrordir ~ info[0] ~ std.path.sep ~ "pkg.list");
64             continue;
65         }
66        
67         curpkg = "";
68        
69         // haven't done it yet, so do it
70         mkdir(mirrordir ~ info[0]);
71         chdir(mirrordir ~ info[0]);
72        
73         // retrieve source
74         getSources(info[0], nconf);
75        
76         // read config
77         void handleDir() {
78             DSSSConf conf = readConfig(null);
79             char[] vers = conf.settings[""]["version"];
80            
81             // then get the list of modules
82             foreach (section; conf.sections) {
83                 if (conf.settings[section]["type"] == "library" ||
84                     conf.settings[section]["type"] == "sourcelibrary") {
85                     char[][] files = targetToFiles(section, conf);
86                     foreach (file; files) {
87                         curpkg ~= file ~ " " ~ vers ~ " " ~ info[0] ~ "\n";
88                     }
89                    
90                 } else if (conf.settings[section]["type"] == "subdir") {
91                     char[] origcwd = getcwd();
92                     chdir(section);
93                     handleDir();
94                     chdir(origcwd);
95                    
96                 }
97             }
98         }
99        
100         handleDir();
101        
102         // and add the package itself
103         DSSSConf conf = readConfig(null);
104         char[] vers = conf.settings[""]["version"];
105        
106         curpkg ~= info[0] ~ " " ~ vers;
107         if ("requires" in conf.settings[""]) {
108             curpkg ~= " " ~ std.string.join(
109                 std.string.split(conf.settings[""]["requires"]),
110                 " ");
111         }
112         curpkg ~= "\n";
113        
114         // write out the package info
115         chdir(mirrordir ~ info[0]);
116         write("pkg.list", curpkg);
117         pkgs ~= curpkg;
118        
119         // remove garbage
120         system("rm -f src.*");
121         system("find . -name .svn | xargs rm -rf");
122        
123         // compress it
124         system("tar -cf - * | gzip -9 > ../" ~ info[0] ~ ".tar.gz");
125        
126         // cd back
127         chdir(srcListPrefix);
128     }
129    
130     write("pkgs.list", cast(char[]) pkgs);
131     return 0;
132 }
Note: See TracBrowser for help on using the browser.