/[ascend]/trunk/tools/dtar/dspec
ViewVC logotype

Contents of /trunk/tools/dtar/dspec

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2041 - (show annotations) (download)
Sat Jun 13 08:06:10 2009 UTC (13 years, 11 months ago) by jpye
File size: 2664 byte(s)
Attempting to fixed rankine_regen model, not working.
This commit with model rankine.a4c demonstrates bug 399.
Added dspec, first attempt at single-file debian package script.
1 #!/usr/bin/env python
2 # dspec - Convert RPM-ish .dspec files into dpkg input files
3 # Copyright (C) 2008 John Pye <john@curioussymbols.com>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2, or (at your option)
8 # any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place - Suite 330,
18 # Boston, MA 02111-1307, USA.
19
20
21 import sys, re, tarfile, os.path, subprocess, shutil, getopt, glob
22 import apt
23 from debian_bundle import deb822, changelog
24
25 def usage():
26 print """%s: Convert RPM-ish .dspec files into dpkg input files
27 """
28
29 opts,args = getopt.getopt(sys.argv[1:],"nhs",["help","source","nooverwrite"])
30
31 # do we just want a source package?
32 buildsource = False
33 overwrite = True
34
35
36 for _o,_a in opts:
37 if _o in ['-h','--help']:
38 usage()
39 sys.exit()
40 elif _o in ['-s','--source']:
41 buildsource = True
42 elif _o in ['-n','--nooverwrite']:
43 overwrite = False
44 else:
45 assert False,"unhandled option"
46
47 if len(args)<1 or len(args)>1:
48 raise RuntimeError("One filename must be supplied")
49
50 # the tarball is the argument to this script
51
52 startingcwd = os.getcwd()
53
54 fn = args[0]
55
56 ffull = os.path.abspath(fn)
57
58 f = file(ffull).readlines()
59
60 # strip comments
61 fs = []
62 for l in f:
63 ls = l.lstrip()
64 if len(ls) and ls[0] == "#":
65 continue
66 fs.append(l)
67
68 # divide sections
69
70 possiblesections = ["control","changelog","rules"]
71 currentsection = "control"
72 sections = {"control":[]}
73
74 for l in fs:
75 if len(l) and l[0] == "%":
76 section = l[1:].strip()
77 if section in possiblesections:
78 currentsection = section
79 if currentsection not in sections.keys():
80 sections[currentsection] = []
81 continue
82 print "%s: %s" % (currentsection,l.rstrip())
83 sections[currentsection].append(l)
84
85 # create location for temporary files
86
87 maindir = "/tmp/dtar-%s" % os.getpid()
88
89 if os.path.exists(maindir):
90 raise RuntimeError("Temp path '%s' already exists!"%maindir)
91
92 os.mkdir(maindir)
93
94 # create debian.tar
95
96 debtarname = os.path.join(maindir,"debian.tar")
97 t = tarfile.open(name = debtarname,mode="w")
98
99 for s in possiblesections:
100 os.chdir(maindir)
101 file(s,"w").writelines(sections[s])
102 t.add(s,arcname=os.path.join("debian",s))
103
104 t.close()
105
106 sys.stdout.write(file(debtarname).read())

Properties

Name Value
svn:executable *

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22