Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net-proxy/adblock2privoxy ebuild request #701

Open
wmyrda opened this Issue Apr 22, 2018 · 22 comments

Comments

Projects
None yet
2 participants
@wmyrda
Copy link

wmyrda commented Apr 22, 2018

These days just about any RTV device, phone and more have networking capabilities. Unlike in PCs they adblocking possibilities are very limited that it is essential to use network wide adblocking capabilities. Privoxy is capable to do just that, but itself does not update filtering scripts which are long time outdated. This is where adblock2privoxy comes in. There is very fine application which changes adblock scripts into privoxy understood setup. I wrote number of ebuilds over the years, but I am not familiar with haskell at all and would kindly ask to write an ebuild for that as this is where my skills stop.
According to upstream application uses stack to install which done manually installed about 2GB of stuff out of portage directory just during configure phase

stack setup --allow-different-user
Downloaded lts-8.23 build plan.
Fetched package index.
Populated index cache.
Preparing to install GHC (ncurses6-nopie) to an isolated location.
This will not interfere with any system-level installation.
Downloaded ghc-ncurses6-nopie-8.0.2.
Installed GHC.
stack will use a sandboxed GHC it installed
For more information on paths, see 'stack path' and 'stack exec env'
To use this GHC and packages outside of a project, consider using:
stack ghc, stack ghci, stack runghc, or stack exec

This is what I got, which obviously is not finished

# Copyright 1999-2018 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

EAPI=6

inherit git-r3 haskell-cabal

DESCRIPTION="Fork of Zubr's adblock2privoxy with additional changes"
HOMEPAGE="https://github.com/essandess/adblock2privoxy"
EGIT_REPO_URI="https://github.com/essandess/adblock2privoxy.git"

LICENSE="GPL-3"
KEYWORDS="~amd64 ~x86"
IUSE="apache nginx"
SLOT="0"

DEPEND="dev-lang/ghc
        dev-haskell/stack
"
RDEPEND="${DEPEND}
        net-proxy/privoxy
        apache? ( www-servers/apache )
        nginx? ( www-servers/nginx )
"

DOCS="README.md"

src_configure() {
        cd "${S}/${PN}"
        stack setup
}

src_compile() {
        cd "${S}/${PN}"
        stack build
}

#src_install() {
#       exeinto /usr/bin
#       doexe ${PN}/${PN}
#
#       insinto /vaw/www/privoxy
#       doins -r css
#}
@wmyrda

This comment has been minimized.

Copy link
Author

wmyrda commented Apr 22, 2018

Just on the side not as I saw this question elsewhere on other issues. Original program works only with GHC 7, while the forked version I proposed should work with GHC 8 as it has fixes for it.

@trofi

This comment has been minimized.

Copy link
Member

trofi commented Apr 22, 2018

Package from ::haskell overlay don't use stack and usually pull dependencies as other gentoo packages. Simplest way to autogenerate initial skeleton ebuild is to run hackport merge packagename or hackport make-ebuild dev-haskell path-to.cabal and then tweak it lightly to do the needed thing.

trofi added a commit that referenced this issue Apr 22, 2018

dev-haskell/parsec-permutation: new package
Bug: #701
Package-Manager: Portage-2.3.28, Repoman-2.3.9
@wmyrda

This comment has been minimized.

Copy link
Author

wmyrda commented Apr 22, 2018

Thanks for the tip. I am not familiar with hackport either and If that would mean that hackport installs package from their repo than it is probably good for dependencies, but not for adblock2privoxy package itself as the forks author states on its website

[Note: issuing the command stack unpack adblock2privoxy downloads the original adblock2privoxy from Hackage to the directory ./adblock2privoxy-*, which does not contain the modifications of this fork.]

All that means that I would spend a week on it and still not get it right, therefore I would ask for help again even if it is somewhat out of the scope of ::haskel project.

@trofi

This comment has been minimized.

Copy link
Member

trofi commented Apr 22, 2018

Yes, i was talking only about package dependencies. The package itself you would need to tweak a bit.

hackport only generates ebuilds for you. It does not enforce you to use hackage. It just generates default URLs that point there. You can change them back again to git repository. ::haskell has a few examples of ebuilds not from hackage. For example games-action/nikki.

@wmyrda

This comment has been minimized.

Copy link
Author

wmyrda commented Apr 23, 2018

Unfortunately using hackport didn't really work for me as I di not know how to get past this

hackport make-ebuild net-proxy adblock2privoxy /tmp/portage/net-proxy/adblock2privoxy-9999/work/adblock2privoxy-9999/adblock2privoxy/adblock2privoxy.cabal 
**hackport: Prelude.read: no parse**

adding stuff manually I got to this point

RDEPEND="net-proxy/privoxy"
DEPEND="${RDEPEND}
        dev-lang/ghc
        dev-haskell/case-insensitive
        dev-haskell/http-conduit
        dev-haskell/missingh
        dev-haskell/mtl
        >=dev-haskell/network-2.4
        dev-haskell/network-uri
        >=dev-haskell/old-locale-1.0
        dev-haskell/parsec
        dev-haskell/parsec-permutation
        dev-haskell/stack
        >=dev-haskell/strict-0.3
        >=dev-haskell/system-filepath-0.1.2
        >=dev-haskell/text-0.11
        >=dev-haskell/time-1.4"

It is missing containers As I did not know which one could it be as there is more of them in the tree

dev-haskell/data-default-instances-containers
dev-haskell/mutable-containers
dev-haskell/stm-containers
dev-haskell/unordered-containers

and it is missing directory

dev-haskell/directory-layout
dev-haskell/directory-listing-webpage-parser
dev-haskell/directory-tree
dev-haskell/machines-directory

Anyways those pulled by stack setup lts-8.23 and ncurses6-nopie / ghc-ncurses6-nopie-8.0.2 are not listed anywhere either. Are ebuilds for them present anywhere?

@trofi

This comment has been minimized.

Copy link
Member

trofi commented Apr 23, 2018

packages like containers and directory come bundled with ghc package. hackport detects that and leaves only ghc dependency (-v option should show this fact).

You can check it with:

$ qfile $(ghc --print-libdir)/package.conf.d/containers-0*.conf
dev-lang/ghc (/usr/lib64/ghc-8.0.2/package.conf.d/containers-0.5.7.1-gentoo-ghc-8.0.2.conf)

hackport hardcodes rules WRT bundled libraries here: https://github.com/gentoo-haskell/hackport/blob/master/Portage/GHCCore.hs#L182

@trofi

This comment has been minimized.

Copy link
Member

trofi commented Apr 23, 2018

hackport make-ebuild net-proxy adblock2privoxy /tmp/portage/net-proxy/adblock2privoxy-9999/work/adblock2privoxy-9999/adblock2privoxy/adblock2privoxy.cabal

You have redundant adblock2privoxy word here. I think it should be:

$ hackport \
    make-ebuild \
    net-proxy \
    /tmp/portage/net-proxy/adblock2privoxy-9999/wor/adblock2privoxy-9999/adblock2privoxy/adblock2privoxy.cabal
@wmyrda

This comment has been minimized.

Copy link
Author

wmyrda commented Apr 24, 2018

You are right about containers and directory. They are both part of ghc. As for hackport I do not know what is wrong but for any command I issue like the one you proposed or hackport list or hackport status results in hackport: Prelude.read: no parse
ncurses6-nopie / ghc-ncurses6-nopie-8.0.2 on the other hand is still what I was unable to find

@trofi

This comment has been minimized.

Copy link
Member

trofi commented Apr 24, 2018

As for hackport I do not know what is wrong but for any command I issue like the one you proposed or hackport list or hackport status results in hackport: Prelude.read: no parse

That is unexpected. Can you post the output of:

$ hackport list -v3

ncurses6-nopie / ghc-ncurses6-nopie-8.0.2 on the other hand is still what I was unable to find

What do those identifiers mean?

@wmyrda

This comment has been minimized.

Copy link
Author

wmyrda commented Apr 24, 2018

hackport list -v3 gives hackport: Prelude.read: no parse so something must be broken there :(

As for ncurces if you go back to my original post it said Downloaded ghc-ncurses6-nopie-8.0.2. while trying to build package manually and it took quite a lot of space so idea is to integrate it to the ebuild. Perhaps new ebuild for dev-haskell/ncurses is required?

@trofi

This comment has been minimized.

Copy link
Member

trofi commented Apr 24, 2018

In your initial post you were using stack. hackport genrates ebuilds that use cabal build system directory without stack involvement.

@wmyrda

This comment has been minimized.

Copy link
Author

wmyrda commented May 15, 2018

After few obstacles from hackport including that it for some reason wanted to create ebuild in /var/db/pkg not in /usr/local/portage I got ebuild ready. To my surprise the stock options inherited from eclass where enough to install the package.

# Copyright 1999-2018 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

EAPI=6

CABAL_FEATURES=""
inherit git-r3 haskell-cabal

DESCRIPTION="Convert adblock config files to privoxy format - Fork with additional changes"
HOMEPAGE="https://github.com/essandess/adblock2privoxy"
EGIT_REPO_URI="https://github.com/essandess/adblock2privoxy.git"

LICENSE="GPL-3"
KEYWORDS="~amd64 ~x86"
IUSE=""
SLOT="0"

RDEPEND="net-proxy/privoxy
        dev-haskell/case-insensitive:=
        dev-haskell/http-conduit:=
        dev-haskell/missingh:=
        dev-haskell/mtl:=
        >=dev-haskell/network-2.4:=
        dev-haskell/network-uri:=
        >=dev-haskell/old-locale-1.0:=
        dev-haskell/parsec:=
        >=dev-haskell/parsec-permutation-0.1.2.0:=
        >=dev-haskell/strict-0.3:=
        >=dev-haskell/text-0.11:=
        >=dev-lang/ghc-7.4.1:=
"
DEPEND="${RDEPEND}
        >=dev-haskell/cabal-1.10
"

DOCS="README.md"
S="${WORKDIR}/${P}/${PN}"

Adding it in overlay would be welcomed addition.

@trofi

This comment has been minimized.

Copy link
Member

trofi commented May 15, 2018

Feel free to submit pull request to the ::haskell overlay. Up to you to decide on package name for a fork, just make sure it's not confusing to upstream for other users.

@wmyrda

This comment has been minimized.

Copy link
Author

wmyrda commented Aug 20, 2018

Turns out recent update to the GHC 8.4.3 was not to friendly to adblock2privoxy. Please take a quick look whether that could be easily solved

@wmyrda

This comment has been minimized.

Copy link
Author

wmyrda commented Aug 26, 2018

@trofi
I did some reading trying to fix that compilation error I mentioned including SemigroupMonoid, and dozens of examples how that has been handled in other packages and even if fixes seem quite simple it is still way over my head and now that @essandess seems have taken longer vacation I would kindly ask You to take a look at fixing this package as now in my system I get 5 pages of warnings after every merge :/

!!! existing preserved libs:
>>> package: dev-haskell/parsec-3.1.13.0
 *  - /usr/lib64/x86_64-linux-ghc-8.0.2/libHSparsec-3.1.13.0-LDMR9C9vKEsLbmlnl9UQlF-ghc8.0.2.so
 *      used by /usr/bin/adblock2privoxy (net-proxy/adblock2privoxy-9999-r2)
>>> package: dev-haskell/text-1.2.3.0
 *  - /usr/lib64/x86_64-linux-ghc-8.0.2/libHStext-1.2.3.0-L4abLbO8ak22rMR8tnjLjg-ghc8.0.2.so
 *      used by /usr/bin/adblock2privoxy (net-proxy/adblock2privoxy-9999-r2)
>>> package: dev-haskell/exceptions-0.10.0
 *  - /usr/lib64/x86_64-linux-ghc-8.0.2/libHSexceptions-0.10.0-KcamdVkyBSFArlQxeXhgzq-ghc8.0.2.so
 *      used by /usr/bin/adblock2privoxy (net-proxy/adblock2privoxy-9999-r2)

On the other side going back to GHC 8.0.2 for this single Haskell package alone does not sound like a proper alternative

@trofi

This comment has been minimized.

Copy link
Member

trofi commented Aug 26, 2018

There is a step-by step how to fix the Semigroupoid instance: https://prime.haskell.org/wiki/Libraries/Proposals/SemigroupMonoid#Writingcompatiblecode

Basically you need to move (I prefer copy) Monoid/mappend definition into Semigroup/<> definition.

As for !!! existing preserved libs: warning that should be fixable by running emerge @preserved-rebuild and haskell-updater runs.

Do you have your ebuild in some overlay so I could send you an example fix?

@wmyrda

This comment has been minimized.

Copy link
Author

wmyrda commented Aug 26, 2018

I know there are emerge @preserved-rebuild and haskell-updater available which I used many times, but they work only when certain package compiles and adblock2privoxy is not :) This package depends on quite the number of libraries so it alone creates all the warnings which would not disappear if code in that package is not updated for ghc-8.4.

Ebuild you can find couple of posts above or if you prefer whole overlay I use you will find it on my website
However it might most beneficial to send patches here:

@wmyrda wmyrda referenced this issue Aug 27, 2018

Closed

META: work plan for cureent issues #26

16 of 18 tasks complete
@wmyrda

This comment has been minimized.

Copy link
Author

wmyrda commented Aug 31, 2018

@trofi
I tried fixing that bug and best I have come up with was adding import qualified Data.Semigroup as S in import section as well as copying and changing

instance Monoid a => Monoid (ZipListM a) where
  mempty = pure mempty
  mappend x y = mappend <$> x <*> y

into this

instance S.Semigroup ZipListM where
(<>) (mempty x <$> x) (mempty y <*> y) =
mempty (x y) (<$> x <*> y)

That and several other tries I did not work. Could you take a look at it?

@trofi

This comment has been minimized.

Copy link
Member

trofi commented Sep 8, 2018

It should have been something like

instance S.Semigroup ZipListM where
    (<>) x y = mappend <$> x <*> y

I didn't test it.

@wmyrda

This comment has been minimized.

Copy link
Author

wmyrda commented Sep 8, 2018

I tested it with what I hoped would be final version of the patch

diff -Naur adblock2privoxy-9999.old/adblock2privoxy/src/Utils.hs adblock2privoxy-9999/adblock2privoxy/src/Utils.hs
--- adblock2privoxy-9999.old/adblock2privoxy/src/Utils.hs       2018-09-08 21:15:22.343524300 +0200
+++ adblock2privoxy-9999/adblock2privoxy/src/Utils.hs   2018-09-08 21:16:50.847833262 +0200
@@ -25,6 +25,7 @@
 import Control.Applicative hiding (many)
 import Control.Monad.Writer
 import Control.Monad.State
+import qualified Data.Semigroup as S
 
 ------------------------------------------------------------------------------------------
 ----------------------------- export -----------------------------------------------------
@@ -61,6 +62,9 @@
   mempty = pure mempty
   mappend x y = mappend <$> x <*> y
 
+instance S.Semigroup ZipListM where
+    (<>) x y = mappend <$> x <*> y
+
 class Struct2 f where
         struct2 :: a1 -> a2 -> f a1 a2
         square2 :: (Applicative g, Monoid a1, Monoid a2) => g a1 -> g a2 -> [g (f a1 a2)]

I crossed my fingers, but unfortunately it did not work :(

src/Utils.hs:65:22: error:
    • Expecting one more argument to ‘ZipListM’
      Expected a type, but ‘ZipListM’ has kind ‘* -> *’
    • In the first argument of ‘Semigroup’, namely ‘ZipListM’
      In the instance declaration for ‘Semigroup ZipListM’
   |
65 | instance S.Semigroup ZipListM where
   |                      ^^^^^^^^

@trofi

This comment has been minimized.

Copy link
Member

trofi commented Sep 8, 2018

Oh, I did not notice original code was a bit different instance declaration. The change should have been:

instance Monoid a => S.Semigroup (ZipListM a) where
  (<>) x y = mappend <$> x <*> y

Not tested either.

@wmyrda

This comment has been minimized.

Copy link
Author

wmyrda commented Sep 8, 2018

I worked just right. Thank You!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.