🚀 Sync 2026-11-14 15:02:09

This commit is contained in:
github-actions[bot] committed 2026-11-14 15:02:09 +08:00
1 parent 90f27ab347
commit 9f5777add1
44 files changed
+3970 -5

No files matched your search

+82
View File
@@ -0,0 +1,82 @@
#!/bin/sh
# Build dist/luci-theme-7dollar-<version>.apk for OpenWrt 25.x (apk-tools v3).
# Needs apk-tools v3 (`apk mkpkg`, set APK=/path/to/apk.static) and runs as root so files are
# owned by root; .github/workflows/apk.yml does both.
set -eu
cd "$(dirname "$0")/.."
NAME=luci-theme-7dollar
VER=$(sed -n 's/^PKG_VERSION:=//p' Makefile)-r$(sed -n 's/^PKG_RELEASE:=//p' Makefile)
OUT=dist/$NAME-$VER.apk
# Stamp files with the last commit that touched the package, so rebuilding unchanged sources
# gives a byte-identical apk (CI then has nothing to commit).
export SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH:-$(git -c safe.directory="$PWD" log -1 --format=%ct -- Makefile htdocs ucode root scripts/stage.sh scripts/build-apk.sh)}
TMP=$(mktemp -d)
trap 'rm -rf "$TMP"' EXIT
D=$TMP/data S=$TMP/scripts
sh scripts/stage.sh "$D"
mkdir -p "$D/lib/apk/packages" "$S"
( cd "$D" && find . \( -type f -o -type l \) | sed 's/^\.//' | sort ) > "$TMP/list"
mv "$TMP/list" "$D/lib/apk/packages/$NAME.list"
echo /etc/config/7dollar > "$D/lib/apk/packages/$NAME.conffiles"
echo "/etc/config/7dollar $(sha256sum "$D/etc/config/7dollar" | cut -d' ' -f1)" > "$D/lib/apk/packages/$NAME.conffiles_static"
# Same maintainer scripts OpenWrt's package-pack.mk generates for apk packages.
cat > "$S/post-install" <<SH
#!/bin/sh
[ "\${IPKG_NO_SCRIPT}" = "1" ] && exit 0
[ -s "\${IPKG_INSTROOT}/lib/functions.sh" ] || exit 0
. \${IPKG_INSTROOT}/lib/functions.sh
export root="\${IPKG_INSTROOT}"
export pkgname="$NAME"
default_postinst
[ -n "\${IPKG_INSTROOT}" ] || {
rm -rf /tmp/luci-indexcache* /tmp/luci-modulecache/
/etc/init.d/rpcd reload >/dev/null 2>&1
}
exit 0
SH
{ echo '#!/bin/sh'; echo 'export PKG_UPGRADE=1'; sed 1d "$S/post-install"; } > "$S/post-upgrade"
cat > "$S/pre-deinstall" <<SH
#!/bin/sh
[ -s "\${IPKG_INSTROOT}/lib/functions.sh" ] || exit 0
. \${IPKG_INSTROOT}/lib/functions.sh
export root="\${IPKG_INSTROOT}"
export pkgname="$NAME"
default_prerm
SH
cat > "$S/post-deinstall" <<'SH'
#!/bin/sh
[ -n "${IPKG_INSTROOT}" ] || {
uci -q delete luci.themes.7Dollar
[ "$(uci -q get luci.main.mediaurlbase)" = "/luci-static/7dollar" ] && \
uci -q set luci.main.mediaurlbase=/luci-static/bootstrap
uci commit luci
rm -rf /tmp/luci-indexcache* /tmp/luci-modulecache/
}
exit 0
SH
chmod 755 "$S"/*
find "$D" "$S" -exec touch -h -d "@$SOURCE_DATE_EPOCH" {} +
mkdir -p dist
rm -f dist/$NAME-*.apk
${APK:-apk} mkpkg \
--info "name:$NAME" \
--info "version:$VER" \
--info "description:7Dollar, an elegant, lightweight LuCI theme" \
--info "arch:noarch" \
--info "license:Apache-2.0" \
--info "origin:$NAME" \
--info "url:https://github.com/itsmaiGe/luci-theme-7dollar" \
--info "maintainer:itsmaiGe" \
--info "depends:libc luci-base" \
--script "post-install:$S/post-install" \
--script "post-upgrade:$S/post-upgrade" \
--script "pre-deinstall:$S/pre-deinstall" \
--script "post-deinstall:$S/post-deinstall" \
--files "$D" \
--output "$OUT"
basename "$OUT" > dist/latest-apk.txt
echo "$OUT ($(wc -c < "$OUT" | tr -d ' ') bytes)"
+81
View File
@@ -0,0 +1,81 @@
#!/usr/bin/env bash
# Build dist/luci-theme-7dollar_<version>_all.ipk without an OpenWrt SDK.
# The result is a standard opkg package (tar.gz flavour, like ipkg-build).
set -euo pipefail
cd "$(dirname "$0")/.."
VER=$(sed -n 's/^PKG_VERSION:=//p' Makefile)-r$(sed -n 's/^PKG_RELEASE:=//p' Makefile)
NAME=luci-theme-7dollar
OUT=dist/${NAME}_${VER}_all.ipk
TMP=$(mktemp -d)
trap 'rm -rf "$TMP"' EXIT
export COPYFILE_DISABLE=1 # no macOS ._ files
TAR=tar; command -v gtar >/dev/null && TAR=gtar
own() { if $TAR --version | grep -q GNU; then echo "--format=gnu --owner=0 --group=0 --numeric-owner"; else echo "--format ustar --no-xattrs --no-mac-metadata --uid 0 --gid 0 --uname root --gname root"; fi; }
# ---- data ----
D=$TMP/data
sh scripts/check-jsmin.sh
sh scripts/stage.sh "$D"
SIZE=$(du -sk "$D" | cut -f1)
# ---- control ----
C=$TMP/control
mkdir -p "$C"
cat > "$C/control" <<CTL
Package: $NAME
Version: $VER
Depends: libc, luci-base
Source: https://github.com/itsmaiGe/luci-theme-7dollar
SourceName: $NAME
License: Apache-2.0
Section: luci
URL: https://github.com/itsmaiGe/luci-theme-7dollar
Maintainer: itsmaiGe
Architecture: all
Installed-Size: $((SIZE * 1024))
Description: 7Dollar — an elegant, lightweight LuCI theme with five palettes,
light/dark mode, a friendly home dashboard and grouped navigation.
CTL
echo /etc/config/7dollar > "$C/conffiles"
cat > "$C/postinst" <<'SH'
#!/bin/sh
[ "${IPKG_NO_SCRIPT}" = "1" ] && exit 0
[ -s ${IPKG_INSTROOT}/lib/functions.sh ] || exit 0
. ${IPKG_INSTROOT}/lib/functions.sh
default_postinst $0 $@
[ -n "${IPKG_INSTROOT}" ] || {
rm -rf /tmp/luci-indexcache* /tmp/luci-modulecache/
/etc/init.d/rpcd reload >/dev/null 2>&1
}
exit 0
SH
cat > "$C/prerm" <<'SH'
#!/bin/sh
[ -s ${IPKG_INSTROOT}/lib/functions.sh ] || exit 0
. ${IPKG_INSTROOT}/lib/functions.sh
default_prerm $0 $@
SH
cat > "$C/postrm" <<'SH'
#!/bin/sh
[ "$1" = upgrade ] && exit 0 # opkg runs this on upgrades too; only a real removal unregisters
[ -n "${IPKG_INSTROOT}" ] || {
uci -q delete luci.themes.7Dollar
[ "$(uci -q get luci.main.mediaurlbase)" = "/luci-static/7dollar" ] && \
uci -q set luci.main.mediaurlbase=/luci-static/bootstrap
uci commit luci
rm -rf /tmp/luci-indexcache* /tmp/luci-modulecache/
}
exit 0
SH
chmod 644 "$C/control" "$C/conffiles"; chmod 755 "$C/postinst" "$C/prerm" "$C/postrm"
echo "2.0" > "$TMP/debian-binary"
( cd "$D" && $TAR $(own) -czf "$TMP/data.tar.gz" . )
( cd "$C" && $TAR $(own) -czf "$TMP/control.tar.gz" . )
mkdir -p dist
( cd "$TMP" && $TAR $(own) -czf pkg.tar.gz ./debian-binary ./data.tar.gz ./control.tar.gz )
mv "$TMP/pkg.tar.gz" "$OUT"
basename "$OUT" > dist/latest.txt
echo "$OUT ($(wc -c < "$OUT" | tr -d ' ') bytes)"
+18
View File
@@ -0,0 +1,18 @@
#!/bin/sh
# Source builds (feeds / SDK) minify our JS with LuCI's jsmin, which is stricter than a browser:
# for one, it misreads a regex literal that follows `return`. Run every script through the same
# jsmin and make sure the result still parses. Needs cc, curl and node; skipped without them.
set -eu
cd "$(dirname "$0")/.."
T=${TMPDIR:-/tmp}/7dollar-jsmin
mkdir -p "$T"
if [ ! -x "$T/jsmin" ]; then
curl -sfL -o "$T/jsmin.c" https://raw.githubusercontent.com/openwrt/luci/master/modules/luci-base/src/jsmin.c \
&& cc -o "$T/jsmin" "$T/jsmin.c" 2>/dev/null || { echo "check-jsmin: skipped (no cc or network)"; exit 0; }
fi
bad=0
for f in $(find htdocs -name '*.js'); do
"$T/jsmin" < "$f" > "$T/out.js" 2>/dev/null || continue # jsmin gave up: the buildroot then ships the file as it is
node -e "new Function(require('fs').readFileSync('$T/out.js','utf8'))" 2>/dev/null || { echo "check-jsmin: $f breaks after jsmin"; bad=1; }
done
exit $bad
+17
View File
@@ -0,0 +1,17 @@
#!/bin/sh
# Lay out the installed file tree of luci-theme-7dollar in $1 (shared by build-ipk.sh and build-apk.sh).
# JS and CSS are minified on the way (what the OpenWrt buildroot does for LuCI itself); the sources in
# the repo stay readable. MINIFY=0 skips it.
set -eu
cd "$(dirname "$0")/.."
D=$1
mkdir -p "$D/www" "$D/usr/share/ucode/luci"
cp -R htdocs/. "$D/www/"
cp -R ucode/. "$D/usr/share/ucode/luci/"
cp -R root/. "$D/"
find "$D" -name .DS_Store -exec rm {} +
[ "${MINIFY:-1}" = 0 ] || npx -y esbuild@0.28.2 $(find "$D/www" -name '*.js' -o -name '*.css') \
--minify --charset=utf8 --target=esnext --log-level=warning --allow-overwrite --outbase="$D/www" --outdir="$D/www"
find "$D" -type d -exec chmod 755 {} +
find "$D" -type f -exec chmod 644 {} +
chmod 755 "$D"/etc/uci-defaults/*