You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

178 lines
5.3 KiB

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