14
14
WIXPATH=" $HOME /wix"
15
15
16
16
# Check if WiX tools are installed, install them if not present
17
+ log_debug " Checking for WiX tools at $WIXPATH "
17
18
if [ -f " $WIXPATH /candle.exe" ] && [ -f " $WIXPATH /light.exe" ]; then
18
- echo " Wix Tools are installed at $WIXPATH "
19
+ log_debug " WiX tools found - candle.exe and light.exe are present "
19
20
else
21
+ log_debug " WiX tools not found - starting installation"
20
22
(
21
23
# Download prerequisites from build artifacts cache server
22
24
cd /tmp || exit
@@ -61,11 +63,14 @@ CANDLE="wine $WIXPATH/candle.exe"
61
63
LIGHT=" wine $WIXPATH /light.exe"
62
64
63
65
# Determine build directory name based on Jenkins job or version/arch
66
+ log_debug " Determining build directory name (JOB_NAME=$JOB_NAME , VERSION=$VERSION , ARCH=$ARCH )"
64
67
if [ -z " $JOB_NAME " ]; then
65
68
DIRNAME=build-$VERSION -$ARCH
69
+ log_debug " No JOB_NAME set, using DIRNAME=$DIRNAME "
66
70
else
67
71
# Extract first part of Jenkins job name (before the slash)
68
72
DIRNAME=$( echo " ${JOB_NAME} " | sed ' s/\(.*\)\/.*/\1/g' )
73
+ log_debug " Using Jenkins job name, DIRNAME=$DIRNAME "
69
74
fi
70
75
71
76
# Set up packaging directory paths
@@ -75,19 +80,26 @@ P=$PKGD/$DIRNAME
75
80
# pre() - Prepare the packaging directory structure and copy all required files
76
81
# This function sets up the directory layout for the MSI package build
77
82
pre () {
83
+ log_debug " Preparing packaging directory structure"
84
+
78
85
# Clean up any existing packaging directory and create fresh structure
86
+ log_debug " Removing existing packaging directory: $PKGD "
79
87
rm -rf " $PKGD "
80
88
mkdir -p " $P " /bin
81
89
mkdir -p " $P " /ssl
82
90
83
91
# Copy CFEngine binaries and SSL files from build prefix
92
+ log_debug " Copying binaries from $BUILDPREFIX /bin to $P /bin"
84
93
cp -a " $BUILDPREFIX " /bin/* " $P " /bin
94
+ log_debug " Copying SSL files from $BUILDPREFIX /ssl to $P /ssl"
85
95
cp -a " $BUILDPREFIX " /ssl/* " $P " /ssl
96
+ log_debug " Copying dist binaries from $BASEDIR /cfengine/dist$BUILDPREFIX /bin"
86
97
cp -a " $BASEDIR " /cfengine/dist" $BUILDPREFIX " /bin/* " $P " /bin
87
98
88
99
# Copy MinGW runtime DLL and architecture-specific event DLL
89
100
# TODO: make not hard-coded paths for debian/ubuntu installations of mingw
90
101
# These paths are currently hard-coded as there's no easy way to dynamically find them
102
+ log_debug " Copying MinGW runtime DLLs for architecture: $ARCH "
91
103
case " $ARCH " in
92
104
x86)
93
105
# 32-bit: Copy i686 MinGW pthread DLL and 32-bit event DLL
@@ -100,7 +112,7 @@ pre() {
100
112
cp -a " $BASEDIR " /enterprise/libcfenterprise/cf.events.x86_64.dll " $P " /bin/cf.events.dll
101
113
;;
102
114
* )
103
- echo " Unknown architecture: $ARCH "
115
+ log_error " Unknown architecture: $ARCH "
104
116
exit 1
105
117
;;
106
118
esac
@@ -128,6 +140,7 @@ pre() {
128
140
# CfArch: Architecture (x86 or x64)
129
141
candle () {
130
142
REVISION=" $1 "
143
+ log_debug " Running candle with REVISION=$REVISION , ARCH=$ARCH "
131
144
$CANDLE -dCfSourceDir=. -dCfVersion=" $REVISION " -dCfArch=" $ARCH " cfengine-nova.wxs
132
145
}
133
146
@@ -138,14 +151,17 @@ candle() {
138
151
# -sice:ICE20: Suppress ICE20 validation (makes sure you have the necessary dialogs defined to handle things like showing a friendly message when the user cancels the install)
139
152
# -ext WixUtilExtension: Include WiX utility extension for additional functionality
140
153
light () {
154
+ log_debug " Running light to link WiX object into MSI"
141
155
$LIGHT -sval -sice:ICE20 -ext WixUtilExtension cfengine-nova.wixobj
142
156
}
143
157
144
158
# package() - Main packaging function that creates the MSI installer
145
159
package () {
160
+ log_debug " Creating MSI installer"
146
161
cd " $P "
147
162
148
163
# Determine the package revision number based on build configuration
164
+ log_debug " Determining package revision (BUILD_TYPE=$BUILD_TYPE , VERSION=$VERSION )"
149
165
if [ -z " $EXPLICIT_VERSION " ]; then
150
166
# First make sure VERSION does not contain a 4th dot, since on Windows we'll
151
167
# add one later (plus they can only be numeric); so convert
@@ -180,6 +196,7 @@ package() {
180
196
# Convert alphabetic characters to numeric
181
197
# MSI version numbers must be purely numeric
182
198
# Example: 3.10.0a becomes 3.10.097 (where 'a' = ASCII 97)
199
+ log_debug " Transforming $REVISION to only numeric characters by replacing alphabet characters to their ASCII value"
183
200
while true ; do
184
201
alphabet=$( echo " $REVISION " | sed -e ' s/[^a-zA-Z]*\([a-zA-Z]*\).*/\1/' )
185
202
if [ -n " $alphabet " ]; then
@@ -205,10 +222,12 @@ package() {
205
222
206
223
# Find an available drive letter for Wine mapping
207
224
# Start from Y: and work backwards (Z: is typically mapped to root /)
225
+ log_debug " Finding available Wine drive letter for path limitation workaround"
208
226
WORKSPACE_DRIVE=
209
227
for letter in y x w v u t s r q p o n m l k j i h g f e d; do
210
228
if [ ! -e " $HOME " /.wine/dosdevices/$letter : ]; then
211
229
WORKSPACE_DRIVE=$letter :
230
+ log_debug " Using Wine drive letter $WORKSPACE_DRIVE mapped to $PWD "
212
231
# Create symlink from Wine drive letter to current directory
213
232
ln -s " $PWD " " $HOME " /.wine/dosdevices/$WORKSPACE_DRIVE
214
233
break
@@ -221,6 +240,7 @@ package() {
221
240
fi
222
241
223
242
# Run WiX compilation and linking steps
243
+ log_debug " Starting WiX compilation and linking with final REVISION=$REVISION "
224
244
ret=0
225
245
candle " $REVISION " && light || ret=$?
226
246
@@ -233,6 +253,7 @@ package() {
233
253
# post() - Post-processing function to finalize the MSI package
234
254
# Moves the generated MSI to the output directory and renames it appropriately
235
255
post () {
256
+ log_debug " Finalizing MSI package"
236
257
# Create output directory and move the MSI file there
237
258
mkdir -p " $BASEDIR " /cfengine-nova
238
259
mv " $P " /cfengine-nova.msi " $BASEDIR " /cfengine-nova
@@ -254,6 +275,7 @@ post() {
254
275
esac
255
276
256
277
# Rename MSI file with architecture suffix
278
+ log_debug " Renaming MSI file for architecture $ARCH with PKGNAME=$PKGNAME "
257
279
case $ARCH in
258
280
x86)
259
281
# 32-bit: Add i686 suffix
@@ -267,6 +289,8 @@ post() {
267
289
}
268
290
269
291
# Main execution flow:
292
+ log_debug " --- Starting MSI package build process ---"
270
293
pre # Prepare packaging directory and copy files
271
294
package # Build the MSI using WiX tools
272
295
post # Finalize and rename the MSI package
296
+ log_debug " --- MSI package build completed ----"
0 commit comments