7 pkgdestdir = "${WORKDIR}/install"
9 manifest = sys.__stdin__
10 if len(sys.argv) == 2:
11 manifest = file(sys.argv[1], "r")
13 def mangle_path_stage(field, fields):
18 if os.path.isabs(path):
20 if path.startswith('/'):
22 path = os.path.join(srcdir, path)
24 if os.path.isabs(path):
26 if path.startswith('/'):
28 path = os.path.join(destdir, path)
29 libpath = os.path.join(destdir, '${libdir}')
30 incpath = os.path.join(destdir, '${includedir}')
31 if path.startswith(libpath):
32 path = "${STAGING_LIBDIR}" + path[len(libpath):]
33 elif path.startswith(incpath):
34 path = "${STAGING_INCDIR}" + path[len(incpath):]
39 def mangle_path_install(field, fields):
44 if os.path.isabs(path):
46 if path.startswith('/'):
48 path = os.path.join(srcdir, path)
50 if os.path.isabs(path):
52 if path.startswith('/'):
54 path = os.path.join(destdir, path)
57 def mangle_path_populate(field, fields):
60 if None in (pkg, path):
63 if os.path.isabs(path):
65 if path.startswith('/'):
67 path = os.path.join(srcdir, path)
69 if os.path.isabs(path):
71 if path.startswith('/'):
73 path = os.path.join(pkgdestdir, pkg, path)
78 fieldmap = ( "pkg", "src", "dest", "type", "mode", "uid", "gid", "major", "minor", "start", "inc", "count" )
79 for f in xrange(len(fieldmap)):
80 fields[fieldmap[f]] = None
85 splitline = line.split()
86 if not len(splitline):
90 for f in xrange(len(fieldmap)):
91 if splitline[f] == '-':
93 fields[fieldmap[f]] = splitline[f]
98 def handle_directory(fields, commands, mangle_path):
102 if os.path.isabs(dest):
104 if dest.startswith('/'):
107 dest = mangle_path("dest", fields)
110 cmd += os.path.dirname(dest)
111 if not cmd in commands:
114 def handle_file(fields, commands, mangle_path):
115 if None in (fields["src"], fields["dest"]):
118 handle_directory(fields, commands, mangle_path)
119 src = mangle_path("src", fields)
122 dest = mangle_path("dest", fields)
125 mode = fields["mode"]
129 cmd += "-m " + mode + " "
130 cmd += src + " " + dest
131 if not cmd in commands:
134 def handle_symbolic_link(fields, commands, mangle_path):
135 if None in (fields["src"], fields["dest"]):
138 handle_directory(fields, commands, mangle_path)
139 dest = mangle_path("dest", fields)
141 if None in (src, dest):
144 cmd = "ln -sf " + src + " " + dest
145 if not cmd in commands:
148 def handle_hard_link(fields, commands, mangle_path):
149 if None in (fields["src"], fields["dest"]):
152 handle_directory(fields, commands, mangle_path)
153 src = mangle_path("src", fields)
154 dest = mangle_path("dest", fields)
155 if None in (src, dest):
158 cmd = "ln -f " + src + " " + dest
159 if not cmd in commands:
163 commands_populate = list()
164 commands_stage = list()
167 line = manifest.readline()
170 if line.startswith("#"):
173 fields = getfields(line)
177 if not fields in entries:
178 entries.append(fields)
180 if fields["type"] == "d":
181 handle_directory(fields, commands, mangle_path_install)
182 if fields["type"] == "f":
183 handle_file(fields, commands, mangle_path_install)
184 if fields["type"] == "s":
185 handle_symbolic_link(fields, commands, mangle_path_install)
186 if fields["type"] == "h":
187 handle_hard_link(fields, commands, mangle_path_install)
189 if fields["type"] == "d":
190 handle_directory(fields, commands_populate, mangle_path_populate)
191 if fields["type"] == "f":
192 handle_file(fields, commands_populate, mangle_path_populate)
193 if fields["type"] == "s":
194 handle_symbolic_link(fields, commands_populate, mangle_path_populate)
195 if fields["type"] == "h":
196 handle_hard_link(fields, commands_populate, mangle_path_populate)
198 if fields["type"] == "d":
199 handle_directory(fields, commands_stage, mangle_path_stage)
200 if fields["type"] == "f":
201 handle_file(fields, commands_stage, mangle_path_stage)
202 if fields["type"] == "s":
203 handle_symbolic_link(fields, commands_stage, mangle_path_stage)
205 print "do_stage () {"
206 print '\t' + string.join(commands_stage, '\n\t')
208 print "do_install () {"
209 print '\t' + string.join(commands, '\n\t')
211 print "do_populate () {"
212 print '\t' + string.join(commands_populate, '\n\t')