summaryrefslogtreecommitdiffstats
path: root/pki/scripts/compose_pki_migrate_packages
blob: d36b58417e580e983440ed9824ddf2a64e503fc8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
#!/bin/bash
# BEGIN COPYRIGHT BLOCK
# (C) 2010 Red Hat, Inc.
# All rights reserved.
# END COPYRIGHT BLOCK

## Always switch into the base directory three levels
## above this shell script prior to executing it so
## that all of its output is written to this directory

cd `dirname $0`/../..


##
## Retrieve the name of this base directory
##

PKI_PWD=`pwd`


##
## Establish the 'pki-migrate' name and version information
##

PKI_MIGRATE="pki-migrate"
PKI_MIGRATE_VERSION="9.0.0"


##
## Establish the SOURCE files/directories of the 'pki-migrate' source directory
##

PKI_DIR="pki"
PKI_BASE_DIR="${PKI_DIR}/base"
PKI_SPECS_FILE="${PKI_DIR}/specs/${PKI_MIGRATE}.spec"
PKI_FILE_LIST="CMakeLists.txt COPYING CPackConfig.cmake ConfigureChecks.cmake DefineOptions.cmake README cmake_uninstall.cmake.in config.h.cmake"
PKI_CMAKE_DIR="cmake"
PKI_BASE_MANIFEST="CMakeLists.txt"
PKI_COMPONENT_LIST="migrate"


##
## Establish the TARGET files/directories of the 'pki-migrate' source/spec files
##

PKI_PACKAGES="${PKI_PWD}/packages"
PKI_MIGRATE_BUILD_DIR="${PKI_PACKAGES}/BUILD"
PKI_MIGRATE_RPMS_DIR="${PKI_PACKAGES}/RPMS"
PKI_MIGRATE_SOURCES_DIR="${PKI_PACKAGES}/SOURCES"
PKI_MIGRATE_SPECS_DIR="${PKI_PACKAGES}/SPECS"
PKI_MIGRATE_SRPMS_DIR="${PKI_PACKAGES}/SRPMS"

PKI_MIGRATE_TARBALL="${PKI_MIGRATE}-${PKI_MIGRATE_VERSION}.tar.gz"
PKI_MIGRATE_SPEC_FILE="${PKI_MIGRATE_SPECS_DIR}/${PKI_MIGRATE}.spec"
PKI_MIGRATE_PACKAGE_SCRIPT="${PKI_PACKAGES}/package_${PKI_MIGRATE}"
PKI_MIGRATE_PACKAGE_COMMAND="rpmbuild --define \"_topdir \`pwd\`\" -ba SPECS/${PKI_MIGRATE}.spec"

PKI_MIGRATE_STAGING_DIR="${PKI_PACKAGES}/staging"
PKI_MIGRATE_DIR="${PKI_MIGRATE_STAGING_DIR}/${PKI_MIGRATE}-${PKI_MIGRATE_VERSION}"
PKI_MIGRATE_BASE_DIR="${PKI_MIGRATE_DIR}/base"


##
## Always create a top-level 'packages' directory
##

mkdir -p ${PKI_PACKAGES}


##
## Always create 'pki-migrate' package directories
##

mkdir -p ${PKI_MIGRATE_BUILD_DIR}
mkdir -p ${PKI_MIGRATE_RPMS_DIR}
mkdir -p ${PKI_MIGRATE_SOURCES_DIR}
mkdir -p ${PKI_MIGRATE_SPECS_DIR}
mkdir -p ${PKI_MIGRATE_SRPMS_DIR}


##
## Always start with new 'pki-migrate' package files
##

rm -rf ${PKI_MIGRATE_BUILD_DIR}/${PKI_MIGRATE}-${PKI_MIGRATE_VERSION}
rm -f  ${PKI_MIGRATE_RPMS_DIR}/${PKI_MIGRATE}-${PKI_MIGRATE_VERSION}*.rpm
rm -f  ${PKI_MIGRATE_SOURCES_DIR}/${PKI_MIGRATE_TARBALL}
rm -f  ${PKI_MIGRATE_SPEC_FILE}
rm -f  ${PKI_MIGRATE_SRPMS_DIR}/${PKI_MIGRATE}-${PKI_MIGRATE_VERSION}*.rpm


##
## Copy a new 'pki-migrate' spec file from the
## current contents of the PKI working repository
##

cp -p ${PKI_SPECS_FILE} ${PKI_MIGRATE_SPECS_DIR}


##
## Always start with a new 'pki-migrate' staging directory
##

rm -rf ${PKI_MIGRATE_STAGING_DIR}


##
## To generate the 'pki-migrate' tarball, construct a staging area
## consisting of the 'pki-migrate' source components from the
## current contents of the PKI working repository
##

mkdir -p ${PKI_MIGRATE_DIR}
cd ${PKI_DIR}
for file in "${PKI_FILE_LIST}" ;
do
	cp -p ${file} ${PKI_MIGRATE_DIR}
done
find ${PKI_CMAKE_DIR}             \
	-name .svn -prune -o          \
	-name *.swp -prune -o         \
	-print | cpio -pdum ${PKI_MIGRATE_DIR} > /dev/null 2>&1
cd - > /dev/null 2>&1

mkdir -p ${PKI_MIGRATE_BASE_DIR}
cd ${PKI_BASE_DIR}
cp -p ${PKI_BASE_MANIFEST} ${PKI_MIGRATE_BASE_DIR}
for component in "${PKI_COMPONENT_LIST}" ;
do
	find ${component}             \
	-name .svn -prune -o          \
	-name *.swp -prune -o         \
	-name Makefile.am -prune -o   \
	-name Makefile.in -prune -o   \
	-name aclocal.m4 -prune -o    \
	-name autogen.sh -prune -o    \
	-name build.xml -prune -o     \
	-name compile -prune -o       \
	-name config.guess -prune -o  \
	-name config.h.in -prune -o   \
	-name config.sub -prune -o    \
	-name configure -prune -o     \
	-name configure.ac -prune -o  \
	-name depcomp -prune -o       \
	-name install-sh -prune -o    \
	-name ltmain.sh -prune -o     \
	-name m4 -prune -o            \
	-name missing -prune -o       \
	-name setup_package -prune -o \
	-print | cpio -pdum ${PKI_MIGRATE_BASE_DIR} > /dev/null 2>&1
done
cd - > /dev/null 2>&1


##
## Due to the following lower-level 'config' subdirectories,
## INDEPENDENTLY remove ALL top-level 'config' directories:
##
##     * ./console/src/com/netscape/admin/certsrv/config (N/A 'pki-migrate')
##     * ./tps/forms/tps/admin/console/config            (N/A 'pki-migrate')
##

rm -rf ${PKI_MIGRATE_BASE_DIR}/*/config


##
## Create the 'pki-migrate' tarball
##

mkdir -p ${PKI_MIGRATE_SOURCES_DIR}
cd ${PKI_MIGRATE_STAGING_DIR}
gtar -zcvf ${PKI_MIGRATE_TARBALL}    \
	"${PKI_MIGRATE}-${PKI_MIGRATE_VERSION}" > /dev/null 2>&1
mv ${PKI_MIGRATE_TARBALL} ${PKI_MIGRATE_SOURCES_DIR}
cd - > /dev/null 2>&1


##
## Always remove the PKI staging area
##

rm -rf ${PKI_MIGRATE_STAGING_DIR}


##
## Always generate a fresh 'pki-migrate' package script
##

rm -rf ${PKI_MIGRATE_PACKAGE_SCRIPT}
printf "#!/bin/bash\n\n"                    >  ${PKI_MIGRATE_PACKAGE_SCRIPT}
printf "${PKI_MIGRATE_PACKAGE_COMMAND}\n\n" >> ${PKI_MIGRATE_PACKAGE_SCRIPT}
chmod 775 ${PKI_MIGRATE_PACKAGE_SCRIPT}


##
## Automatically invoke RPM/SRPM creation
##

cd ${PKI_PACKAGES} ;
script -c package_${PKI_MIGRATE} package_${PKI_MIGRATE}.log