1 |
|
---|
2 | function get_pacman_file_version ()
|
---|
3 | {
|
---|
4 | old_file=$1
|
---|
5 | shift
|
---|
6 |
|
---|
7 | pacman_file_version=1
|
---|
8 | if test -f ${old_file}; then
|
---|
9 | pacman_file_version=`grep description ${old_file} | egrep '[(]v' | sed -e 's#.*(v##' -e 's#).*##'`
|
---|
10 | if test "${pacman_file_version}" = ""; then
|
---|
11 | pacman_file_version=1
|
---|
12 | else
|
---|
13 | pacman_file_version=`expr ${pacman_file_version} + 1`
|
---|
14 | fi
|
---|
15 | fi
|
---|
16 |
|
---|
17 | echo "(v${pacman_file_version})"
|
---|
18 | }
|
---|
19 |
|
---|
20 | function build_one_project ()
|
---|
21 | {
|
---|
22 | p_id=`basename ${project_path}`
|
---|
23 | p_name=`dirname ${project_path}`
|
---|
24 | p_name=`basename ${p_name}`
|
---|
25 |
|
---|
26 | # echo "p_id=${p_id} p_name=${p_name} "
|
---|
27 |
|
---|
28 | pacman_base_filename=${p_name}-${p_id}${platform_opt}
|
---|
29 | pacman_filename=${pacman_base_filename}.pacman
|
---|
30 |
|
---|
31 | pacman_file_version=`get_pacman_file_version ${cache_dir}/${pacman_filename}`
|
---|
32 |
|
---|
33 | if test -f ${cache_dir}/${pacman_filename}; then
|
---|
34 | mv ${cache_dir}/${pacman_filename} ${cache_dir}/${pacman_filename}.bak
|
---|
35 | if test ! $? = 0; then
|
---|
36 | echo "failed to rename ${cache_dir}/${pacman_filename} to ${cache_dir}/${pacman_filename}.bak"
|
---|
37 | exit 1
|
---|
38 | fi
|
---|
39 | fi
|
---|
40 |
|
---|
41 | if test -f ${project_path}/cmt/project.cmt; then
|
---|
42 | download_filename="${pacman_base_filename}"
|
---|
43 | download_text="download = { '*':'${download_filename}.tar.gz' }"
|
---|
44 | fi
|
---|
45 |
|
---|
46 | cat <<EOF >|${cache_dir}/${pacman_filename}
|
---|
47 |
|
---|
48 | description='Project description for ${p_name} ${p_id} ${platform_opt} ${pacman_file_version}'
|
---|
49 |
|
---|
50 | url = 'http://atlas.web.cern.ch/Atlas/GROUPS/SOFTWARE/OO/Development/'
|
---|
51 |
|
---|
52 | depends = [ '${previous}' ]
|
---|
53 |
|
---|
54 | usePackageRoot = 0
|
---|
55 |
|
---|
56 | source = '${source}'
|
---|
57 | ${download_text}
|
---|
58 |
|
---|
59 | paths = [ ['CMTPATH', '\$PACMAN_INSTALLATION/${p_name}/${p_id}'] ]
|
---|
60 |
|
---|
61 | EOF
|
---|
62 |
|
---|
63 | if test -f ${project_path}/cmt/project.cmt; then
|
---|
64 |
|
---|
65 | echo "Constructing the tar ball of the project file"
|
---|
66 |
|
---|
67 | mkdir -p ${tempcopydir}/${p_name}/${p_id}
|
---|
68 | cp -R ${project_path}/cmt ${tempcopydir}/${p_name}/${p_id}
|
---|
69 | (cd ${tempcopydir}; tar czvf ${kits_dir}/${download_filename}.tar.gz ${p_name} --exclude=CVS)
|
---|
70 |
|
---|
71 | fi
|
---|
72 |
|
---|
73 | previous="${p_name}-${p_id}${platform_opt}"
|
---|
74 | }
|
---|
75 |
|
---|
76 | #---------------
|
---|
77 | # Prepare arguments and options
|
---|
78 | #
|
---|
79 | platform=
|
---|
80 | platform_opt=
|
---|
81 |
|
---|
82 | while test ! $# = 0; do
|
---|
83 |
|
---|
84 | if test "$1" = "-platform"; then
|
---|
85 | shift
|
---|
86 | platform=$1
|
---|
87 | platform_opt="-${platform}"
|
---|
88 | fi
|
---|
89 | shift
|
---|
90 | done
|
---|
91 |
|
---|
92 | cmtversion=`cmt version`
|
---|
93 |
|
---|
94 | if test "${CMTPATH}" = ""; then
|
---|
95 | echo "Please define first CMTPATH"
|
---|
96 | exit 1
|
---|
97 | fi
|
---|
98 |
|
---|
99 | #---------------
|
---|
100 |
|
---|
101 | #---------------
|
---|
102 | # Prepare the pacman cache environment
|
---|
103 | #
|
---|
104 | if test "${PACMAN_CACHE}" = ""; then
|
---|
105 | echo "Please define first the PACMAN_CACHE"
|
---|
106 | exit 1
|
---|
107 | fi
|
---|
108 |
|
---|
109 | cache_dir=${PACMAN_CACHE}/cache
|
---|
110 | kits_dir=${PACMAN_CACHE}/kits
|
---|
111 | source='../kits'
|
---|
112 |
|
---|
113 | if test ! -d ${cache_dir}; then
|
---|
114 | mkdir -p ${cache_dir}
|
---|
115 | fi
|
---|
116 |
|
---|
117 | if test ! -d ${kits_dir}; then
|
---|
118 | mkdir -p ${kits_dir}
|
---|
119 | fi
|
---|
120 | #---------------
|
---|
121 |
|
---|
122 |
|
---|
123 | #---------------
|
---|
124 | # Revert the order of CMTPATH (ie of projects)
|
---|
125 | #
|
---|
126 | reverse=
|
---|
127 | for f in `echo ${CMTPATH} | sed -e 's#[:]# #g'`; do
|
---|
128 | reverse="${f} ${reverse}"
|
---|
129 | done
|
---|
130 | #---------------
|
---|
131 |
|
---|
132 | #---------------
|
---|
133 | # Prepare temporary file management
|
---|
134 | #
|
---|
135 | tempprefix=/tmp/CMT$$
|
---|
136 | if test ! "${TMP}" = ""; then
|
---|
137 | tempprefix=${TMP}/CMT$$
|
---|
138 | fi
|
---|
139 |
|
---|
140 | tempcopydir=${tempprefix}/c$$
|
---|
141 |
|
---|
142 | trap "if test -d ${tempprefix} ; then chmod -R +w ${tempprefix}; fi; /bin/rm -rf ${tempprefix}" 0 1 2 15
|
---|
143 |
|
---|
144 | if test -d ${tempprefix} ; then chmod -R +w ${tempprefix}; fi
|
---|
145 | /bin/rm -rf ${tempprefix}
|
---|
146 | #---------------
|
---|
147 |
|
---|
148 | #---------------
|
---|
149 | # Loop over projects in reverse order
|
---|
150 | #
|
---|
151 | previous="CMTCONFIG-${cmtversion}${platform_opt}"
|
---|
152 |
|
---|
153 | for f in `echo ${reverse}`; do
|
---|
154 | echo "--------------------------------------------"
|
---|
155 | echo "Building kit for project_path=${f}"
|
---|
156 | project_path=${f}
|
---|
157 | build_one_project
|
---|
158 | done
|
---|
159 | #---------------
|
---|
160 |
|
---|