-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·66 lines (54 loc) · 1.92 KB
/
build.sh
File metadata and controls
executable file
·66 lines (54 loc) · 1.92 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
#!/bin/sh
set -e
# Check and extract version number
[ $# != 1 ] && echo "Usage: $0 <latest_releases_tag>" && exit 1
VERSION=$(echo "$1" | sed -n 's|[^0-9]*\([^_]*\).*|\1|p') && test "$VERSION"
PACKAGE=lazydocker
REPO=jesseduffield/lazydocker
ARCH_LIST="amd64 arm64"
AMD64_FILENAME=lazydocker_"$VERSION"_Linux_x86_64.tar.gz
ARM64_FILENAME=lazydocker_"$VERSION"_Linux_arm64.tar.gz
prepare() {
mkdir -p output tmp
curl -fs https://api.github.com/repos/$REPO/releases/latest | jq -r '.body' | gzip > tmp/changelog.gz
}
build() {
BASE_DIR="$PACKAGE"_"$ARCH" && rm -rf "$BASE_DIR"
install -D templates/copyright -t "$BASE_DIR/usr/share/doc/$PACKAGE"
install -D tmp/changelog.gz -t "$BASE_DIR/usr/share/doc/$PACKAGE"
# Download and move file
curl -fsLo "tmp/$PACKAGE-$ARCH.tar.gz" "$(get_url_by_arch "$ARCH")"
TMPDIR=$(mktemp -dp .)
tar -xf "tmp/$PACKAGE-$ARCH.tar.gz" -C "$TMPDIR"
install -D -m 755 -t "$BASE_DIR/usr/bin" "$TMPDIR/lazydocker" && rm -rf "$TMPDIR"
# Package deb
mkdir -p "$BASE_DIR/DEBIAN"
SIZE=$(du -sk "$BASE_DIR"/usr | cut -f1)
echo "Package: $PACKAGE
Version: $VERSION+1
Architecture: $ARCH
Installed-Size: $SIZE
Maintainer: wcbing <i@wcbing.top>
Section: utils
Priority: optional
Homepage: https://github.com/$REPO
Description: The lazier way to manage everything docker
A simple terminal UI for both docker and docker-compose,
written in Go with the gocui library.
" > "$BASE_DIR/DEBIAN/control"
dpkg-deb -b --root-owner-group -Z xz "$BASE_DIR" output
}
get_url_by_arch() {
DOWNLOAD_PREFIX="https://github.com/$REPO/releases/latest/download"
case $1 in
"amd64") echo "$DOWNLOAD_PREFIX/$AMD64_FILENAME" ;;
"arm64") echo "$DOWNLOAD_PREFIX/$ARM64_FILENAME" ;;
esac
}
prepare
for ARCH in $ARCH_LIST; do
echo "Building $ARCH package..."
build
done
# Create repo files
cd output && apt-ftparchive packages . > Packages && apt-ftparchive release . > Release