adblock-fast: improve Makefile's prerm
[feed/packages.git] / net / adblock-fast / Makefile
1 # Copyright 2023 MOSSDeF, Stan Grishin (stangri@melmac.ca)
2 # TLD optimization written by Dirk Brenken (dev@brenken.org)
3 # This is free software, licensed under the GNU General Public License v3.
4
5 include $(TOPDIR)/rules.mk
6
7 PKG_NAME:=adblock-fast
8 PKG_VERSION:=1.1.1
9 PKG_RELEASE:=r8
10 PKG_MAINTAINER:=Stan Grishin <stangri@melmac.ca>
11 PKG_LICENSE:=GPL-3.0-or-later
12
13 include $(INCLUDE_DIR)/package.mk
14
15 define Package/adblock-fast
16 SECTION:=net
17 CATEGORY:=Network
18 TITLE:=AdBlock Fast Service
19 URL:=https://docs.openwrt.melmac.net/adblock-fast/
20 DEPENDS:=+jshn +curl
21 DEPENDS+=+!BUSYBOX_DEFAULT_AWK:gawk
22 DEPENDS+=+!BUSYBOX_DEFAULT_GREP:grep
23 DEPENDS+=+!BUSYBOX_DEFAULT_SED:sed
24 DEPENDS+=+!BUSYBOX_DEFAULT_SORT:coreutils-sort
25 CONFLICTS:=simple-adblock
26 PROVIDES:=simple-adblock
27 PKGARCH:=all
28 endef
29
30 define Package/adblock-fast/description
31 Fast AdBlocking script to block ad or abuse/malware domains with Dnsmasq, SmartDNS or Unbound.
32 Script supports local/remote list of domains and hosts-files for both block-listing and allow-listing.
33 Please see https://docs.openwrt.melmac.net/adblock-fast/ for more information.
34 endef
35
36 define Package/adblock-fast/conffiles
37 /etc/config/adblock-fast
38 endef
39
40 define Build/Configure
41 endef
42
43 define Build/Compile
44 endef
45
46 define Package/adblock-fast/install
47 $(INSTALL_DIR) $(1)/etc/init.d
48 $(INSTALL_BIN) ./files/etc/init.d/adblock-fast $(1)/etc/init.d/adblock-fast
49 $(SED) "s|^\(readonly PKG_VERSION\).*|\1='$(PKG_VERSION)-$(PKG_RELEASE)'|" $(1)/etc/init.d/adblock-fast
50 $(INSTALL_DIR) $(1)/etc/config
51 $(INSTALL_CONF) ./files/etc/config/adblock-fast $(1)/etc/config/adblock-fast
52 $(INSTALL_DIR) $(1)/tmp
53 $(INSTALL_DATA) ./files/adblock-fast.config.update $(1)/tmp/adblock-fast.config.update
54 $(INSTALL_DIR) $(1)/etc/uci-defaults
55 $(INSTALL_BIN) ./files/etc/uci-defaults/90-adblock-fast $(1)/etc/uci-defaults/90-adblock-fast
56 endef
57
58 define Package/adblock-fast/postinst
59 #!/bin/sh
60 # check if we are on real system
61 if [ -z "$${IPKG_INSTROOT}" ]; then
62 sed -f /tmp/adblock-fast.config.update -i /etc/config/adblock-fast || true
63 /etc/init.d/adblock-fast enable
64 fi
65 exit 0
66 endef
67
68 define Package/adblock-fast/prerm
69 #!/bin/sh
70 # check if we are on real system
71 if [ -z "$${IPKG_INSTROOT}" ]; then
72 echo -n "Stopping adblock-fast service... "
73 { /etc/init.d/adblock-fast stop && \
74 /etc/init.d/adblock-fast killcache; } >/dev/null 2>&1 && echo "OK" || echo "FAIL"
75 echo -n "Removing rc.d symlink for adblock-fast... "
76 /etc/init.d/adblock-fast disable >/dev/null 2>&1 && echo "OK" || echo "FAIL"
77 fi
78 exit 0
79 endef
80
81 $(eval $(call BuildPackage,adblock-fast))