comparison recipes/wince/libexpat.py @ 376:964e6981847a

Added for Windows CE
author Andre Heinecke <aheinecke@intevation.de>
date Mon, 21 Jun 2010 10:44:57 +0000
parents
children
comparison
equal deleted inserted replaced
375:6b09c0541502 376:964e6981847a
1 # Copyright (C) 2010 by Intevation GmbH
2 # Authors:
3 # Andre Heinecke <aheinecke@intevation.de>
4 #
5 # This program is free software under the GPL (>=v2)
6 # Read the file COPYING coming with the software for details.
7
8 """Recipe to build libexpat from Git"""
9
10 import os
11 import re
12 import inspect
13 import new
14
15 import treepkg.util
16 import treepkg.packager
17 import treepkg.run as run
18 from treepkg.cmdexpand import cmdexpand
19
20 class SourcePackager(treepkg.packager.SourcePackager):
21
22 """SourcePackager that uses pbuilder to create the source tarball"""
23
24 tarball_dependencies=set(["autoconf", "automake","git-core", "git"])
25 createtarball_script = """\
26 #! /bin/bash
27 set -e
28
29 apt-get --assume-yes --force-yes install %(builddeps)s
30
31 # copy the source tree to a directory that's under pbuilder control so
32 # that it gets removed along with the build environment. Otherwise we
33 # end up with a directory containing files that cannot be removed by
34 # treepkg
35 workdir=/tmp/work
36 cp -a %(basedir)s $workdir
37 cd $workdir
38
39 export MINGWPATH=/opt/mingw32ce
40 export INCLUDE=$MINGWPATH/arm-mingw32ce/include:$MINGWPATH/include:$INCLUDE
41 export LIB=$MINGWPATH/arm-mingw32ce/lib:$MINGWPATH/lib:$LIB
42 export PATH=:$PATH:$MINGWPATH/bin:$MINGWPATH/arm-mingw32ce/bin:\
43 $MINGWPATH/libexec/gcc/arm-mingw32ce/4.4.0:
44
45 autoreconf
46 ./configure --enable-maintainer-mode --host=arm-mingw32ce
47 %(make_dist_command)s
48
49 mv *.tar.gz %(origtargz)s
50 """
51
52 make_dist_command = "make dist"
53
54 def __init__(self, *args):
55 super(SourcePackager, self).__init__(*args)
56 self.pkgbasename = None
57 self.pkgbaseversion = None
58 self.origtargz = None
59
60 def orig_source_version(self, directory):
61 """Determines the version from expat.h directory"""
62 filename = os.path.join(directory, "conftools/get-version.sh")
63 expat_h = os.path.join(directory, "lib/expat.h")
64 output = run.capture_output(cmdexpand("$filename $expat_h",**locals()))
65 return output
66
67 def determine_package_version(self, directory):
68 """ Returns a Git package Name """
69 date = run.capture_output(cmdexpand("/bin/sh -c \" git log --date=iso \
70 -n 1 | grep Date \
71 | awk \'{print $$2}\'\""),
72 cwd=directory)
73 time = run.capture_output(cmdexpand("/bin/sh -c \" git log --date=iso \
74 -n 1 | grep Date \
75 | awk \'{print $$3}\'\""),
76 cwd=directory)
77 date = date.replace('-','')
78 time = time.replace(':','')
79 return "%s-%s%s.%s" % (self.orig_source_version(directory),
80 date[:8], time[:4], self.revision[:7])
81
82 def copy_workingcopy(self, dest):
83 treepkg.util.copytree(self.track.checkout_dir, dest)
84
85 def create_original_tarball(self):
86 copied_working_copy = os.path.join(self.work_dir, "copied_working_copy")
87 self.copy_workingcopy(copied_working_copy)
88
89 self.pkgbaseversion = \
90 self.determine_package_version(copied_working_copy)
91 self.pkgbasename = self.pkg_basename + "_" + self.pkgbaseversion
92 self.origtargz = os.path.join(self.work_dir,
93 self.pkgbasename + ".orig.tar.gz")
94
95 script = (self.createtarball_script
96 % dict(builddeps=" ".join(self.track.dependencies_required()
97 | self.tarball_dependencies),
98 basedir=copied_working_copy,
99 origtargz=self.origtargz,
100 make_dist_command=self.make_dist_command))
101 script_name = os.path.join(self.work_dir, "createtarball")
102 treepkg.util.writefile(script_name, script, 0755)
103
104 treepkg.util.ensure_directory(self.src_dir)
105 treepkg.util.ensure_directory(self.log_dir)
106 self.track.builder.run_script([script_name],
107 logfile=os.path.join(self.log_dir,
108 "tarball_log.txt"),
109 bindmounts=[self.work_dir, self.src_dir])
110
111 def create_orig_dir(self):
112 """Unpacks the tarball created by create_original_tarball into work_dir
113 """
114 unpack_dir = os.path.join(self.work_dir, "unpack")
115 treepkg.util.ensure_directory(unpack_dir)
116 run.call(cmdexpand("tar xzf $origtargz -C $unpack_dir",
117 unpack_dir=unpack_dir, origtargz=self.origtargz))
118 unpacked_files = treepkg.util.listdir_abs(unpack_dir)
119 if len(unpacked_files) != 1:
120 raise RuntimeError("%s should have extracted to a single directory",
121 origtargz)
122 unpacked_dir = unpacked_files[0]
123
124 orig_dir = os.path.join(self.work_dir, os.path.basename(unpacked_dir))
125 os.rename(unpacked_dir, orig_dir)
126 return orig_dir
127
128 def do_package(self):
129 self.create_original_tarball()
130 orig_dir = self.create_orig_dir()
131
132 changemsg = ("Update to change: %s" % self.revision)
133
134 self.copy_debian_directory(orig_dir, self.pkgbaseversion, changemsg)
135
136 self.create_source_package(orig_dir, self.origtargz)
137 self.move_source_package(self.pkgbasename)
138
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)