Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
wcbing committed Dec 9, 2024
0 parents commit 4588e25
Show file tree
Hide file tree
Showing 9 changed files with 173 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -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.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
```
42 changes: 42 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -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
29 changes: 29 additions & 0 deletions check.sh
Original file line number Diff line number Diff line change
@@ -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."
9 changes: 9 additions & 0 deletions templates/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Package: dufs
Version: version
Architecture: arch
Maintainer: wcbing <[email protected]>
Section: web
Priority: optional
Homepage: https://github.com/sigoden/dufs
Description: A file server that supports static serving, uploading,
searching, accessing control, webdav...
2 changes: 2 additions & 0 deletions templates/usr/bin/dufs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This file will be replaced.
这个文件将会被替换。
2 changes: 2 additions & 0 deletions templates/usr/share/doc/dufs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This file will be replaced.
这个文件将会被替换。
34 changes: 34 additions & 0 deletions templates/usr/share/doc/dufs/copyright
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
License: Apache-2.0

Files: DEBIAN/*
Copyright: 2024, wcbing <[email protected]>
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.

0 comments on commit 4588e25

Please sign in to comment.