@@ -19,7 +19,6 @@ make_absolute () {
19
19
# Building
20
20
# ####################################################################
21
21
echo " Building Packaging.Linux..."
22
-
23
22
# Parse script arguments
24
23
for i in " $@ "
25
24
do
@@ -32,6 +31,10 @@ case "$i" in
32
31
VERSION=" ${i#* =} "
33
32
shift # past argument=value
34
33
;;
34
+ --install-from-source=* )
35
+ INSTALL_FROM_SOURCE=${i#* =}
36
+ shift # past argument=value
37
+ ;;
35
38
* )
36
39
# unknown option
37
40
;;
@@ -59,22 +62,28 @@ if [ -z "$VERSION" ]; then
59
62
die " --version was not set"
60
63
fi
61
64
62
- ARCH=" ` dpkg-architecture -q DEB_HOST_ARCH` "
63
- if test -z " $ARCH " ; then
64
- die " Could not determine host architecture!"
65
+ if [ $INSTALL_FROM_SOURCE = false ]; then
66
+ ARCH=" ` dpkg-architecture -q DEB_HOST_ARCH` "
67
+ if test -z " $ARCH " ; then
68
+ die " Could not determine host architecture!"
69
+ fi
65
70
fi
66
71
67
72
# Outputs
68
73
PAYLOAD=" $PROJ_OUT /payload/$CONFIGURATION "
69
74
SYMBOLOUT=" $PROJ_OUT /payload.sym/$CONFIGURATION "
70
75
71
- TAROUT=" $PROJ_OUT /tar/$CONFIGURATION "
72
- TARBALL=" $TAROUT /gcmcore-linux_$ARCH .$VERSION .tar.gz"
73
- SYMTARBALL=" $TAROUT /symbols-linux_$ARCH .$VERSION .tar.gz"
76
+ if [ $INSTALL_FROM_SOURCE = false ]; then
77
+ TAROUT=" $PROJ_OUT /tar/$CONFIGURATION "
78
+ TARBALL=" $TAROUT /gcmcore-linux_$ARCH .$VERSION .tar.gz"
79
+ SYMTARBALL=" $TAROUT /symbols-linux_$ARCH .$VERSION .tar.gz"
74
80
75
- DEBOUT=" $PROJ_OUT /deb/$CONFIGURATION "
76
- DEBROOT=" $DEBOUT /root"
77
- DEBPKG=" $DEBOUT /gcmcore-linux_$ARCH .$VERSION .deb"
81
+ DEBOUT=" $PROJ_OUT /deb/$CONFIGURATION "
82
+ DEBROOT=" $DEBOUT /root"
83
+ DEBPKG=" $DEBOUT /gcmcore-linux_$ARCH .$VERSION .deb"
84
+ else
85
+ INSTALL_LOCATION=" /usr/local"
86
+ fi
78
87
79
88
# Cleanup payload directory
80
89
if [ -d " $PAYLOAD " ]; then
@@ -89,7 +98,13 @@ if [ -d "$SYMBOLOUT" ]; then
89
98
fi
90
99
91
100
# Ensure directories exists
92
- mkdir -p " $PAYLOAD " " $SYMBOLOUT " " $DEBROOT "
101
+ mkdir -p " $PAYLOAD " " $SYMBOLOUT "
102
+
103
+ if [ $INSTALL_FROM_SOURCE = false ]; then
104
+ mkdir -p " $DEBROOT "
105
+ else
106
+ mkdir -p " $INSTALL_LOCATION "
107
+ fi
93
108
94
109
# Publish core application executables
95
110
echo " Publishing core application..."
@@ -135,40 +150,44 @@ mv "$PAYLOAD"/*.pdb "$SYMBOLOUT" || exit 1
135
150
echo " Build complete."
136
151
137
152
# ####################################################################
138
- # PACKING
153
+ # PACKING AND INSTALLING
139
154
# ####################################################################
140
- echo " Packing Packaging.Linux..."
141
- # Cleanup any old archive files
142
- if [ -e " $TAROUT " ]; then
143
- echo " Deleteing old archive '$TAROUT '..."
144
- rm " $TAROUT "
145
- fi
146
-
147
- # Ensure the parent directory for the archive exists
148
- mkdir -p " $TAROUT " || exit 1
149
-
150
155
# Set full read, write, execute permissions for owner and just read and execute permissions for group and other
151
156
echo " Setting file permissions..."
152
157
/bin/chmod -R 755 " $PAYLOAD " || exit 1
153
158
154
- # Build binaries tarball
155
- echo " Building binaries tarball..."
156
- pushd " $PAYLOAD "
157
- tar -czvf " $TARBALL " * || exit 1
158
- popd
159
-
160
- # Build symbols tarball
161
- echo " Building symbols tarball..."
162
- pushd " $SYMBOLOUT "
163
- tar -czvf " $SYMTARBALL " * || exit 1
164
- popd
165
-
166
- # Build .deb
167
- INSTALL_TO=" $DEBROOT /usr/local/share/gcm-core/"
168
- LINK_TO=" $DEBROOT /usr/local/bin/"
169
- mkdir -p " $DEBROOT /DEBIAN" " $INSTALL_TO " " $LINK_TO " || exit 1
159
+ if [ $INSTALL_FROM_SOURCE = false ]; then
160
+ echo " Packing Packaging.Linux..."
161
+ # Cleanup any old archive files
162
+ if [ -e " $TAROUT " ]; then
163
+ echo " Deleteing old archive '$TAROUT '..."
164
+ rm " $TAROUT "
165
+ fi
166
+
167
+ # Ensure the parent directory for the archive exists
168
+ mkdir -p " $TAROUT " || exit 1
169
+
170
+ # Build binaries tarball
171
+ echo " Building binaries tarball..."
172
+ pushd " $PAYLOAD "
173
+ tar -czvf " $TARBALL " * || exit 1
174
+ popd
175
+
176
+ # Build symbols tarball
177
+ echo " Building symbols tarball..."
178
+ pushd " $SYMBOLOUT "
179
+ tar -czvf " $SYMTARBALL " * || exit 1
180
+ popd
181
+
182
+ # Build .deb
183
+ INSTALL_TO=" $DEBROOT /usr/local/share/gcm-core/"
184
+ LINK_TO=" $DEBROOT /usr/bin/"
185
+ mkdir -p " $DEBROOT /DEBIAN" " $INSTALL_TO " " $LINK_TO " || exit 1
170
186
171
187
# make the debian control file
188
+ # this is purposefully not indented, see
189
+ # https://stackoverflow.com/questions/9349616/bash-eof-in-if-statement
190
+ # for details
172
191
cat > " $DEBROOT /DEBIAN/control" << EOF
173
192
Package: gcmcore
174
193
Version: $VERSION
@@ -183,13 +202,25 @@ Description: Cross Platform Git Credential Manager command line utility.
183
202
For more information see https://aka.ms/gcm
184
203
EOF
185
204
205
+ dpkg-deb --build " $DEBROOT " " $DEBPKG " || exit 1
206
+ else
207
+ echo " Installing..."
208
+
209
+ # Install directories
210
+ INSTALL_TO=" $INSTALL_LOCATION /share/gcm-core/"
211
+ LINK_TO=" $INSTALL_LOCATION /bin/"
212
+ MESSAGE=" Install complete."
213
+ fi
214
+
215
+ mkdir -p " $INSTALL_TO " " $LINK_TO "
216
+
186
217
# Copy all binaries and shared libraries to target installation location
187
218
cp -R " $PAYLOAD " /* " $INSTALL_TO " || exit 1
188
219
189
220
# Create symlink
190
- ln -s -r " $INSTALL_TO /git-credential-manager-core" \
191
- " $LINK_TO /git-credential-manager-core" || exit 1
192
-
193
- dpkg-deb --build " $DEBROOT " " $DEBPKG " || exit 1
221
+ if [ ! -f " $LINK_TO /git-credential-manager-core" ] ; then
222
+ ln -s -r " $INSTALL_TO /git-credential-manager-core" \
223
+ " $LINK_TO /git-credential-manager-core " || exit 1
224
+ fi
194
225
195
- echo " Pack complete. "
226
+ echo $MESSAGE
0 commit comments