update 2024-08-06 00:22:13

This commit is contained in:
kenzok8 2024-08-06 00:22:13 +08:00
parent aea668cece
commit b54186c19c
4 changed files with 51 additions and 18 deletions

View File

@ -7,7 +7,7 @@
include $(TOPDIR)/rules.mk
LUCI_NAME:=luci-app-tinyfilemanager
PKG_VERSION:=2.5.3-20240803
PKG_VERSION:=2.5.3-20240804
#PKG_RELEASE:=1
LUCI_TITLE:=LuCI Tiny File Manager

View File

@ -30,19 +30,34 @@ cd $WORKDIR
rm -rf *
# Download Repository
curl -L ${REPOURL}/archive/refs/tags/${VERSION}.tar.gz | tar -xvz -C "$WORKDIR"
grep -qE "^(master|main)$" <<< "$VERSION" && refs=heads || refs=tags
curl -L https://codeload.github.com/prasathmani/tinyfilemanager/tar.gz/refs/$refs/$VERSION | tar -xvz -C "$WORKDIR"
# Check offline ?
[ -z "$(sed -En "/^\\\$external = array\(/,/^\);/p" "$PKG_DIR/$INDEXPHP")" ] && {
# Version Check
if [ -z "$(sed -En "/^\\\$external = array\(/,/^\);/p" "$PKG_DIR/$INDEXPHP")" ]; then
online=y ver_cc=old # <= 2.5.3
elif [ -n "$(sed -En "/^\\\$external = array\(/,/^\);/{s,^(.+=\")(http(s)?://.+/)([^/]+\.(css|js))(\".+),\4,p}" "$PKG_DIR/$INDEXPHP")" ]; then
online=y ver_cc=master
else
online=n ver_cc=offline
fi
[ "$online" = "y" ] && {
# Preprocessing
sed -Ei "/<link rel=\"(preconnect|dns-prefetch)\"/d" "$PKG_DIR/$INDEXPHP"
FM_HIGHLIGHTJS_STYLE=$(sed -En "s|^\\\$highlightjs_style = *'([^']*)';|\1|p" "$PKG_DIR/$INDEXPHP")
sed -i "s|<?php echo FM_HIGHLIGHTJS_STYLE ?>|\$FM_HIGHLIGHTJS_STYLE|g" "$PKG_DIR/$INDEXPHP"
[ "$ver_cc" = "old" ] && {
FM_HIGHLIGHTJS_STYLE=$(sed -En "s|^\\\$highlightjs_style = *'([^']*)';|\1|p" "$PKG_DIR/$INDEXPHP")
sed -i "s|<?php echo FM_HIGHLIGHTJS_STYLE ?>|\$FM_HIGHLIGHTJS_STYLE|g" "$PKG_DIR/$INDEXPHP"
}
[ "$ver_cc" = "master" ] && {
__highlightjs_style=$(sed -En "s|^\\\$highlightjs_style = *'([^']*)';|\1|p" "$PKG_DIR/$INDEXPHP")
sed -i "s|' . \$highlightjs_style . '|\$__highlightjs_style|" "$PKG_DIR/$INDEXPHP"
}
# Download CDN Used
mkdir -p "$REF_DIR" 2>/dev/null
refurl=($(sed -En "s,^.+=\"(https?://.+\.(css|js))\".+,\1,p" "$PKG_DIR/$INDEXPHP" | sort -u ))
[ "$ver_cc" = "old" ] && refurl=($(sed -En "s,^.+=\"(https?://.+\.(css|js))\".+,\1,p" "$PKG_DIR/$INDEXPHP" | sort -u ))
[ "$ver_cc" = "master" ] && refurl=($(sed -En "/^\\\$external /,/^\);/{s,^.+=\"(http(s)?://.+\.(css|js))\".+,\1, p}" "$PKG_DIR/$INDEXPHP" | sort -u ))
ref=
url=
out=
@ -81,7 +96,8 @@ for _i in $ref; do
done
# Post-processing
sed -i "s|\$FM_HIGHLIGHTJS_STYLE|<?php echo FM_HIGHLIGHTJS_STYLE ?>|g" "$PKG_DIR/$INDEXPHP"
[ "$ver_cc" = "old" ] && sed -i "s|\$FM_HIGHLIGHTJS_STYLE|<?php echo FM_HIGHLIGHTJS_STYLE ?>|g" "$PKG_DIR/$INDEXPHP"
[ "$ver_cc" = "master" ] && sed -i "s|\$__highlightjs_style|' . \$highlightjs_style . '|" "$PKG_DIR/$INDEXPHP"
# Hotfix
@ -91,7 +107,7 @@ sed -Ei "s,^(.+=\")https?://.+/([^/]+\.(css|js))(\".+),\1$REF_DIR/\3/\2\4," "$PK
}
# FixED
sed -Ei "/^if \(\\\$use_auth\) \{/,/^}/{/\/\/ Logging In/,/\/\/ Form/{s|(fm_redirect\().+|\1FM_SELF_URL);|g}}" "$PKG_DIR/$INDEXPHP"
[ "$ver_cc" = "master" ] || sed -Ei "/^if \(\\\$use_auth\) \{/,/^}/{/\/\/ Logging In/,/\/\/ Form/{s|(fm_redirect\().+|\1FM_SELF_URL);|g}}" "$PKG_DIR/$INDEXPHP"
# Clean up and Done
[ -d "$PKG_DIR/$REF_DIR" ] && cp -rf "$PKG_DIR/$REF_DIR" .

View File

@ -111,6 +111,7 @@ check() {
| grep '"tag_name":' | sed "/$VERSION/,\${/$VERSION/b;d}" \
| sed -E 's|",||g; s|^.+"([^"]+)|\1|g' \
> "$VARDIR/releaseslist"
[ "$?" != 0 ] || sed -i 'i\master' "$VARDIR/releaseslist"
}
restart() {

View File

@ -33,19 +33,34 @@ fi
rm -rf *
# Download Repository
curl -sSL ${REPOURL}/archive/refs/tags/${VERSION}.tar.gz | tar -xvz -C /tmp
grep -qE "^(master|main)$" <<< "$VERSION" && refs=heads || refs=tags
curl -sSL https://codeload.github.com/prasathmani/tinyfilemanager/tar.gz/refs/$refs/$VERSION | tar -xvz -C /tmp
# Check offline ?
[ -z "$(sed -En "/^\\\$external = array\(/,/^\);/p" /tmp/$PKG_DIR/$INDEXPHP)" ] && {
# Version Check
if [ -z "$(sed -En "/^\\\$external = array\(/,/^\);/p" /tmp/$PKG_DIR/$INDEXPHP)" ]; then
online=y ver_cc=old # <= 2.5.3
elif [ -n "$(sed -En "/^\\\$external = array\(/,/^\);/{s,^(.+=\")(http(s)?://.+/)([^/]+\.(css|js))(\".+),\4,p}" /tmp/$PKG_DIR/$INDEXPHP)" ]; then
online=y ver_cc=master
else
online=n ver_cc=offline
fi
[ "$online" = "y" ] && {
# Preprocessing
sed -Ei "/<link rel=\"(preconnect|dns-prefetch)\"/d" /tmp/$PKG_DIR/$INDEXPHP
FM_HIGHLIGHTJS_STYLE=$(sed -En "s|^\\\$highlightjs_style = *'([^']*)';|\1|p" /tmp/$PKG_DIR/$INDEXPHP)
sed -i "s|<?php echo FM_HIGHLIGHTJS_STYLE ?>|\$FM_HIGHLIGHTJS_STYLE|g" /tmp/$PKG_DIR/$INDEXPHP
[ "$ver_cc" = "old" ] && {
FM_HIGHLIGHTJS_STYLE=$(sed -En "s|^\\\$highlightjs_style = *'([^']*)';|\1|p" /tmp/$PKG_DIR/$INDEXPHP)
sed -i "s|<?php echo FM_HIGHLIGHTJS_STYLE ?>|\$FM_HIGHLIGHTJS_STYLE|g" /tmp/$PKG_DIR/$INDEXPHP
}
[ "$ver_cc" = "master" ] && {
__highlightjs_style=$(sed -En "s|^\\\$highlightjs_style = *'([^']*)';|\1|p" /tmp/$PKG_DIR/$INDEXPHP)
sed -i "s|' . \$highlightjs_style . '|\$__highlightjs_style|" /tmp/$PKG_DIR/$INDEXPHP
}
# Download CDN Used
mkdir -p "$REF_DIR" 2>/dev/null
refurl=($(sed -En "s,^.+=\"(https?://.+\.(css|js))\".+,\1,p" /tmp/$PKG_DIR/$INDEXPHP | sort -u ))
[ "$ver_cc" = "old" ] && refurl=($(sed -En "s,^.+=\"(https?://.+\.(css|js))\".+,\1,p" /tmp/$PKG_DIR/$INDEXPHP | sort -u ))
[ "$ver_cc" = "master" ] && refurl=($(sed -En "/^\\\$external /,/^\);/{s,^.+=\"(http(s)?://.+\.(css|js))\".+,\1, p}" /tmp/$PKG_DIR/$INDEXPHP | sort -u ))
ref=
url=
out=
@ -84,17 +99,18 @@ for _i in $ref; do
done
# Post-processing
sed -i "s|\$FM_HIGHLIGHTJS_STYLE|<?php echo FM_HIGHLIGHTJS_STYLE ?>|g" /tmp/$PKG_DIR/$INDEXPHP
[ "$ver_cc" = "old" ] && sed -i "s|\$FM_HIGHLIGHTJS_STYLE|<?php echo FM_HIGHLIGHTJS_STYLE ?>|g" /tmp/$PKG_DIR/$INDEXPHP
[ "$ver_cc" = "master" ] && sed -i "s|\$__highlightjs_style|' . \$highlightjs_style . '|" /tmp/$PKG_DIR/$INDEXPHP
# Hotfix
# Migrating to Local Reference
sed -Ei "s,^(.+=\")https?://.+/([^/]+\.(css|js))(\".+),\1$REF_DIR/\3/\2\4," /tmp/$PKG_DIR/$INDEXPHP
sed -Ei "s,^(.+=\")https?://(.+\.(css|js))(\".+),\1$REF_DIR/\2\4," /tmp/$PKG_DIR/$INDEXPHP
}
# FixED
sed -Ei "/^if \(\\\$use_auth\) \{/,/^}/{/\/\/ Logging In/,/\/\/ Form/{s|(fm_redirect\().+|\1FM_SELF_URL);|g}}" /tmp/$PKG_DIR/$INDEXPHP
[ "$ver_cc" = "master" ] || sed -Ei "/^if \(\\\$use_auth\) \{/,/^}/{/\/\/ Logging In/,/\/\/ Form/{s|(fm_redirect\().+|\1FM_SELF_URL);|g}}" /tmp/$PKG_DIR/$INDEXPHP
# Clean up and Done
[ -d "/tmp/$PKG_DIR/$REF_DIR" ] && cp -rf "/tmp/$PKG_DIR/$REF_DIR" .