File: package

package info (click to toggle)
hub 2.14.2~ds1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,376 kB
  • sloc: sh: 1,049; ruby: 857; makefile: 89
file content (65 lines) | stat: -rwxr-xr-x 1,442 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/env bash
# Usage: script/package <os> <arch> <version>
#
# Packages the project as a release asset and prints the archive's filename.
set -e

os="${1?}"
arch="${2?}"
version="${3?}"

release="hub-${os}-${arch}-${version}"

case "$os" in
  darwin | freebsd | linux | netbsd | openbsd | solaris | windows ) ;;
  * ) echo "unsupported OS: $os" >&2; exit 1 ;;
esac

case "$arch" in
  386 | amd64 | arm | arm64 ) ;;
  * ) echo "unsupported arch: $arch" >&2; exit 1 ;;
esac

export GOOS="$os"
export GOARCH="$arch"

tmpdir="tmp/${release}"
rm -rf "$tmpdir"

exename="${tmpdir}/bin/hub"
[ "$os" != "windows" ] || exename="${exename}.exe"
mkdir -p "${exename%/*}"
script/build -o "$exename"

crlf() {
  sed $'s/$/\r/' "$1" > "$2"
}

if [ "$os" = "windows" ]; then
  crlf README.md "${tmpdir}/README.txt"
  crlf LICENSE "${tmpdir}/LICENSE.txt"
  for man in share/doc/*/*.html; do
    mkdir -p "${tmpdir}/${man%/*}"
    cp "$man" "${tmpdir}/${man}"
  done
  crlf script/install.bat "${tmpdir}/install.bat"
else
  cp -R README.md LICENSE etc share "$tmpdir"
  rm -rf "${tmpdir}/share/man/"*/*.md
  cp script/install.sh "${tmpdir}/install"
  chmod +x "${tmpdir}/install"
fi

if [ "$os" = "windows" ]; then
  file="${PWD}/${tmpdir}.zip"
  rm -f "$file"
  pushd "$tmpdir" >/dev/null
  zip -r "$file" * >/dev/null
else
  file="${PWD}/${tmpdir}.tgz"
  rm -f "$file"
  pushd "${tmpdir%/*}" >/dev/null
  tar -czf "$file" "$release"
fi

echo "$file"