source: cmtpacman/HEAD/scripts/create_project_kits.sh @ 695

Last change on this file since 695 was 53, checked in by arnault, 19 years ago

From CVS to SVN

File size: 3.5 KB
Line 
1
2function 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
20function 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
48description='Project description for ${p_name} ${p_id} ${platform_opt} ${pacman_file_version}'
49
50url = 'http://atlas.web.cern.ch/Atlas/GROUPS/SOFTWARE/OO/Development/'
51
52depends = [ '${previous}' ]
53
54usePackageRoot = 0
55
56source = '${source}'
57${download_text}
58
59paths = [ ['CMTPATH', '\$PACMAN_INSTALLATION/${p_name}/${p_id}'] ]
60
61EOF
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#
79platform=
80platform_opt=
81
82while test ! $# = 0; do
83
84  if test "$1" = "-platform"; then
85    shift
86    platform=$1
87    platform_opt="-${platform}"
88  fi
89  shift
90done
91
92cmtversion=`cmt version`
93
94if test "${CMTPATH}" = ""; then
95  echo "Please define first CMTPATH"
96  exit 1
97fi
98
99#---------------
100
101#---------------
102# Prepare the pacman cache environment
103#
104if test "${PACMAN_CACHE}" = ""; then
105  echo "Please define first the PACMAN_CACHE"
106  exit 1
107fi
108
109cache_dir=${PACMAN_CACHE}/cache
110kits_dir=${PACMAN_CACHE}/kits
111source='../kits'
112
113if test ! -d ${cache_dir}; then
114  mkdir -p ${cache_dir}
115fi
116
117if test ! -d ${kits_dir}; then
118  mkdir -p ${kits_dir}
119fi
120#---------------
121
122
123#---------------
124# Revert the order of CMTPATH (ie of projects)
125#
126reverse=
127for f in `echo ${CMTPATH} | sed -e 's#[:]# #g'`; do
128  reverse="${f} ${reverse}"
129done
130#---------------
131
132#---------------
133# Prepare temporary file management
134#
135tempprefix=/tmp/CMT$$
136if test ! "${TMP}" = ""; then
137  tempprefix=${TMP}/CMT$$
138fi
139
140tempcopydir=${tempprefix}/c$$
141
142trap "if test -d ${tempprefix} ; then chmod -R +w ${tempprefix}; fi; /bin/rm -rf ${tempprefix}" 0 1 2 15
143
144if 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#
151previous="CMTCONFIG-${cmtversion}${platform_opt}"
152
153for f in `echo ${reverse}`; do
154  echo "--------------------------------------------"
155  echo "Building kit for project_path=${f}"
156  project_path=${f}
157  build_one_project
158done
159#---------------
160
Note: See TracBrowser for help on using the repository browser.