Files
f-denkena 9b5356d0ab Add Windows one-click zip and Debian timer/tray packaging
Bundles forked rclone + rclone-bisyncd. Does not vendor dist binaries.
2026-09-10 00:24:07 +02:00

75 lines
2.9 KiB
Bash
Executable File

#!/bin/sh
set -eu
ROOT="$(CDPATH= cd -- "$(dirname "$0")" && pwd)"
DIST="$ROOT/dist"
SRC_RCLONE="${RCLONE_SRC:-$ROOT/../rclone}"
export CGO_ENABLED=0
rm -rf "$DIST"
mkdir -p "$DIST/win" "$DIST/deb-root"
echo "==> rclone linux amd64"
( cd "$SRC_RCLONE" && go build -trimpath -o "$DIST/rclone-linux-amd64" )
echo "==> rclone windows amd64"
( cd "$SRC_RCLONE" && GOOS=windows GOARCH=amd64 go build -trimpath -o "$DIST/rclone.exe" )
echo "==> rclone-bisyncd"
( cd "$ROOT/cmd/rclone-bisyncd" && go build -trimpath -o "$DIST/rclone-bisyncd-linux-amd64" )
( cd "$ROOT/cmd/rclone-bisyncd" && GOOS=windows GOARCH=amd64 go build -trimpath -o "$DIST/rclone-bisyncd.exe" )
echo "==> windows zip"
WIN="$DIST/rclone-dropbox-bisync-windows-amd64"
rm -rf "$WIN"
mkdir -p "$WIN"
cp "$DIST/rclone.exe" "$DIST/rclone-bisyncd.exe" \
"$ROOT/windows/Install.ps1" "$ROOT/windows/Install.cmd" "$ROOT/windows/tray.ps1" \
"$ROOT/windows/config.example.json" "$WIN/"
( cd "$DIST" && zip -r -q rclone-dropbox-bisync-windows-amd64.zip rclone-dropbox-bisync-windows-amd64 )
echo "==> deb"
DEB="$DIST/deb-root"
mkdir -p \
"$DEB/opt/rclone-dropbox-bisync/bin" \
"$DEB/usr/lib/systemd/user" \
"$DEB/etc/xdg/autostart" \
"$DEB/usr/share/doc/rclone-dropbox-bisync" \
"$DEB/DEBIAN"
cp "$DIST/rclone-linux-amd64" "$DEB/opt/rclone-dropbox-bisync/bin/rclone"
cp "$DIST/rclone-bisyncd-linux-amd64" "$DEB/opt/rclone-dropbox-bisync/bin/rclone-bisyncd"
cp "$ROOT/linux/session-start.sh" "$DEB/opt/rclone-dropbox-bisync/bin/session-start.sh"
chmod 755 "$DEB/opt/rclone-dropbox-bisync/bin/"*
cp "$ROOT/linux/systemd/rclone-bisync.service" "$ROOT/linux/systemd/rclone-bisync.timer" \
"$DEB/usr/lib/systemd/user/"
cp "$ROOT/linux/autostart/rclone-bisync-tray.desktop" "$DEB/etc/xdg/autostart/"
cp "$ROOT/config.example.json" "$DEB/usr/share/doc/rclone-dropbox-bisync/"
cat > "$DEB/DEBIAN/postinst" <<'EOF'
#!/bin/sh
set -e
if [ -n "${SUDO_USER:-}" ]; then
uhome=$(getent passwd "$SUDO_USER" | cut -d: -f6)
mkdir -p "$uhome/.config/rclone-dropbox-bisync"
if [ ! -f "$uhome/.config/rclone-dropbox-bisync/config.json" ]; then
cp /usr/share/doc/rclone-dropbox-bisync/config.example.json \
"$uhome/.config/rclone-dropbox-bisync/config.json"
chown -R "$SUDO_USER:" "$uhome/.config/rclone-dropbox-bisync"
fi
fi
exit 0
EOF
chmod 755 "$DEB/DEBIAN/postinst"
cp "$ROOT/linux/control" "$DEB/DEBIAN/control"
# Installed-Size in KiB
size=$(du -sk "$DEB" | awk '{print $1}')
echo "Installed-Size: $size" >> "$DEB/DEBIAN/control"
# ar-based .deb (no dpkg-deb on this host)
pkg="$DIST/deb-pkg"
rm -rf "$pkg"
mkdir -p "$pkg/data" "$pkg"
( cd "$DEB" && tar --owner=0 --group=0 -cJf "$pkg/data.tar.xz" \
opt usr etc )
( cd "$DEB/DEBIAN" && tar --owner=0 --group=0 -czf "$pkg/control.tar.gz" . )
echo 2.0 > "$pkg/debian-binary"
( cd "$pkg" && ar r "$DIST/rclone-dropbox-bisync_1.0.0_amd64.deb" \
debian-binary control.tar.gz data.tar.xz )
ls -lh "$DIST"/*.deb "$DIST"/*.zip "$DIST"/rclone*