lxc: use generic autoreconf fixup
[feed/packages.git] / net / privoxy / Makefile
1 #
2 # Copyright (C) 2006-2015 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7
8 include $(TOPDIR)/rules.mk
9
10 PKG_NAME:=privoxy
11 PKG_VERSION:=3.0.23
12 PKG_RELEASE:=1
13
14 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-stable-src.tar.gz
15 PKG_SOURCE_URL:=@SF/ijbswa
16 PKG_MD5SUM:=bbe47d5ff1a54d9f9fc93a160532697f
17 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)-stable
18 PKG_FIXUP:=autoreconf
19 PKG_INSTALL:=1
20
21 PKG_LICENSE:=GPL-2.0
22 PKG_LICENSE_FILES:=LICENSE
23
24 PKG_MAINTAINER:=christian.schoenebeck@gmail.com
25
26 include $(INCLUDE_DIR)/package.mk
27
28 define Package/$(PKG_NAME)
29 SECTION:=net
30 CATEGORY:=Network
31 SUBMENU:=Web Servers/Proxies
32 DEPENDS:=+libpcre +libpthread +zlib
33 TITLE:=Privoxy WEB Proxy
34 URL:=http://www.privoxy.org/
35 USERID:=privoxy=8118:privoxy=8118
36 endef
37
38 # shown in LuCI package description
39 define Package/$(PKG_NAME)/description
40 $(TITLE) - Homepage: www.privoxy.org
41 endef
42
43 # shown in make menuconfig <Help>
44 define Package/$(PKG_NAME)/config
45 help
46 Privoxy is a web proxy with advanced filtering capabilities for protecting
47 privacy, modifying web page content, managing cookies, controlling access,
48 and removing ads, banners, pop-ups and other obnoxious Internet junk.
49 Privoxy has a very flexible configuration and can be customized to suit
50 individual needs and tastes.
51 Privoxy has application for both stand-alone systems and multi-user networks.
52
53 Run as : $(USERID)
54 Version: $(PKG_VERSION)-$(PKG_RELEASE)
55 Home : $(URL)
56
57 $(PKG_MAINTAINER)
58 endef
59
60 CONFIGURE_ARGS += \
61 --sysconfdir=/etc/privoxy
62
63 # needed otherwise errors during compile
64 MAKE_FLAGS:=
65
66 define Build/Install
67 $(call Build/Install/Default,)
68 # rename original sample config from pkg_source to save existing one during install
69 mv $(PKG_INSTALL_DIR)/etc/privoxy/config $(PKG_INSTALL_DIR)/etc/privoxy/config.privoxy
70 endef
71
72 # "/etc/privoxy/config" temporary needed if updating from old version
73 define Package/$(PKG_NAME)/conffiles
74 /etc/config/privoxy
75 /etc/privoxy/config
76 endef
77
78 define Package/$(PKG_NAME)/preinst
79 #!/bin/sh
80 # if run within buildroot exit
81 [ -n "$${IPKG_INSTROOT}" ] && exit 0
82 # stop service if PKG_UPGRADE
83 [ "$${PKG_UPGRADE}" = "1" ] && /etc/init.d/privoxy stop >/dev/null 2>&1
84 exit 0 # supress errors from stop command
85 endef
86
87 define Package/$(PKG_NAME)/install
88 $(INSTALL_DIR) $(1)/usr/sbin
89 $(CP) $(PKG_INSTALL_DIR)/usr/sbin/privoxy $(1)/usr/sbin/
90 $(INSTALL_DIR) $(1)/etc/init.d
91 $(INSTALL_BIN) ./files/privoxy.init $(1)/etc/init.d/privoxy
92 $(INSTALL_DIR) $(1)/etc/hotplug.d/iface
93 $(INSTALL_BIN) ./files/privoxy.hotplug $(1)/etc/hotplug.d/iface/80-privoxy
94
95 $(INSTALL_DIR) $(1)/etc/privoxy
96 $(CP) $(PKG_INSTALL_DIR)/etc/privoxy/* $(1)/etc/privoxy/
97 # temporary needed if updating from old version
98 # otherwise old config file will be delete by opkg
99 $(INSTALL_CONF) ./files/privoxy.oldconfig $(1)/etc/privoxy/config
100 # create .old file to be removed with next pacakge builds during update
101 $(INSTALL_CONF) ./files/privoxy.oldconfig $(1)/etc/privoxy/config.old
102 # copy NEW config
103 $(INSTALL_DIR) $(1)/etc/config
104 $(INSTALL_CONF) ./files/privoxy.config $(1)/etc/config/privoxy
105 endef
106
107 define Package/$(PKG_NAME)/postinst
108 #!/bin/sh
109
110 # if fresh install we don't need old config file in privoxy directory
111 [ "$${PKG_UPGRADE}" = "0" ] && rm -f /etc/privoxy/config
112
113 # if run within buildroot exit here
114 [ -n "$${IPKG_INSTROOT}" ] && exit 0
115
116 # if PKG_UPGRADE then build uci configuration
117 # from existing(?) old /etc/privoxy/config file
118 if [ "$${PKG_UPGRADE}" = "1" -a -f /etc/privoxy/config ]; then
119
120 echo "converting OLD config to NEW uci configuration"
121
122 SECTION="privoxy.privoxy"
123 CFGFILE=/etc/privoxy/config
124
125 echo -n > /etc/config/privoxy # clear/create uci configuration file
126 cp -f $${CFGFILE} $${CFGFILE}.old # save old configuration
127
128 # cleanup
129 sed -i 's/^[ \t]*//;s/[ \t]*$$//' $${CFGFILE} # remove invisible chars at beginning and end of lines
130 sed -i '/^#/d' $${CFGFILE} # remove lines with "#"
131 sed -i '/^$$/d' $${CFGFILE} # remove empty lines
132
133 uci -q set $${SECTION}="privoxy" # create section
134
135 cat $${CFGFILE} | while read LINE; do
136 # option is first parameter; uci did not like "-" in option names
137 OPT=$$(echo $${LINE} | awk '{print $$1}' | sed 's/-/_/g')
138 VAL=$$(echo $${LINE} | awk '{print $$2}')
139 case $${OPT} in
140 # debug 1024 => debug_1024 '1'
141 debug)
142 uci -q set $${SECTION}.debug_$${VAL}="1"
143 ;;
144 # handle list values; splitted case for better reading
145 actionsfile|filterfile|listen_address)
146 uci -q add_list $${SECTION}.$${OPT}="$${VAL}"
147 ;;
148 permit_access|deny_access)
149 uci -q add_list $${SECTION}.$${OPT}="$${VAL}"
150 ;;
151 trust_info_url|forward)
152 uci -q add_list $${SECTION}.$${OPT}="$${VAL}"
153 ;;
154 forward_socks4|forward_socks4a)
155 uci -q add_list $${SECTION}.$${OPT}="$${VAL}"
156 ;;
157 forward_socks5|forward_socks5t)
158 uci -q add_list $${SECTION}.$${OPT}="$${VAL}"
159 ;;
160 # all others are normal options
161 *)
162 uci -q set $${SECTION}.$${OPT}="$${VAL}"
163 ;;
164 esac
165 done
166 uci -q commit privoxy # commit changes
167 rm -f $${CFGFILE} # remove old configuration file
168 fi
169
170 # set permissions to privoxy group
171 echo "setting permissions"
172 chgrp -R privoxy /etc/privoxy/*
173 chmod 664 /etc/privoxy/*
174 chmod 755 /etc/privoxy/templates
175 chmod 644 /etc/privoxy/templates/*
176 endef
177
178 $(eval $(call BuildPackage,$(PKG_NAME)))