forked from bitly/oauth2_proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake-deb.sh
executable file
·48 lines (40 loc) · 1.49 KB
/
make-deb.sh
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
#!/bin/bash -e
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PACKAGE=oauth2-proxy
VERSION=2.2.$(git log -n1 --format="%ct")
DEST="deb-$PACKAGE-$VERSION"
DEB="$PACKAGE-$VERSION.deb"
OS=${1:-$(go env GOOS)}
ARCH=${2:-$(go env GOARCH)}
echo "=============== Build Config ================="
echo "PACKAGE: $PACKAGE"
echo "VERSION: $VERSION"
echo "DEST: $DEST"
echo "DEB: $DEB"
echo "OS: $OS"
echo "ARCH: $ARCH"
echo "=============== Running tests ================="
#$DIR/test.sh
echo "not running tests"
echo "=============== Building ================="
BUILD=$(mktemp -d ${TMPDIR:-/tmp}/oauth2_proxy.XXXXXX)
GOOS=$OS GOARCH=$ARCH CGO_ENABLED=0 \
go build -ldflags="-s -w" -o $BUILD/oauth2-proxy
echo "=============== Copying Package Files ==================="
rm -rf $DEST
mkdir $DEST && cp -a build/$PACKAGE/* $DEST
mkdir -p $DEST/usr/share/flipkart/$PACKAGE/
cp $BUILD/oauth2-proxy $DEST/usr/share/flipkart/$PACKAGE/
echo "=============== Creating DEB ====================="
sed -i -e "s/_PACKAGE_/$PACKAGE/g" $DEST/DEBIAN/control
sed -i -e "s/_VERSION_/$VERSION/g" $DEST/DEBIAN/control
sed -i -e "s/_ARCH_/$ARCH/g" $DEST/DEBIAN/control
fakeroot dpkg -b $DEST $DEB
echo "=================== Uploading to repo-svc repo $repo ========================"
reposervice --host $host --port $port pubrepo --repo $repo --appkey secret --debs $DEB
echo "Done!"
echo "=============== Cleaning Up ======================"
rm -rf /tmp/$PACKAGE-latest.deb
cp $DEB /tmp/$PACKAGE-latest.deb
rm -rf $BUILD
rm -rf $DEST $DEB