diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..39bcab0 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,34 @@ +name: build and release + +on: + push: + branches: + - main + schedule: + - cron: '0 1 * * *' + +jobs: + build-release: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Get Version + run: | + ./check.sh + echo "tag=$(cat tag)" >> $GITHUB_ENV + + - name: Build + if: ${{ env.tag != '0' }} + run: ./build.sh + + - name: Release + uses: softprops/action-gh-release@v2 + if: ${{ env.tag != '0' }} + with: + tag_name: v${{ env.tag }} + files: | + *.deb + Packages + Release \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..081ff8b --- /dev/null +++ b/LICENSE @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) 2024 wcbing + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..e5b77f7 --- /dev/null +++ b/README.md @@ -0,0 +1,12 @@ +自行打包的 [dufs](https://github.com/sigoden/dufs),供 Debian 或其他发行版上使用。 + +Self-packaged [dufs](https://github.com/sigoden/dufs) for use on Debian or other distro. + + +## Usage/用法 + +```sh +echo "deb [trusted=yes] https://github.com/wcbing/dufs-debs/releases/latest/download ./" | + sudo tee /etc/apt/sources.list.d/dufs.list +sudo apt update +``` \ No newline at end of file diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..d70db5e --- /dev/null +++ b/build.sh @@ -0,0 +1,42 @@ +#!/bin/sh + +PACKAGE="dufs" +REPO="sigoden/dufs" + +VERSION="$(cat tag)" + +ARCH="amd64 arm64" +AMD64_FILENAME="dufs-v$VERSION-x86_64-unknown-linux-musl.tar.gz" +ARM64_FILENAME="dufs-v$VERSION-aarch64-unknown-linux-musl.tar.gz" + +get_url_by_arch() { + case $1 in + "amd64") echo "https://github.com/$REPO/releases/latest/download/$AMD64_FILENAME" ;; + "arm64") echo "https://github.com/$REPO/releases/latest/download/$ARM64_FILENAME" ;; + esac +} + +build() { + # Prepare + BASE_DIR="$PACKAGE"_"$VERSION"-1_"$1" + cp -r templates "$BASE_DIR" + sed -i "s/Architecture: arch/Architecture: $1/" "$BASE_DIR/DEBIAN/control" + sed -i "s/Version: version/Version: $VERSION-1/" "$BASE_DIR/DEBIAN/control" + # Download and move file + curl -sLo "$BASE_DIR/usr/share/doc/dufs/CHANGELOG.md" "https://raw.githubusercontent.com/sigoden/dufs/refs/heads/main/CHANGELOG.md" + curl -sLo "$PACKAGE-$1.tar.gz" "$(get_url_by_arch $1)" + tar -xzf "$PACKAGE-$1.tar.gz" + mv "$PACKAGE" "$BASE_DIR/usr/bin/$PACKAGE" + chmod 755 "$BASE_DIR/usr/bin/$PACKAGE" + # Build + dpkg-deb --build --root-owner-group "$BASE_DIR" +} + +for i in $ARCH; do + echo "Building $i package..." + build "$i" +done + +# Create repo files +apt-ftparchive packages . > Packages +apt-ftparchive release . > Release diff --git a/check.sh b/check.sh new file mode 100755 index 0000000..02abb9c --- /dev/null +++ b/check.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +REPO="sigoden/dufs" +LOCAL_REPO="wcbing-build/dufs-debs" + +get_github_latest_tag() { + curl -sI "https://github.com/$1/releases/latest" | grep "releases/tag" | + sed -E 's#.*/releases/tag/[vV]*([^_\r]*).*#\1#' +} + +LOCAL_VERSION=$(get_github_latest_tag "$LOCAL_REPO") +if [ -z "$LOCAL_VERSION" ]; then + echo "Error: Can't get version tag from $LOCAL_REPO." + LOCAL_VERSION="0" +fi + +VERSION=$(get_github_latest_tag "$REPO") +if [ -z "$VERSION" ]; then + echo "Error: Can't get version tag from $REPO." + echo 0 > tag + exit 1 +elif [ "$LOCAL_VERSION" = "$VERSION" ]; then + echo "No update." + echo 0 > tag + exit 0 +fi + +echo "$VERSION" > tag +echo "Update to $VERSION from $LOCAL_VERSION." diff --git a/templates/DEBIAN/control b/templates/DEBIAN/control new file mode 100644 index 0000000..67ce4f5 --- /dev/null +++ b/templates/DEBIAN/control @@ -0,0 +1,9 @@ +Package: dufs +Version: version +Architecture: arch +Maintainer: wcbing +Section: web +Priority: optional +Homepage: https://github.com/sigoden/dufs +Description: A file server that supports static serving, uploading, + searching, accessing control, webdav... diff --git a/templates/usr/bin/dufs b/templates/usr/bin/dufs new file mode 100644 index 0000000..645b94d --- /dev/null +++ b/templates/usr/bin/dufs @@ -0,0 +1,2 @@ +This file will be replaced. +这个文件将会被替换。 \ No newline at end of file diff --git a/templates/usr/share/doc/dufs/CHANGELOG.md b/templates/usr/share/doc/dufs/CHANGELOG.md new file mode 100644 index 0000000..645b94d --- /dev/null +++ b/templates/usr/share/doc/dufs/CHANGELOG.md @@ -0,0 +1,2 @@ +This file will be replaced. +这个文件将会被替换。 \ No newline at end of file diff --git a/templates/usr/share/doc/dufs/copyright b/templates/usr/share/doc/dufs/copyright new file mode 100644 index 0000000..e4ebf80 --- /dev/null +++ b/templates/usr/share/doc/dufs/copyright @@ -0,0 +1,34 @@ +format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: dufs +Source: https://github.com/sigoden/dufs/releases + +Files: * +Copyright: 2022, sigoden +License: Apache-2.0 + +Files: DEBIAN/* +Copyright: 2024, wcbing +License: MIT + +License: Apache-2.0 + Debian systems provide the Apache 2.0 license in + /usr/share/common-licenses/Apache-2.0 + +License: MIT + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + . + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + . + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE.