Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 110 lines (84 sloc) 2.664 kB
ec989f5 @coolwanglu add file for debian/ubuntu packaging
authored
1 #!/usr/bin/env python
2
3 """
4 Dirty script for building package for PPA
5 by WangLu
6 2011.01.13
7
8 modified by pdf2htmlEX
9 2012.08.28
10 """
11
12
13 import os
14 import sys
15 import re
16 import time
17
18 print 'Generating version...'
19
20 try:
21 rev = open('.git/refs/heads/devv').read()[:5]
22 except:
23 print 'Cannot get revision number'
24 sys.exit(-1)
25
c53d7de @coolwanglu add config.h.in
authored
26 today_timestr = time.strftime('%Y%m%d%H%M')
ec989f5 @coolwanglu add file for debian/ubuntu packaging
authored
27 package='pdf2htmlex'
28 projectname='pdf2htmlEX'
29 try:
30 version = re.findall(r'set\(PDF2HTMLEX_VERSION\s*"([^"]*)"\)', open('CMakeLists.txt').read())[0]
31 except:
32 print 'Cannot get package name and version number'
33 sys.exit(-1)
34
c53d7de @coolwanglu add config.h.in
authored
35 deb_version = version+'-3~git'+today_timestr+'r'+rev
ec989f5 @coolwanglu add file for debian/ubuntu packaging
authored
36 full_deb_version = deb_version+'-0ubuntu1'
37
38 #check if we need to update debian/changelog
39 if re.findall(r'\(([^)]+)\)', open('debian/changelog').readline())[0] == full_deb_version:
40 print
41 print 'No need to update debian/changelog, skipping'
42 else:
43 print
44 print 'Writing debian/changelog'
45 if os.system('dch -v "%s"' % (full_deb_version,)) != 0:
46 print 'Failed when updating debian/changelog'
47 sys.exit(-1)
48
49 print
50 print 'Building...'
51 # handling files
b391c62 @coolwanglu fixed debian install file
authored
52 if os.system('(rm CMakeCache.txt || true) && cmake . && make dist') != 0:
ec989f5 @coolwanglu add file for debian/ubuntu packaging
authored
53 print 'Failed in creating tarball'
54 sys.exit(-1)
55
56 orig_tar_filename = package+'-'+version+'.tar.bz2'
57 if os.system('test -e %s && cp %s ../build-area' % (orig_tar_filename, orig_tar_filename)) != 0:
58 print 'Cannot copy tarball file to build area'
59 sys.exit(-1)
60
61 deb_orig_tar_filename = package+'_'+deb_version+'.orig.tar.bz2'
62
63 try:
64 os.chdir('../build-area')
65 except:
66 print 'Cannot find ../build-area'
67 sys.exit(-1)
68
69 # remove old dir
70 os.system('rm -rf %s' % (package+'-'+version,))
71
72 if os.system('mv %s %s && tar -xvf %s' % (orig_tar_filename, deb_orig_tar_filename, deb_orig_tar_filename)) != 0:
73 print 'Cannot extract tarball'
74 sys.exit(-1)
75
76 try:
77 os.chdir(package+'-'+version)
78 except:
79 print 'Cannot enter project dir'
80 sys.exit(-1)
81
82 os.system('cp -r ../../%s/debian .' % (projectname,))
83
84 # building
85 if os.system('debuild -S -sa') != 0:
86 print 'Failed in debuild'
87 sys.exit(-1)
88
89 print
90 sys.stdout.write('Everything seems to be good so far, upload?(y/n)')
91 sys.stdout.flush()
92 ans = raw_input().lower()
93 while ans not in ['y', 'n']:
94 sys.stdout.write('I don\'t understand, enter \'y\' or \'n\':')
95 ans = raw_input().lower()
96
97 if ans == 'n':
98 print 'Skipped.'
99 sys.exit(0)
100
101 if os.system('dput ppa:coolwanglu/%s ../%s' % (package, package+'_'+full_deb_version+'_source.changes')) != 0:
102 print 'Failed in uploading by dput'
103 sys.exit(-1)
104
105 print 'Build area not cleaned.'
106 print 'All done. Cool!'
107
108
109
Something went wrong with that request. Please try again.