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.

166 lines
5.1 KiB

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