mirror of
https://github.com/remittor/zapret-openwrt.git
synced 2026-01-31 06:40:42 +03:00
makefile: Fix check for installed packages
This commit is contained in:
@@ -37,7 +37,7 @@ define Package/$(PKG_NAME)
|
|||||||
DEPENDS:= +nftables +curl +gzip
|
DEPENDS:= +nftables +curl +gzip
|
||||||
DEPENDS+= +coreutils +coreutils-sort +coreutils-sleep
|
DEPENDS+= +coreutils +coreutils-sort +coreutils-sleep
|
||||||
DEPENDS+= +kmod-nft-nat +kmod-nft-offload +kmod-nft-queue
|
DEPENDS+= +kmod-nft-nat +kmod-nft-offload +kmod-nft-queue
|
||||||
DEPENDS+= +libnetfilter-queue +libcap +zlib
|
DEPENDS+= +libnetfilter-queue +libmnl +libcap +zlib
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define Build/Prepare
|
define Build/Prepare
|
||||||
@@ -180,7 +180,7 @@ if [ -z "$${IPKG_INSTROOT}" ]; then
|
|||||||
$${ZAPRET_INITD} running && $${ZAPRET_INITD} stop >/dev/null 2>&1
|
$${ZAPRET_INITD} running && $${ZAPRET_INITD} stop >/dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if $${PKG_CHECK} zapret >/dev/null 2>&1; then
|
if $${PKG_CHECK} zapret 2>/dev/null | grep -q . ; then
|
||||||
if [ ! -f "/opt/zapret/sync_config.sh" ]; then
|
if [ ! -f "/opt/zapret/sync_config.sh" ]; then
|
||||||
echo "Please uninstall incompatible \"zapret\" package!"
|
echo "Please uninstall incompatible \"zapret\" package!"
|
||||||
exit 47
|
exit 47
|
||||||
@@ -190,7 +190,7 @@ if [ -z "$${IPKG_INSTROOT}" ]; then
|
|||||||
exit 48
|
exit 48
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if $${PKG_CHECK} luci-app-zapret >/dev/null 2>&1; then
|
if $${PKG_CHECK} luci-app-zapret 2>/dev/null | grep -q . ; then
|
||||||
SVC_FILE=/www/luci-static/resources/view/zapret/service.js
|
SVC_FILE=/www/luci-static/resources/view/zapret/service.js
|
||||||
if [ ! -f "$${SVC_FILE}" ] || ! grep -Fq "/remittor/zapret-openwrt" "$${SVC_FILE}"; then
|
if [ ! -f "$${SVC_FILE}" ] || ! grep -Fq "/remittor/zapret-openwrt" "$${SVC_FILE}"; then
|
||||||
echo "Please uninstall incompatible \"luci-app-zapret\" package!"
|
echo "Please uninstall incompatible \"luci-app-zapret\" package!"
|
||||||
@@ -206,10 +206,10 @@ if [ -z "$${IPKG_INSTROOT}" ]; then
|
|||||||
[ -d "$${ZAPRET_DIR}" ] && rm -rf $${ZAPRET_DIR}
|
[ -d "$${ZAPRET_DIR}" ] && rm -rf $${ZAPRET_DIR}
|
||||||
echo "All files of the previously installed package have been removed!"
|
echo "All files of the previously installed package have been removed!"
|
||||||
fi
|
fi
|
||||||
if $${PKG_CHECK} zapret-mdig >/dev/null 2>&1; then
|
if $${PKG_CHECK} zapret-mdig 2>/dev/null | grep -q . ; then
|
||||||
$${PKG_REMOVE} zapret-mdig
|
$${PKG_REMOVE} zapret-mdig
|
||||||
fi
|
fi
|
||||||
if $${PKG_CHECK} zapret-ip2net >/dev/null 2>&1; then
|
if $${PKG_CHECK} zapret-ip2net 2>/dev/null | grep -q . ; then
|
||||||
$${PKG_REMOVE} zapret-ip2net
|
$${PKG_REMOVE} zapret-ip2net
|
||||||
fi
|
fi
|
||||||
if [ ! -d "$${ZAPRET_DIR}" ]; then
|
if [ ! -d "$${ZAPRET_DIR}" ]; then
|
||||||
|
|||||||
@@ -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
|
function get_distrib_param
|
||||||
{
|
{
|
||||||
local parname=$1
|
local parname=$1
|
||||||
@@ -475,7 +485,7 @@ if [ "$opt_update" != "" ]; then
|
|||||||
mkdir $ZAP_PKG_DIR
|
mkdir $ZAP_PKG_DIR
|
||||||
ZAP_PKG_FN="$ZAP_PKG_DIR/${ZAP_PKG_URL##*/}"
|
ZAP_PKG_FN="$ZAP_PKG_DIR/${ZAP_PKG_URL##*/}"
|
||||||
echo "Download ZIP-file..."
|
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
|
if [ $? -ne 0 ]; then
|
||||||
echo "ERROR: cannot download package!"
|
echo "ERROR: cannot download package!"
|
||||||
return 215
|
return 215
|
||||||
@@ -529,11 +539,11 @@ if [ "$opt_update" != "" ]; then
|
|||||||
if [ "$opt_forced" = true ]; then
|
if [ "$opt_forced" = true ]; then
|
||||||
pkg_mgr_update
|
pkg_mgr_update
|
||||||
fi
|
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..."
|
echo "Uninstall mdig..."
|
||||||
${PKG_REMOVE} ${ZAPRET_CFG_NAME}-mdig
|
${PKG_REMOVE} ${ZAPRET_CFG_NAME}-mdig
|
||||||
fi
|
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..."
|
echo "Uninstall ip2net..."
|
||||||
${PKG_REMOVE} ${ZAPRET_CFG_NAME}-ip2net
|
${PKG_REMOVE} ${ZAPRET_CFG_NAME}-ip2net
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user