@@ -53,26 +53,102 @@ log "Latest version from GitHub API: ${LATEST_VERSION}"
53
53
54
54
# Run the AutoPkg recipe for Fleet with verbose output
55
55
log " Running the AutoPkg recipe to create the Fleet package..."
56
+ CACHE_DIR=" /Users/runner/Library/AutoPkg/Cache/com.github.jc0b.pkg.fleetctl"
56
57
AUTOPKG_OUTPUT=$( GITHUB_TOKEN=" $PACKAGE_AUTOMATION_TOKEN " autopkg run -vv com.github.jc0b.pkg.fleetctl)
57
58
log " AutoPkg Output:"
58
59
echo " $AUTOPKG_OUTPUT "
59
60
61
+ # Check for fleetctl binary and fix path structure if needed
62
+ if [[ " $AUTOPKG_OUTPUT " == * " Error processing path" * ]]; then
63
+ log " AutoPkg recipe failed. Attempting to fix fleetctl binary path..."
64
+
65
+ # Show extracted contents for debugging
66
+ log " Extracted contents of fleetctl directory:"
67
+ find " $CACHE_DIR /fleetctl" -type f | sort
68
+
69
+ # Find the actual fleetctl binary
70
+ EXTRACTED_FLEETCTL=$( find " $CACHE_DIR /fleetctl" -type f -name " fleetctl" | head -n 1)
71
+
72
+ if [ -n " $EXTRACTED_FLEETCTL " ]; then
73
+ log " Found fleetctl binary at: $EXTRACTED_FLEETCTL "
74
+
75
+ # Create the expected directory structure
76
+ mkdir -p " $CACHE_DIR /fleetctl/fleetctl_v${LATEST_VERSION} _macos_all"
77
+ cp " $EXTRACTED_FLEETCTL " " $CACHE_DIR /fleetctl/fleetctl_v${LATEST_VERSION} _macos_all/fleetctl"
78
+ chmod +x " $CACHE_DIR /fleetctl/fleetctl_v${LATEST_VERSION} _macos_all/fleetctl"
79
+
80
+ log " Copied fleetctl binary to expected location"
81
+
82
+ # Try running AutoPkg again
83
+ log " Running AutoPkg recipe again with fixed path..."
84
+ AUTOPKG_OUTPUT=$( GITHUB_TOKEN=" $PACKAGE_AUTOMATION_TOKEN " autopkg run -vv com.github.jc0b.pkg.fleetctl)
85
+ log " AutoPkg Output (second attempt):"
86
+ echo " $AUTOPKG_OUTPUT "
87
+ else
88
+ # Try to find any binary in the extracted files
89
+ log " Could not find fleetctl binary by name. Looking for any executable file..."
90
+ EXTRACTED_FILES=$( find " $CACHE_DIR /fleetctl" -type f -perm -u+x | head -n 1)
91
+
92
+ if [ -n " $EXTRACTED_FILES " ]; then
93
+ log " Found possible binary at: $EXTRACTED_FILES "
94
+ mkdir -p " $CACHE_DIR /fleetctl/fleetctl_v${LATEST_VERSION} _macos_all"
95
+ cp " $EXTRACTED_FILES " " $CACHE_DIR /fleetctl/fleetctl_v${LATEST_VERSION} _macos_all/fleetctl"
96
+ chmod +x " $CACHE_DIR /fleetctl/fleetctl_v${LATEST_VERSION} _macos_all/fleetctl"
97
+
98
+ log " Copied possible binary to expected location"
99
+
100
+ # Try running AutoPkg again
101
+ log " Running AutoPkg recipe again with fixed path..."
102
+ AUTOPKG_OUTPUT=$( GITHUB_TOKEN=" $PACKAGE_AUTOMATION_TOKEN " autopkg run -vv com.github.jc0b.pkg.fleetctl)
103
+ log " AutoPkg Output (third attempt):"
104
+ echo " $AUTOPKG_OUTPUT "
105
+ else
106
+ log " Could not find any executable in extracted files!"
107
+ exit 1
108
+ fi
109
+ fi
110
+ fi
111
+
60
112
# Use the latest version we got from GitHub API
61
113
DETECTED_VERSION=" ${LATEST_VERSION} "
62
114
log " Using version: $DETECTED_VERSION "
63
115
64
116
# Find the created package in the correct location
65
- CACHE_DIR=" /Users/runner/Library/AutoPkg/Cache/com.github.jc0b.pkg.fleetctl"
66
117
PACKAGE_FILE=" $CACHE_DIR /fleetctl_v${DETECTED_VERSION} .pkg"
67
118
68
119
if [ ! -f " $PACKAGE_FILE " ]; then
69
120
log " Package not found at: $PACKAGE_FILE "
70
121
log " Searching for package in cache directory..."
71
122
PACKAGE_FILE=$( find " $CACHE_DIR " -name " fleetctl_v*.pkg" -type f)
72
123
if [ -z " $PACKAGE_FILE " ]; then
73
- log " No package file found! Directory contents:"
74
- ls -la " $CACHE_DIR "
75
- exit 1
124
+ # Manual package creation as a last resort
125
+ log " No package file found. Attempting manual package creation..."
126
+
127
+ # Create a basic package structure
128
+ PKG_ROOT=" $CACHE_DIR /pkg_root"
129
+ mkdir -p " $PKG_ROOT /usr/local/bin"
130
+
131
+ # Find any fleetctl binary
132
+ BINARY_PATH=$( find " $CACHE_DIR " -name " fleetctl" -type f | head -n 1)
133
+
134
+ if [ -n " $BINARY_PATH " ]; then
135
+ cp " $BINARY_PATH " " $PKG_ROOT /usr/local/bin/"
136
+ chmod +x " $PKG_ROOT /usr/local/bin/fleetctl"
137
+
138
+ # Create package
139
+ PACKAGE_FILE=" $CACHE_DIR /fleetctl_v${DETECTED_VERSION} .pkg"
140
+ pkgbuild --root " $PKG_ROOT " --identifier " com.fleetdm.fleetctl" --version " $DETECTED_VERSION " " $PACKAGE_FILE "
141
+
142
+ if [ $? -ne 0 ]; then
143
+ log " Manual package creation failed!"
144
+ ls -la " $CACHE_DIR "
145
+ exit 1
146
+ fi
147
+ else
148
+ log " No fleetctl binary found! Directory contents:"
149
+ ls -la " $CACHE_DIR "
150
+ exit 1
151
+ fi
76
152
fi
77
153
log " Found package at: $PACKAGE_FILE "
78
154
fi
@@ -183,4 +259,4 @@ log "Successfully uploaded package to release"
183
259
184
260
# Clean up
185
261
rm -f release.json
186
- defaults delete com.github.autopkg GITHUB_TOKEN
262
+ defaults delete com.github.autopkg GITHUB_TOKEN
0 commit comments