Compare commits

..

1 Commits

Author SHA1 Message Date
remittor
ea12fcc85a makefile: Fix check for installed packages 2026-01-29 21:09:32 +03:00
2 changed files with 18 additions and 8 deletions

View File

@@ -52,7 +52,7 @@ define Package/$(PKG_NAME)
DEPENDS:= +nftables +curl +gzip +$(LUA_DEPEND)
DEPENDS+= +coreutils +coreutils-sort +coreutils-sleep
DEPENDS+= +kmod-nft-nat +kmod-nft-offload +kmod-nft-queue
DEPENDS+= +libnetfilter-queue +libcap +zlib
DEPENDS+= +libnetfilter-queue +libmnl +libcap +zlib
endef
define Build/Prepare
@@ -197,7 +197,7 @@ if [ -z "$${IPKG_INSTROOT}" ]; then
$${ZAPRET_INITD} running && $${ZAPRET_INITD} stop >/dev/null 2>&1
fi
fi
if $${PKG_CHECK} zapret2 >/dev/null 2>&1; then
if $${PKG_CHECK} zapret2 2>/dev/null | grep -q . ; then
if [ ! -f "/opt/zapret2/sync_config.sh" ]; then
echo "Please uninstall incompatible \"zapret2\" package!"
exit 47
@@ -207,7 +207,7 @@ if [ -z "$${IPKG_INSTROOT}" ]; then
exit 48
fi
fi
if $${PKG_CHECK} luci-app-zapret2 >/dev/null 2>&1; then
if $${PKG_CHECK} luci-app-zapret2 2>/dev/null | grep -q . ; then
SVC_FILE=/www/luci-static/resources/view/zapret2/service.js
if [ ! -f "$${SVC_FILE}" ] || ! grep -Fq "/remittor/zapret-openwrt" "$${SVC_FILE}"; then
echo "Please uninstall incompatible \"luci-app-zapret2\" package!"
@@ -223,10 +223,10 @@ if [ -z "$${IPKG_INSTROOT}" ]; then
[ -d "$${ZAPRET_DIR}" ] && rm -rf $${ZAPRET_DIR}
echo "All files of the previously installed package have been removed!"
fi
if $${PKG_CHECK} zapret2-mdig >/dev/null 2>&1; then
if $${PKG_CHECK} zapret2-mdig 2>/dev/null | grep -q . ; then
$${PKG_REMOVE} zapret2-mdig
fi
if $${PKG_CHECK} zapret2-ip2net >/dev/null 2>&1; then
if $${PKG_CHECK} zapret2-ip2net 2>/dev/null | grep -q . ; then
$${PKG_REMOVE} zapret2-ip2net
fi
if [ ! -d "$${ZAPRET_DIR}" ]; then

View File

@@ -89,6 +89,16 @@ fi
# -------------------------------------------------------------------------------------------------------
function check_pkg_installed
{
local pkg_name="$1"
if [ "$PKG_MGR" = apk ]; then
apk info -e "$pkg_name" >/dev/null 2>&1;
else
opkg status "$pkg_name" 2>/dev/null | grep -q .
fi
}
function get_distrib_param
{
local parname=$1
@@ -475,7 +485,7 @@ if [ "$opt_update" != "" ]; then
mkdir $ZAP_PKG_DIR
ZAP_PKG_FN="$ZAP_PKG_DIR/${ZAP_PKG_URL##*/}"
echo "Download ZIP-file..."
curl -s -L --max-time 15 -H "$CURL_HEADER2" "$ZAP_PKG_URL" -o "$ZAP_PKG_FN"
curl -s -L --max-time 35 -H "$CURL_HEADER2" "$ZAP_PKG_URL" -o "$ZAP_PKG_FN"
if [ $? -ne 0 ]; then
echo "ERROR: cannot download package!"
return 215
@@ -529,11 +539,11 @@ if [ "$opt_update" != "" ]; then
if [ "$opt_forced" = true ]; then
pkg_mgr_update
fi
if ${PKG_CHECK} ${ZAPRET_CFG_NAME}-mdig >/dev/null 2>&1; then
if check_pkg_installed ${ZAPRET_CFG_NAME}-mdig; then
echo "Uninstall mdig..."
${PKG_REMOVE} ${ZAPRET_CFG_NAME}-mdig
fi
if ${PKG_CHECK} ${ZAPRET_CFG_NAME}-ip2net >/dev/null 2>&1; then
if check_pkg_installed ${ZAPRET_CFG_NAME}-ip2net; then
echo "Uninstall ip2net..."
${PKG_REMOVE} ${ZAPRET_CFG_NAME}-ip2net
fi