comparison recipes/gnupg/base.py @ 555:3105488b3eab

Include Andres changes to build gnupg from git with testing for scratchbox
author Bjoern Ricks <bricks@intevation.de>
date Tue, 31 May 2011 09:25:51 +0000
parents 3a83cb3c6504
children
comparison
equal deleted inserted replaced
554:3a83cb3c6504 555:3105488b3eab
9 9
10 import os 10 import os
11 import re 11 import re
12 import inspect 12 import inspect
13 import new 13 import new
14 import shutil
14 15
15 import treepkg.util 16 import treepkg.util
16 import treepkg.packager 17 import treepkg.packager
17 import treepkg.run as run 18 import treepkg.run as run
18 from treepkg.cmdexpand import cmdexpand 19 from treepkg.cmdexpand import cmdexpand
41 return match.group(1) 42 return match.group(1)
42 43
43 raise RuntimeError("Could not determine the version number from %s" 44 raise RuntimeError("Could not determine the version number from %s"
44 % filename) 45 % filename)
45 46
46 def determine_package_version(self, directory): 47 def determine_upstream_version(self, directory=None):
47 return "%s+svn%s" % (self.orig_source_version(directory), self.revision) 48 return self.orig_source_version(directory)
48 49
49 def do_package(self): 50 def do_package(self):
50 pkgbaseversion, pkgbasedir = self.export_sources() 51 pkgbaseversion, pkgbasedir = self.export_sources()
51 52
52 run.call(cmdexpand("/bin/sh autogen.sh"), cwd=pkgbasedir, 53 run.call(cmdexpand("/bin/sh autogen.sh"), cwd=pkgbasedir,
55 56
56 # patch the version number in the newly generated configure 57 # patch the version number in the newly generated configure
57 # file. autogen.sh normally determines it from svn, but here it 58 # file. autogen.sh normally determines it from svn, but here it
58 # ran on a copy that did not include the .svn subdirectories and 59 # ran on a copy that did not include the .svn subdirectories and
59 # thus could not find the svn revision. 60 # thus could not find the svn revision.
60 treepkg.util.replace_in_file(os.path.join(pkgbasedir, "configure"), 61 #treepkg.util.replace_in_file(os.path.join(pkgbasedir, "configure"),
61 re.escape(orig_version) + "-svn0", 62 # re.escape(orig_version) + "-git0",
62 orig_version + "-svn%s" % self.revision) 63 # orig_version + "-git%s" % self.revision)
63 64
64 pkgbasename = self.pkg_basename + "_" + pkgbaseversion 65 pkgbasename = self.pkg_basename + "_" + pkgbaseversion
65 origtargz = os.path.join(self.work_dir, 66 origtargz = os.path.join(self.work_dir,
66 pkgbasename + ".orig.tar.gz") 67 pkgbasename + ".orig.tar.gz")
67 self.create_tarball(origtargz, self.work_dir, 68 self.create_tarball(origtargz, self.work_dir,
68 os.path.basename(pkgbasedir)) 69 os.path.basename(pkgbasedir))
69 70
70 changemsg = ("Update to rev. %s" % (self.revision,)) 71 changemsg = ("Update to git rev. %s" % (self.revision,))
71 self.copy_debian_directory(pkgbasedir, pkgbaseversion, 72 self.copy_debian_directory(pkgbasedir, pkgbaseversion,
72 changemsg) 73 changemsg)
73 74
74 self.create_source_package(pkgbasedir, origtargz) 75 self.create_source_package(pkgbasedir, origtargz)
75 self.move_source_package(pkgbasename) 76 self.move_source_package(pkgbasename)
90 a script. 91 a script.
91 """ 92 """
92 93
93 createtarball_script = """\ 94 createtarball_script = """\
94 #! /bin/bash 95 #! /bin/bash
95 set -e 96 set -e
96 97
97 apt-get --assume-yes --force-yes install %(builddeps)s 98 # Check if we are in a scratchbox
98 99 if [ -n "${SBOX_UNAME_MACHINE+x}" ]; then
100 fakeroot apt-get --assume-yes --force-yes install %(builddeps)s
101 else
102 apt-get --assume-yes --force-yes install %(builddeps)s
103 fi
104 export AUTOMAKE_SUFFIX=-1.10
99 # copy the source tree to a directory that's under pbuilder control so 105 # copy the source tree to a directory that's under pbuilder control so
100 # that it gets removed along with the build environment. Otherwise we 106 # that it gets removed along with the build environment. Otherwise we
101 # end up with a directory containing files that cannot be removed by 107 # end up with a directory containing files that cannot be removed by
102 # treepkg 108 # treepkg
103 workdir=/tmp/work 109 workdir=/tmp/treepkg_gpg_work
104 cp -a %(basedir)s $workdir 110 cp -a %(basedir)s $workdir
105 cd $workdir 111 cd $workdir
106 112
107 # tweak autoconf settings so that make dist produces a tar.gz, not a 113 # tweak autoconf settings so that make dist produces a tar.gz, not a
108 # tar.bz2. Removing all options whose names contain 'dist' should 114 # tar.bz2. Removing all options whose names contain 'dist' should
109 # achieve that. 115 # achieve that.
110 cp Makefile.am Makefile.am.orig 116 cp Makefile.am Makefile.am.orig
111 sed -e '/AUTOMAKE_OPTIONS/ s/[a-zA-Z0-9-]*dist[a-zA-Z0-9-]*//g' \ 117 sed -e '/AUTOMAKE_OPTIONS/ s/[a-zA-Z0-9-]*dist[a-zA-Z0-9-]*//g' \
112 Makefile.am.orig > Makefile.am 118 Makefile.am.orig > Makefile.am
113 119
120 # Run Autogen
114 ./autogen.sh 121 ./autogen.sh
122
123 # Tweak configure to contain svn revision numbers
124 cp configure configure.orig
125 sed -e "s/-svn0/-svn%(svn_revision)s/g" configure.orig > configure
126
127 echo ./configure --enable-maintainer-mode $add_cfg_opts
115 ./configure --enable-maintainer-mode 128 ./configure --enable-maintainer-mode
116 129
117 # revert autoconf changes, so that the original Makefile.am ends up in 130 # revert autoconf changes, so that the original Makefile.am ends up in
118 # the tarball 131 # the tarball
119 mv Makefile.am.orig Makefile.am 132 mv Makefile.am.orig Makefile.am
133
134 # Evil hack for a fig2dev bug in scratchbox
135 fakefigs="gnupg-card-architecture libgcrypt-modules fips-fsm"
136
137 if [ -n "${SBOX_UNAME_MACHINE+x}" ]; then
138 for i in $fakefigs; do
139 if [ -f doc/$i.fig ]; then
140 touch doc/$i.eps
141 touch doc/$i.png
142 touch doc/$i.pdf
143 fi
144 done
145 fi
120 146
121 %(make_dist_command)s 147 %(make_dist_command)s
122 148
123 mv *.tar.gz %(origtargz)s 149 mv *.tar.gz %(origtargz)s
124 """ 150 """
145 self.pkgbaseversion = \ 171 self.pkgbaseversion = \
146 self.determine_package_version(copied_working_copy) 172 self.determine_package_version(copied_working_copy)
147 self.pkgbasename = self.pkg_basename + "_" + self.pkgbaseversion 173 self.pkgbasename = self.pkg_basename + "_" + self.pkgbaseversion
148 self.origtargz = os.path.join(self.work_dir, 174 self.origtargz = os.path.join(self.work_dir,
149 self.pkgbasename + ".orig.tar.gz") 175 self.pkgbasename + ".orig.tar.gz")
150
151 script = (self.createtarball_script 176 script = (self.createtarball_script
152 % dict(builddeps=" ".join(self.track.dependencies_required() 177 % dict(builddeps=" ".join(self.track.dependencies_required()
153 | self.tarball_dependencies), 178 | self.tarball_dependencies),
154 basedir=copied_working_copy, 179 basedir=copied_working_copy,
155 origtargz=self.origtargz, 180 origtargz=self.origtargz,
181 svn_revision=self.revision,
156 make_dist_command=self.make_dist_command)) 182 make_dist_command=self.make_dist_command))
157 script_name = os.path.join(self.work_dir, "createtarball") 183 script_name = os.path.join(self.work_dir, "createtarball")
158 treepkg.util.writefile(script_name, script, 0755) 184 treepkg.util.writefile(script_name, script, 0755)
159 185
160 treepkg.util.ensure_directory(self.src_dir) 186 treepkg.util.ensure_directory(self.src_dir)
161 treepkg.util.ensure_directory(self.log_dir) 187 treepkg.util.ensure_directory(self.log_dir)
162 self.builder.run_script([script_name], 188 try:
163 logfile=os.path.join(self.log_dir, 189 self.builder.run_script([script_name],
164 "tarball_log.txt"), 190 logfile=os.path.join(self.log_dir,
165 bindmounts=[self.work_dir, self.src_dir]) 191 "tarball_log.txt"),
192 bindmounts=[self.work_dir, self.src_dir])
193 finally:
194 shutil.rmtree("/tmp/treepkg_gpg_work", ignore_errors=True)
166 195
167 def create_orig_dir(self): 196 def create_orig_dir(self):
168 """Unpacks the tarball created by create_original_tarball into work_dir 197 """Unpacks the tarball created by create_original_tarball into work_dir
169 """ 198 """
170 unpack_dir = os.path.join(self.work_dir, "unpack") 199 unpack_dir = os.path.join(self.work_dir, "unpack")
183 212
184 def do_package(self): 213 def do_package(self):
185 self.create_original_tarball() 214 self.create_original_tarball()
186 orig_dir = self.create_orig_dir() 215 orig_dir = self.create_orig_dir()
187 216
188 changemsg = ("Update to rev. %s" % (self.revision,)) 217 changemsg = ("Update to git rev. %s" % (self.revision,))
189 self.copy_debian_directory(orig_dir, self.pkgbaseversion, changemsg) 218 self.copy_debian_directory(orig_dir, self.pkgbaseversion, changemsg)
190 219
191 self.create_source_package(orig_dir, self.origtargz) 220 self.create_source_package(orig_dir, self.origtargz)
192 self.move_source_package(self.pkgbasename) 221 self.move_source_package(self.pkgbasename)
193 222
194 223
195 def define_gnupg_packager(pkg_basename, 224 def define_gnupg_packager(pkg_basename,
196 tarball_dependencies=("autoconf", "automake", 225 tarball_dependencies=("autoconf", "automake",
197 "texinfo", "subversion"), 226 "texinfo"),
198 make_dist_command=None): 227 make_dist_command=None):
199 """Create a SourcePackager for a GnuPG package in the caller's globals(). 228 """Create a SourcePackager for a GnuPG package in the caller's globals().
200 This is a helper function for the modules in the recipe.gnupg package. 229 This is a helper function for the modules in the recipe.gnupg package.
201 """ 230 """
202 base_class = BaseSourcePackager 231 base_class = BaseSourcePackager
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)