-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Expand file tree
/
Copy pathpack.sh
More file actions
executable file
·131 lines (111 loc) · 3.14 KB
/
pack.sh
File metadata and controls
executable file
·131 lines (111 loc) · 3.14 KB
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
#!/bin/bash
set -eu
die () {
echo "$*" >&2
exit 1
}
# Directories
THISDIR="$( cd "$(dirname "$0")" || exit 1 ; pwd -P )"
ROOT="$( cd "$THISDIR"/../../.. || exit 1 ; pwd -P )"
SRC="$ROOT/src"
OUT="$ROOT/out"
PROJ_OUT="$OUT/linux/Packaging.Linux"
# Parse script arguments
for i in "$@"
do
case "$i" in
--version=*)
VERSION="${i#*=}"
shift # past argument=value
;;
--payload=*)
PAYLOAD="${i#*=}"
shift # past argument=value
;;
--symbols=*)
SYMBOLS="${i#*=}"
shift # past argument=value
;;
--configuration=*)
CONFIGURATION="${i#*=}"
shift # past argument=value
;;
*)
# unknown option
;;
esac
done
# Perform pre-execution checks
CONFIGURATION="${CONFIGURATION:=Debug}"
if [ -z "$VERSION" ]; then
die "--version was not set"
fi
if [ -z "$PAYLOAD" ]; then
die "--payload was not set"
elif [ ! -d "$PAYLOAD" ]; then
die "Could not find '$PAYLOAD'. Did you run layout.sh first?"
fi
if [ -z "$SYMBOLS" ]; then
die "--symbols was not set"
fi
ARCH="$(dpkg-architecture -q DEB_HOST_ARCH)"
if test -z "$ARCH"; then
die "Could not determine host architecture!"
fi
TAROUT="$PROJ_OUT/$CONFIGURATION/tar/"
TARBALL="$TAROUT/gcm-linux_$ARCH.$VERSION.tar.gz"
SYMTARBALL="$TAROUT/gcm-linux_$ARCH.$VERSION-symbols.tar.gz"
DEBOUT="$PROJ_OUT/$CONFIGURATION/deb"
DEBROOT="$DEBOUT/root"
DEBPKG="$DEBOUT/gcm-linux_$ARCH.$VERSION.deb"
mkdir -p "$DEBROOT"
# Set full read, write, execute permissions for owner and just read and execute permissions for group and other
echo "Setting file permissions..."
/bin/chmod -R 755 "$PAYLOAD" || exit 1
echo "Packing Packaging.Linux..."
# Cleanup any old archive files
if [ -e "$TAROUT" ]; then
echo "Deleteing old archive '$TAROUT'..."
rm -r "$TAROUT"
fi
# Ensure the parent directory for the archive exists
mkdir -p "$TAROUT" || exit 1
# Build binaries tarball
echo "Building binaries tarball..."
pushd "$PAYLOAD"
tar -czvf "$TARBALL" ./* || exit 1
popd
# Build symbols tarball
echo "Building symbols tarball..."
pushd "$SYMBOLS"
tar -czvf "$SYMTARBALL" ./* || exit 1
popd
# Build .deb
INSTALL_TO="$DEBROOT/usr/local/share/gcm-core/"
LINK_TO="$DEBROOT/usr/local/bin/"
mkdir -p "$DEBROOT/DEBIAN" "$INSTALL_TO" "$LINK_TO" || exit 1
# make the debian control file
# this is purposefully not indented, see
# https://stackoverflow.com/questions/9349616/bash-eof-in-if-statement
# for details
cat >"$DEBROOT/DEBIAN/control" <<EOF
Package: gcm
Version: $VERSION
Section: vcs
Priority: optional
Architecture: $ARCH
Depends:
Maintainer: GCM <gitfundamentals@github.com>
Description: Cross Platform Git Credential Manager command line utility.
GCM supports authentication with a number of Git hosting providers
including GitHub, BitBucket, and Azure DevOps.
For more information see https://aka.ms/gcm
EOF
# Copy all binaries and shared libraries to target installation location
cp -R "$PAYLOAD"/* "$INSTALL_TO" || exit 1
# Create symlink
if [ ! -f "$LINK_TO/git-credential-manager" ]; then
ln -s -r "$INSTALL_TO/git-credential-manager" \
"$LINK_TO/git-credential-manager" || exit 1
fi
dpkg-deb -Zxz --root-owner-group --build "$DEBROOT" "$DEBPKG" || exit 1