##// END OF EJS Templates
osx: new script for generating OS X package versions...
Augie Fackler -
r33595:283a7da6 stable
parent child Browse files
Show More
@@ -0,0 +1,130 b''
1 #!/usr/bin/env python2
2 from __future__ import absolute_import, print_function
3
4 import argparse
5 import json
6 import os
7 import subprocess
8 import sys
9
10 # Always load hg libraries from the hg we can find on $PATH.
11 hglib = json.loads(subprocess.check_output(
12 ['hg', 'debuginstall', '-Tjson']))[0]['hgmodules']
13 sys.path.insert(0, os.path.dirname(hglib))
14
15 from mercurial import util
16
17 ap = argparse.ArgumentParser()
18 ap.add_argument('--paranoid',
19 action='store_true',
20 help=("Be paranoid about how version numbers compare and "
21 "produce something that's more likely to sort "
22 "reasonably."))
23 ap.add_argument('--selftest', action='store_true', help='Run self-tests.')
24 ap.add_argument('versionfile', help='Path to a valid mercurial __version__.py')
25
26 def paranoidver(ver):
27 """Given an hg version produce something that distutils can sort.
28
29 Some Mac package management systems use distutils code in order to
30 figure out upgrades, which makes life difficult. The test case is
31 a reduced version of code in the Munki tool used by some large
32 organizations to centrally manage OS X packages, which is what
33 inspired this kludge.
34
35 >>> paranoidver('3.4')
36 '3.4.0'
37 >>> paranoidver('3.4.2')
38 '3.4.2'
39 >>> paranoidver('3.0-rc+10')
40 '2.9.9999-rc+10'
41 >>> paranoidver('4.2+483-5d44d7d4076e')
42 '4.2.0+483-5d44d7d4076e'
43 >>> paranoidver('4.2.1+598-48d1e1214d8c')
44 '4.2.1+598-48d1e1214d8c'
45 >>> paranoidver('4.3-rc')
46 '4.2.9999-rc'
47 >>> paranoidver('4.3')
48 '4.3.0'
49 >>> from distutils import version
50 >>> class LossyPaddedVersion(version.LooseVersion):
51 ... '''Subclass version.LooseVersion to compare things like
52 ... "10.6" and "10.6.0" as equal'''
53 ... def __init__(self, s):
54 ... self.parse(s)
55 ...
56 ... def _pad(self, version_list, max_length):
57 ... 'Pad a version list by adding extra 0 components to the end'
58 ... # copy the version_list so we don't modify it
59 ... cmp_list = list(version_list)
60 ... while len(cmp_list) < max_length:
61 ... cmp_list.append(0)
62 ... return cmp_list
63 ...
64 ... def __cmp__(self, other):
65 ... if isinstance(other, str):
66 ... other = MunkiLooseVersion(other)
67 ... max_length = max(len(self.version), len(other.version))
68 ... self_cmp_version = self._pad(self.version, max_length)
69 ... other_cmp_version = self._pad(other.version, max_length)
70 ... return cmp(self_cmp_version, other_cmp_version)
71 >>> def testver(older, newer):
72 ... o = LossyPaddedVersion(paranoidver(older))
73 ... n = LossyPaddedVersion(paranoidver(newer))
74 ... return o < n
75 >>> testver('3.4', '3.5')
76 True
77 >>> testver('3.4.0', '3.5-rc')
78 True
79 >>> testver('3.4-rc', '3.5')
80 True
81 >>> testver('3.4-rc+10-deadbeef', '3.5')
82 True
83 >>> testver('3.4.2', '3.5-rc')
84 True
85 >>> testver('3.4.2', '3.5-rc+10-deadbeef')
86 True
87 >>> testver('4.2+483-5d44d7d4076e', '4.2.1+598-48d1e1214d8c')
88 True
89 >>> testver('4.3-rc', '4.3')
90 True
91 >>> testver('4.3', '4.3-rc')
92 False
93 """
94 major, minor, micro, extra = util.versiontuple(ver, n=4)
95 if micro is None:
96 micro = 0
97 if extra:
98 if extra.startswith('rc'):
99 if minor == 0:
100 major -= 1
101 minor = 9
102 else:
103 minor -= 1
104 micro = 9999
105 extra = '-' + extra
106 else:
107 extra = '+' + extra
108 else:
109 extra = ''
110 return '%d.%d.%d%s' % (major, minor, micro, extra)
111
112 def main(argv):
113 opts = ap.parse_args(argv[1:])
114 if opts.selftest:
115 import doctest
116 doctest.testmod()
117 return
118 with open(opts.versionfile) as f:
119 for l in f:
120 if l.startswith('version = '):
121 # version number is entire line minus the quotes
122 ver = l[len('version = ') + 1:-2]
123 break
124 if opts.paranoid:
125 print(paranoidver(ver))
126 else:
127 print(ver)
128
129 if __name__ == '__main__':
130 main(sys.argv)
@@ -1,70 +1,71 b''
1 #require test-repo slow osx osxpackaging
1 #require test-repo slow osx osxpackaging
2
2
3 $ . "$TESTDIR/helpers-testrepo.sh"
3 $ . "$TESTDIR/helpers-testrepo.sh"
4 $ testrepohgenv
4 $ testrepohgenv
5
5
6 $ OUTPUTDIR="`pwd`"
6 $ OUTPUTDIR="`pwd`"
7 $ export OUTPUTDIR
7 $ export OUTPUTDIR
8 $ KEEPMPKG=yes
8 $ KEEPMPKG=yes
9 $ export KEEPMPKG
9 $ export KEEPMPKG
10
10
11 $ cd "$TESTDIR"/..
11 $ cd "$TESTDIR"/..
12 $ contrib/genosxversion.py --selftest ignoredarg
12 $ make osx > "$OUTPUTDIR/build.log" 2>&1
13 $ make osx > "$OUTPUTDIR/build.log" 2>&1
13 $ cd "$OUTPUTDIR"
14 $ cd "$OUTPUTDIR"
14 $ ls -d *.pkg
15 $ ls -d *.pkg
15 Mercurial-*-macosx10.*.pkg (glob)
16 Mercurial-*-macosx10.*.pkg (glob)
16
17
17 $ xar -xf Mercurial*.pkg
18 $ xar -xf Mercurial*.pkg
18
19
19 Gather list of all installed files:
20 Gather list of all installed files:
20 $ lsbom mercurial.pkg/Bom > boms.txt
21 $ lsbom mercurial.pkg/Bom > boms.txt
21
22
22 We've had problems with the filter logic in the past. Make sure no
23 We've had problems with the filter logic in the past. Make sure no
23 .DS_Store files ended up in the final package:
24 .DS_Store files ended up in the final package:
24 $ grep DS_S boms.txt
25 $ grep DS_S boms.txt
25 [1]
26 [1]
26
27
27 Spot-check some randomly selected files:
28 Spot-check some randomly selected files:
28 $ grep bdiff boms.txt | cut -d ' ' -f 1,2,3
29 $ grep bdiff boms.txt | cut -d ' ' -f 1,2,3
29 ./Library/Python/2.7/site-packages/mercurial/cext/bdiff.so 100755 0/0
30 ./Library/Python/2.7/site-packages/mercurial/cext/bdiff.so 100755 0/0
30 ./Library/Python/2.7/site-packages/mercurial/cffi/bdiff.py 100644 0/0
31 ./Library/Python/2.7/site-packages/mercurial/cffi/bdiff.py 100644 0/0
31 ./Library/Python/2.7/site-packages/mercurial/cffi/bdiff.pyc 100644 0/0
32 ./Library/Python/2.7/site-packages/mercurial/cffi/bdiff.pyc 100644 0/0
32 ./Library/Python/2.7/site-packages/mercurial/cffi/bdiff.pyo 100644 0/0
33 ./Library/Python/2.7/site-packages/mercurial/cffi/bdiff.pyo 100644 0/0
33 ./Library/Python/2.7/site-packages/mercurial/cffi/bdiffbuild.py 100644 0/0
34 ./Library/Python/2.7/site-packages/mercurial/cffi/bdiffbuild.py 100644 0/0
34 ./Library/Python/2.7/site-packages/mercurial/cffi/bdiffbuild.pyc 100644 0/0
35 ./Library/Python/2.7/site-packages/mercurial/cffi/bdiffbuild.pyc 100644 0/0
35 ./Library/Python/2.7/site-packages/mercurial/cffi/bdiffbuild.pyo 100644 0/0
36 ./Library/Python/2.7/site-packages/mercurial/cffi/bdiffbuild.pyo 100644 0/0
36 ./Library/Python/2.7/site-packages/mercurial/pure/bdiff.py 100644 0/0
37 ./Library/Python/2.7/site-packages/mercurial/pure/bdiff.py 100644 0/0
37 ./Library/Python/2.7/site-packages/mercurial/pure/bdiff.pyc 100644 0/0
38 ./Library/Python/2.7/site-packages/mercurial/pure/bdiff.pyc 100644 0/0
38 ./Library/Python/2.7/site-packages/mercurial/pure/bdiff.pyo 100644 0/0
39 ./Library/Python/2.7/site-packages/mercurial/pure/bdiff.pyo 100644 0/0
39 $ grep zsh/site-functions/_hg boms.txt | cut -d ' ' -f 1,2,3
40 $ grep zsh/site-functions/_hg boms.txt | cut -d ' ' -f 1,2,3
40 ./usr/local/share/zsh/site-functions/_hg 100644 0/0
41 ./usr/local/share/zsh/site-functions/_hg 100644 0/0
41 $ grep hg-completion.bash boms.txt | cut -d ' ' -f 1,2,3
42 $ grep hg-completion.bash boms.txt | cut -d ' ' -f 1,2,3
42 ./usr/local/hg/contrib/hg-completion.bash 100644 0/0
43 ./usr/local/hg/contrib/hg-completion.bash 100644 0/0
43 $ egrep 'man[15]' boms.txt | cut -d ' ' -f 1,2,3
44 $ egrep 'man[15]' boms.txt | cut -d ' ' -f 1,2,3
44 ./usr/local/share/man/man1 40755 0/0
45 ./usr/local/share/man/man1 40755 0/0
45 ./usr/local/share/man/man1/chg.1 100644 0/0
46 ./usr/local/share/man/man1/chg.1 100644 0/0
46 ./usr/local/share/man/man1/hg.1 100644 0/0
47 ./usr/local/share/man/man1/hg.1 100644 0/0
47 ./usr/local/share/man/man5 40755 0/0
48 ./usr/local/share/man/man5 40755 0/0
48 ./usr/local/share/man/man5/hgignore.5 100644 0/0
49 ./usr/local/share/man/man5/hgignore.5 100644 0/0
49 ./usr/local/share/man/man5/hgrc.5 100644 0/0
50 ./usr/local/share/man/man5/hgrc.5 100644 0/0
50 $ grep bser boms.txt | cut -d ' ' -f 1,2,3
51 $ grep bser boms.txt | cut -d ' ' -f 1,2,3
51 ./Library/Python/2.7/site-packages/hgext/fsmonitor/pywatchman/bser.so 100755 0/0
52 ./Library/Python/2.7/site-packages/hgext/fsmonitor/pywatchman/bser.so 100755 0/0
52 ./Library/Python/2.7/site-packages/hgext/fsmonitor/pywatchman/pybser.py 100644 0/0
53 ./Library/Python/2.7/site-packages/hgext/fsmonitor/pywatchman/pybser.py 100644 0/0
53 ./Library/Python/2.7/site-packages/hgext/fsmonitor/pywatchman/pybser.pyc 100644 0/0
54 ./Library/Python/2.7/site-packages/hgext/fsmonitor/pywatchman/pybser.pyc 100644 0/0
54 ./Library/Python/2.7/site-packages/hgext/fsmonitor/pywatchman/pybser.pyo 100644 0/0
55 ./Library/Python/2.7/site-packages/hgext/fsmonitor/pywatchman/pybser.pyo 100644 0/0
55 $ grep localrepo boms.txt | cut -d ' ' -f 1,2,3
56 $ grep localrepo boms.txt | cut -d ' ' -f 1,2,3
56 ./Library/Python/2.7/site-packages/mercurial/localrepo.py 100644 0/0
57 ./Library/Python/2.7/site-packages/mercurial/localrepo.py 100644 0/0
57 ./Library/Python/2.7/site-packages/mercurial/localrepo.pyc 100644 0/0
58 ./Library/Python/2.7/site-packages/mercurial/localrepo.pyc 100644 0/0
58 ./Library/Python/2.7/site-packages/mercurial/localrepo.pyo 100644 0/0
59 ./Library/Python/2.7/site-packages/mercurial/localrepo.pyo 100644 0/0
59 $ egrep 'bin/' boms.txt | cut -d ' ' -f 1,2,3
60 $ egrep 'bin/' boms.txt | cut -d ' ' -f 1,2,3
60 ./usr/local/bin/chg 100755 0/0
61 ./usr/local/bin/chg 100755 0/0
61 ./usr/local/bin/hg 100755 0/0
62 ./usr/local/bin/hg 100755 0/0
62
63
63 Make sure the built binary uses the system Python interpreter
64 Make sure the built binary uses the system Python interpreter
64 $ bsdtar xf mercurial.pkg/Payload usr/local/bin
65 $ bsdtar xf mercurial.pkg/Payload usr/local/bin
65 Use a glob to find this to avoid check-code whining about a fixed path.
66 Use a glob to find this to avoid check-code whining about a fixed path.
66 $ head -n 1 usr/local/b?n/hg
67 $ head -n 1 usr/local/b?n/hg
67 #!/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
68 #!/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
68
69
69 Note that we're not currently installing any /etc/mercurial stuff,
70 Note that we're not currently installing any /etc/mercurial stuff,
70 including merge-tool configurations.
71 including merge-tool configurations.
General Comments 0
You need to be logged in to leave comments. Login now