|
1 | 1 | #!/bin/sh |
| 2 | +set -e |
2 | 3 |
|
3 | | -PACKAGE="neovide" |
4 | | -REPO="neovide/neovide" |
| 4 | +# Check and extract version number |
| 5 | +[ $# != 1 ] && echo "Usage: $0 <latest_releases_tag>" && exit 1 |
| 6 | +VERSION=$(echo "$1" | sed -n 's|[^0-9]*\([^_]*\).*|\1|p') && test "$VERSION" |
5 | 7 |
|
6 | | -VERSION="$(cat tag)" |
| 8 | +PACKAGE=neovide |
| 9 | +REPO=neovide/neovide |
7 | 10 |
|
8 | | -ARCH="amd64" |
9 | | -AMD64_FILENAME="neovide-linux-x86_64.tar.gz" |
10 | | -ARM64_FILENAME="" |
| 11 | +ARCH_LIST="amd64" |
| 12 | +AMD64_FILENAME=neovide-linux-x86_64.tar.gz |
11 | 13 |
|
12 | | -get_url_by_arch() { |
13 | | - case $1 in |
14 | | - "amd64") echo "https://github.com/$REPO/releases/latest/download/$AMD64_FILENAME" ;; |
15 | | - "arm64") echo "https://github.com/$REPO/releases/latest/download/$ARM64_FILENAME" ;; |
16 | | - esac |
| 14 | +prepare() { |
| 15 | + mkdir -p output tmp |
| 16 | + curl -fs "https://raw.githubusercontent.com/sigoden/dufs/refs/heads/main/CHANGELOG.md" | gzip > tmp/changelog.gz |
| 17 | + curl -fsLo "tmp/$PACKAGE.png" https://github.com/neovide/neovide/raw/refs/heads/main/assets/neovide.svg |
| 18 | + curl -fsLo "tmp/$PACKAGE.desktop" https://github.com/neovide/neovide/raw/refs/heads/main/assets/neovide.desktop |
| 19 | + sed -i "s/Icon=neovide/Icon=$PACKAGE/" "tmp/$PACKAGE.desktop" |
| 20 | + sed -i "s/Exec=neovide/Exec=$PACKAGE/" "tmp/$PACKAGE.desktop" |
17 | 21 | } |
18 | 22 |
|
19 | 23 | build() { |
20 | | - # Prepare |
21 | | - BASE_DIR="$PACKAGE"_"$VERSION"-1_"$1" |
22 | | - cp -r templates "$BASE_DIR" |
23 | | - sed -i "s/Architecture: arch/Architecture: $1/" "$BASE_DIR/DEBIAN/control" |
24 | | - sed -i "s/Version: version/Version: $VERSION-1/" "$BASE_DIR/DEBIAN/control" |
| 24 | + BASE_DIR="$PACKAGE"_"$ARCH" && rm -rf "$BASE_DIR" |
| 25 | + install -D templates/copyright -t "$BASE_DIR/usr/share/doc/$PACKAGE" |
| 26 | + install -D tmp/changelog.gz -t "$BASE_DIR/usr/share/doc/$PACKAGE" |
| 27 | + |
25 | 28 | # Download and move file |
26 | | - curl https://api.github.com/repos/$REPO/releases/latest | jq -r '.body' > $BASE_DIR/usr/share/doc/$PACKAGE/CHANGELOG.md |
27 | | - curl -Lo $BASE_DIR/usr/share/applications/neovide.desktop https://github.com/neovide/neovide/raw/refs/heads/main/assets/neovide.desktop |
28 | | - curl -Lo $BASE_DIR/usr/share/icons/hicolor/256x256/apps/neovide.png https://github.com/neovide/neovide/raw/main/assets/neovide-256x256.png |
29 | | - curl -sLo "$PACKAGE-$VERSION-$1.tar.gz" "$(get_url_by_arch $1)" |
30 | | - tar -xzf "$PACKAGE-$VERSION-$1.tar.gz" |
31 | | - mv "$PACKAGE" "$BASE_DIR/usr/bin/$PACKAGE" |
32 | | - chmod 755 "$BASE_DIR/usr/bin/$PACKAGE" |
33 | | - # Build |
34 | | - dpkg-deb --build --root-owner-group -Z xz "$BASE_DIR" |
| 29 | + curl -fsLo "tmp/$PACKAGE-$ARCH.tar.gz" "$(get_url_by_arch "$ARCH")" |
| 30 | + tar -xf "tmp/$PACKAGE-$ARCH.tar.gz" |
| 31 | + install -D -m 755 -t "$BASE_DIR/usr/bin" neovide && rm neovide |
| 32 | + |
| 33 | + install -D "tmp/$PACKAGE.desktop" -t "$BASE_DIR/usr/share/applications" |
| 34 | + install -D "tmp/$PACKAGE.png" -t "$BASE_DIR/usr/share/icons/hicolor/scalable/apps" |
| 35 | + |
| 36 | + # Package deb |
| 37 | + mkdir -p "$BASE_DIR/DEBIAN" |
| 38 | + SIZE=$(du -sk "$BASE_DIR"/usr | cut -f1) |
| 39 | + echo "Package: $PACKAGE |
| 40 | +Version: $VERSION-1 |
| 41 | +Architecture: $ARCH |
| 42 | +Installed-Size: $SIZE |
| 43 | +Maintainer: wcbing <i@wcbing.top> |
| 44 | +Section: editors |
| 45 | +Priority: optional |
| 46 | +Depends: neovim |
| 47 | +Homepage: https://github.com/$REPO |
| 48 | +Description: This is a simple graphical user interface for Neovim |
| 49 | + (an aggressively refactored and updated Vim editor). |
| 50 | + Where possible there are some graphical improvements, but functionally |
| 51 | + it should act like the terminal UI. |
| 52 | + To checkout all the cool features, installation instructions, |
| 53 | + configuration settings and much more, head on over to neovide.dev. |
| 54 | +" > "$BASE_DIR/DEBIAN/control" |
| 55 | + |
| 56 | + dpkg-deb -b --root-owner-group -Z xz "$BASE_DIR" output |
35 | 57 | } |
36 | 58 |
|
37 | | -for i in $ARCH; do |
38 | | - echo "Building $i package..." |
39 | | - build "$i" |
| 59 | +get_url_by_arch() { |
| 60 | + DOWNLOAD_PREFIX="https://github.com/$REPO/releases/latest/download" |
| 61 | + case $1 in |
| 62 | + "amd64") echo "$DOWNLOAD_PREFIX/$AMD64_FILENAME" ;; |
| 63 | + esac |
| 64 | +} |
| 65 | + |
| 66 | +prepare |
| 67 | + |
| 68 | +for ARCH in $ARCH_LIST; do |
| 69 | + echo "Building $ARCH package..." |
| 70 | + build |
40 | 71 | done |
41 | 72 |
|
42 | 73 | # Create repo files |
43 | | -apt-ftparchive packages . > Packages |
44 | | -apt-ftparchive release . > Release |
| 74 | +cd output && apt-ftparchive packages . > Packages && apt-ftparchive release . > Release |
0 commit comments