1
1
"""
2
2
Code for building Origin
3
3
"""
4
-
5
- import sys
6
4
import json
7
5
8
- from tito .common import (
9
- get_latest_commit ,
10
- get_latest_tagged_version ,
11
- check_tag_exists ,
12
- run_command ,
13
- find_spec_file ,
14
- get_spec_version_and_release ,
15
- munge_specfile
16
- )
17
-
6
+ from tito .common import get_latest_commit , run_command
18
7
from tito .builder import Builder
19
8
9
+ from ..common import inject_os_git_vars
10
+
20
11
class OriginBuilder (Builder ):
21
12
"""
22
13
builder which defines 'commit' as the git hash prior to building
23
14
24
15
Used For:
25
16
- Packages that want to know the commit in all situations
26
17
"""
18
+ def _get_tag_for_version (self , version ):
19
+ return "v{}" .format (version )
27
20
28
21
def _get_rpmbuild_dir_options (self ):
29
22
git_hash = get_latest_commit ()
30
- cmd = '. ./hack/common .sh ; OS_ROOT=$(pwd) ; echo $( os::build::ldflags) '
23
+ cmd = 'source ./hack/lib/init .sh; os::build::ldflags'
31
24
ldflags = run_command ("bash -c '{0}'" .format (cmd ))
32
25
33
26
return ('--define "_topdir %s" --define "_sourcedir %s" --define "_builddir %s" '
@@ -40,46 +33,12 @@ def _get_rpmbuild_dir_options(self):
40
33
41
34
def _setup_test_specfile (self ):
42
35
if self .test and not self .ran_setup_test_specfile :
43
- # If making a test rpm we need to get a little crazy with the spec
44
- # file we're building off. (note that this is a temp copy of the
45
- # spec) Swap out the actual release for one that includes the git
46
- # SHA1 we're building for our test package:
47
- sha = self .git_commit_id [:7 ]
48
- fullname = "{0}-{1}" .format (self .project_name , self .display_version )
49
- munge_specfile (
50
- self .spec_file ,
51
- sha ,
52
- self .commit_count ,
53
- fullname ,
54
- self .tgz_filename ,
55
- )
56
- # Custom Openshift v3 stuff follows, everything above is the standard
57
- # builder
36
+ super (OriginBuilder , self )._setup_test_specfile ()
58
37
59
- ## Fixup os_git_vars
60
- cmd = '. ./hack/common.sh ; OS_ROOT=$(pwd) ; os::build::os_version_vars ; echo ${OS_GIT_COMMIT}'
61
- os_git_commit = run_command ("bash -c '{0}'" .format (cmd ))
62
- cmd = '. ./hack/common.sh ; OS_ROOT=$(pwd) ; os::build::os_version_vars ; echo ${OS_GIT_VERSION}'
63
- os_git_version = run_command ("bash -c '{0}'" .format (cmd ))
64
- os_git_version = os_git_version .replace ('-dirty' , '' )
65
- cmd = '. ./hack/common.sh ; OS_ROOT=$(pwd) ; os::build::os_version_vars ; echo ${OS_GIT_MAJOR}'
66
- os_git_major = run_command ("bash -c '{0}'" .format (cmd ))
67
- cmd = '. ./hack/common.sh ; OS_ROOT=$(pwd) ; os::build::os_version_vars ; echo ${OS_GIT_MINOR}'
68
- os_git_minor = run_command ("bash -c '{0}'" .format (cmd ))
69
- print ("OS_GIT_COMMIT::{0}" .format (os_git_commit ))
70
- print ("OS_GIT_VERSION::{0}" .format (os_git_version ))
71
- print ("OS_GIT_MAJOR::{0}" .format (os_git_major ))
72
- print ("OS_GIT_MINOR::{0}" .format (os_git_minor ))
73
- update_os_git_vars = \
74
- "sed -i 's|^%global os_git_vars .*$|%global os_git_vars OS_GIT_TREE_STATE='clean' OS_GIT_VERSION={0} OS_GIT_COMMIT={1} OS_GIT_MAJOR={2} OS_GIT_MINOR={3}|' {4}" .format (
75
- os_git_version ,
76
- os_git_commit ,
77
- os_git_major ,
78
- os_git_minor ,
79
- self .spec_file
80
- )
81
- output = run_command (update_os_git_vars )
38
+ inject_os_git_vars (self .spec_file )
39
+ self ._inject_bundled_deps ()
82
40
41
+ def _inject_bundled_deps (self ):
83
42
# Add bundled deps for Fedora Guidelines as per:
84
43
# https://fedoraproject.org/wiki/Packaging:Guidelines#Bundling_and_Duplication_of_system_libraries
85
44
provides_list = []
@@ -113,34 +72,4 @@ def _setup_test_specfile(self):
113
72
else :
114
73
spec_file_f .write (line )
115
74
116
- self .build_version += ".git." + \
117
- str (self .commit_count ) + \
118
- "." + \
119
- str (self .git_commit_id [:7 ])
120
- self .ran_setup_test_specfile = True
121
-
122
- def _get_build_version (self ):
123
- """
124
- Figure out the git tag and version-release we're building.
125
- """
126
- # Determine which package version we should build:
127
- build_version = None
128
- if self .build_tag :
129
- build_version = self .build_tag [len (self .project_name + "-" ):]
130
- else :
131
- build_version = get_latest_tagged_version (self .project_name )
132
- if build_version is None :
133
- if not self .test :
134
- error_out (["Unable to lookup latest package info." ,
135
- "Perhaps you need to tag first?" ])
136
- sys .stderr .write ("WARNING: unable to lookup latest package "
137
- "tag, building untagged test project\n " )
138
- build_version = get_spec_version_and_release (self .start_dir ,
139
- find_spec_file (in_dir = self .start_dir ))
140
- self .build_tag = "v{0}" .format (build_version )
141
-
142
- if not self .test :
143
- check_tag_exists (self .build_tag , offline = self .offline )
144
- return build_version
145
-
146
- # vim:expandtab:autoindent:tabstop=4:shiftwidth=4:filetype=python:textwidth=0:
75
+ # vim:expandtab:autoindent:tabstop=4:shiftwidth=4:filetype=python:textwidth=0:
0 commit comments