Skip to content

Commit 3d4b3ed

Browse files
committed
package-msi: added log messages to aid debugging
Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
1 parent 2cc90e2 commit 3d4b3ed

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

build-scripts/package-msi

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@
1414
WIXPATH="$HOME/wix"
1515

1616
# Check if WiX tools are installed, install them if not present
17+
log_debug "Checking for WiX tools at $WIXPATH"
1718
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"
1920
else
21+
log_debug "WiX tools not found - starting installation"
2022
(
2123
# Download prerequisites from build artifacts cache server
2224
cd /tmp || exit
@@ -61,11 +63,14 @@ CANDLE="wine $WIXPATH/candle.exe"
6163
LIGHT="wine $WIXPATH/light.exe"
6264

6365
# 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)"
6467
if [ -z "$JOB_NAME" ]; then
6568
DIRNAME=build-$VERSION-$ARCH
69+
log_debug "No JOB_NAME set, using DIRNAME=$DIRNAME"
6670
else
6771
# Extract first part of Jenkins job name (before the slash)
6872
DIRNAME=$(echo "${JOB_NAME}" | sed 's/\(.*\)\/.*/\1/g')
73+
log_debug "Using Jenkins job name, DIRNAME=$DIRNAME"
6974
fi
7075

7176
# Set up packaging directory paths
@@ -75,19 +80,26 @@ P=$PKGD/$DIRNAME
7580
# pre() - Prepare the packaging directory structure and copy all required files
7681
# This function sets up the directory layout for the MSI package build
7782
pre() {
83+
log_debug "Preparing packaging directory structure"
84+
7885
# Clean up any existing packaging directory and create fresh structure
86+
log_debug "Removing existing packaging directory: $PKGD"
7987
rm -rf "$PKGD"
8088
mkdir -p "$P"/bin
8189
mkdir -p "$P"/ssl
8290

8391
# Copy CFEngine binaries and SSL files from build prefix
92+
log_debug "Copying binaries from $BUILDPREFIX/bin to $P/bin"
8493
cp -a "$BUILDPREFIX"/bin/* "$P"/bin
94+
log_debug "Copying SSL files from $BUILDPREFIX/ssl to $P/ssl"
8595
cp -a "$BUILDPREFIX"/ssl/* "$P"/ssl
96+
log_debug "Copying dist binaries from $BASEDIR/cfengine/dist$BUILDPREFIX/bin"
8697
cp -a "$BASEDIR"/cfengine/dist"$BUILDPREFIX"/bin/* "$P"/bin
8798

8899
# Copy MinGW runtime DLL and architecture-specific event DLL
89100
# TODO: make not hard-coded paths for debian/ubuntu installations of mingw
90101
# 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"
91103
case "$ARCH" in
92104
x86)
93105
# 32-bit: Copy i686 MinGW pthread DLL and 32-bit event DLL
@@ -100,7 +112,7 @@ pre() {
100112
cp -a "$BASEDIR"/enterprise/libcfenterprise/cf.events.x86_64.dll "$P"/bin/cf.events.dll
101113
;;
102114
*)
103-
echo "Unknown architecture: $ARCH"
115+
log_error "Unknown architecture: $ARCH"
104116
exit 1
105117
;;
106118
esac
@@ -128,6 +140,7 @@ pre() {
128140
# CfArch: Architecture (x86 or x64)
129141
candle() {
130142
REVISION="$1"
143+
log_debug "Running candle with REVISION=$REVISION, ARCH=$ARCH"
131144
$CANDLE -dCfSourceDir=. -dCfVersion="$REVISION" -dCfArch="$ARCH" cfengine-nova.wxs
132145
}
133146

@@ -138,14 +151,17 @@ candle() {
138151
# -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)
139152
# -ext WixUtilExtension: Include WiX utility extension for additional functionality
140153
light() {
154+
log_debug "Running light to link WiX object into MSI"
141155
$LIGHT -sval -sice:ICE20 -ext WixUtilExtension cfengine-nova.wixobj
142156
}
143157

144158
# package() - Main packaging function that creates the MSI installer
145159
package() {
160+
log_debug "Creating MSI installer"
146161
cd "$P"
147162

148163
# Determine the package revision number based on build configuration
164+
log_debug "Determining package revision (BUILD_TYPE=$BUILD_TYPE, VERSION=$VERSION)"
149165
if [ -z "$EXPLICIT_VERSION" ]; then
150166
# First make sure VERSION does not contain a 4th dot, since on Windows we'll
151167
# add one later (plus they can only be numeric); so convert
@@ -180,6 +196,7 @@ package() {
180196
# Convert alphabetic characters to numeric
181197
# MSI version numbers must be purely numeric
182198
# 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"
183200
while true; do
184201
alphabet=$(echo "$REVISION" | sed -e 's/[^a-zA-Z]*\([a-zA-Z]*\).*/\1/')
185202
if [ -n "$alphabet" ]; then
@@ -205,10 +222,12 @@ package() {
205222

206223
# Find an available drive letter for Wine mapping
207224
# Start from Y: and work backwards (Z: is typically mapped to root /)
225+
log_debug "Finding available Wine drive letter for path limitation workaround"
208226
WORKSPACE_DRIVE=
209227
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
210228
if [ ! -e "$HOME"/.wine/dosdevices/$letter: ]; then
211229
WORKSPACE_DRIVE=$letter:
230+
log_debug "Using Wine drive letter $WORKSPACE_DRIVE mapped to $PWD"
212231
# Create symlink from Wine drive letter to current directory
213232
ln -s "$PWD" "$HOME"/.wine/dosdevices/$WORKSPACE_DRIVE
214233
break
@@ -221,6 +240,7 @@ package() {
221240
fi
222241

223242
# Run WiX compilation and linking steps
243+
log_debug "Starting WiX compilation and linking with final REVISION=$REVISION"
224244
ret=0
225245
candle "$REVISION" && light || ret=$?
226246

@@ -233,6 +253,7 @@ package() {
233253
# post() - Post-processing function to finalize the MSI package
234254
# Moves the generated MSI to the output directory and renames it appropriately
235255
post() {
256+
log_debug "Finalizing MSI package"
236257
# Create output directory and move the MSI file there
237258
mkdir -p "$BASEDIR"/cfengine-nova
238259
mv "$P"/cfengine-nova.msi "$BASEDIR"/cfengine-nova
@@ -254,6 +275,7 @@ post() {
254275
esac
255276

256277
# Rename MSI file with architecture suffix
278+
log_debug "Renaming MSI file for architecture $ARCH with PKGNAME=$PKGNAME"
257279
case $ARCH in
258280
x86)
259281
# 32-bit: Add i686 suffix
@@ -267,6 +289,8 @@ post() {
267289
}
268290

269291
# Main execution flow:
292+
log_debug "--- Starting MSI package build process ---"
270293
pre # Prepare packaging directory and copy files
271294
package # Build the MSI using WiX tools
272295
post # Finalize and rename the MSI package
296+
log_debug "--- MSI package build completed ----"

0 commit comments

Comments
 (0)