You are not logged in.

#1 2011-02-27 19:37:40

benji.ijneb
Member
Registered: 2008-12-13
Posts: 84

[REQUEST] SelfControl

http://svn.jklmnop.net/projects/SelfControl.html

Looks like a really useful app for anyone trying to get some work done. It's written in perl and requires, as far as I can tell:

iptables at gksu perl-yaml gtk2-perl

It would be really great to get a PKGBUILD for this!

Offline

#2 2011-03-27 15:04:25

benji.ijneb
Member
Registered: 2008-12-13
Posts: 84

Re: [REQUEST] SelfControl

Bump. Anyone?

Offline

#3 2011-04-02 22:59:41

Stunts
Member
From: Portugal
Registered: 2009-03-28
Posts: 339
Website

Re: [REQUEST] SelfControl

This seems quite easy to turn into a PKGBUILD.
https://wiki.archlinux.org/index.php/Creating_Packages
You should give it a try yourself. You will see how gratifying it is when you finally succeed.
This program is a good example for a first try. I can guide you trough if you require help.

Offline

#4 2011-04-02 23:28:05

sportscliche
Member
From: Albuquerque, NM
Registered: 2010-11-30
Posts: 43

Re: [REQUEST] SelfControl

I gave it a shot, essentially following the guide in the INSTALL file of the package.  The dependencies I discovered are 'iptables' 'perl-yaml' 'gtk2-perl' 'at' and 'ed', the latter revealed with ./BUILD test.  I edited the ABS PKGBUILD-perl.proto template to follow the INSTALL sequence.  I made the package, installed it, and found that the on-board perl script has a few things scattered around in the wrong places, including the start script.  This could be cleaned up with some work.  I was able to launch the program from the command line, however, and got a working GUI.  I tried blocking some random websites, setting the timeout for the minimum 5 minutes.   Then I tested using both Firefox and Chrome.  While the blocking worked immediately, the changes appeared to be permanent: after the set time had elapsed (the program shows you the exact second this should occur), the websites remained inaccessible. 

I'm not sure if it's an issue with the source code or my PKGBUILD, but something isn't right.  Sorry, that's as far as I could get.

Offline

#5 2011-04-02 23:32:43

Stunts
Member
From: Portugal
Registered: 2009-03-28
Posts: 339
Website

Re: [REQUEST] SelfControl

You seem to be doing good.
Post what you've made so far. Let me take a look at what you've done and let's see what needs improving.

Offline

#6 2011-04-03 00:01:17

sportscliche
Member
From: Albuquerque, NM
Registered: 2010-11-30
Posts: 43

Re: [REQUEST] SelfControl

Here's where I left it.  This will generate a SelfControl GUI but the program has problems as I mentioned above.  Note that I am not the original poster. 

pkgname=selfcontrol
pkgver=0.9
pkgrel=1
pkgdesc=""
arch=('any')
url="http://svn.jklmnop.net/projects/SelfControl.html"
license=('GPL' 'PerlArtistic')
depends=('perl>=5.10.0' 'at' 'ed' 'gtk2-perl' 'perl-yaml' 'iptables')
options=(!emptydirs)
source=(http://svn.jklmnop.net/projects/SelfControl/$pkgname-$pkgver.tar.gz)
md5sums=('fa5736dc761c647c43f6598d8894b8f5')

build() {
  cd "$srcdir/$pkgname-$pkgver"
# Cleaning up the script to place the icon correctly; more work needed
#  sed -i 's:icons/hicolor/scalable/apps:pixmaps:' Build.PL
  perl Build.PL installdirs=vendor destdir="$pkgdir/"
  perl Build
}

package() {
  cd "$srcdir/$pkgname-$pkgver"
# perl Build test
  perl Build install
}

Offline

#7 2011-04-04 22:13:41

Stunts
Member
From: Portugal
Registered: 2009-03-28
Posts: 339
Website

Re: [REQUEST] SelfControl

I haven't dropped this.
I've made an attempt to get it working last Sunday but got interrupted.
I'll continue with it once I get the chance (it's still sitting on my desktop).
Maybe by the end of the week...

Offline

#8 2011-04-05 20:02:42

benji.ijneb
Member
Registered: 2008-12-13
Posts: 84

Re: [REQUEST] SelfControl

Great to see this happening! Thanks, people.

Offline

#9 2011-04-10 18:58:47

Stunts
Member
From: Portugal
Registered: 2009-03-28
Posts: 339
Website

Re: [REQUEST] SelfControl

OK, so I've been messing with this for a wile now and I seem to be hitting 2 problems:
I have modified the PKGBUILD provided by sportscliche, in order to properly address the init.d vs. rc.d problems, so that part is solved now.
First one is the program crashes after asking for the root password when hitting "Start". I know it worked, since my /etc/hosts gets edited, and the websites get blocked.
But afterwards, the sites don't stop being blocked. The lines added by Selfcontrol remain in /etc/hosts after the blocking period expires.
Here's my modified PKGBUILD:

pkgname=selfcontrol
pkgver=0.9
pkgrel=1
pkgdesc=""
arch=('any')
url="http://svn.jklmnop.net/projects/SelfControl.html"
license=('GPL' 'PerlArtistic')
depends=('perl>=5.10.0' 'at' 'ed' 'gtk2-perl' 'perl-yaml' 'iptables')
options=(!emptydirs)
source=(http://svn.jklmnop.net/projects/SelfControl/$pkgname-$pkgver.tar.gz)
md5sums=('fa5736dc761c647c43f6598d8894b8f5')

build() {
  cd "$srcdir/$pkgname-$pkgver"
# Cleaning up the script to place the icon correctly; more work needed
#  sed -i 's:icons/hicolor/scalable/apps:pixmaps:' Build.PL
  perl Build.PL installdirs=vendor destdir="$pkgdir/"
  perl Build
}

package() {
  cd "$srcdir/$pkgname-$pkgver"
# perl Build test
  perl Build install
  cd "$pkgdir"
  mv etc/init.d etc/rc.d
  sed -i 's:iptables-:/usr/sbin/&:' etc/rc.d/selfcontrol
  sed -i 's:init.d:rc.d:' usr/share/perl5/vendor_perl/SelfControl/Root.pm

}

I think the problem lies here:
"usr/share/perl5/vendor_perl/SelfControl.pm"
# `atq` - requires sudoers line to really work:
# username ALL = NOPASSWD: /usr/bin/atq

This really seems to be the root of the problem, but doing what is recommended there seems kind of hackish.
I take it back - this is not as easy to package as it first seemed...
Any more ideas?

Edit:
Also adding the line just like that to sudoers file (replacing "username" with my username, of course) does not solve the problem...

Last edited by Stunts (2011-04-10 19:00:02)

Offline

#10 2011-04-22 15:06:46

sportscliche
Member
From: Albuquerque, NM
Registered: 2010-11-30
Posts: 43

Re: [REQUEST] SelfControl

I took what I think is a completely different approach to this problem and built from the the debian source.  I turn the selfcontrol .deb file into a tarball, unzip it, and then perform the tedious process of manually assigning the various files to their proper directories.  This is what dpkg would do automatically.  I got a working GUI but encountered the same problem again -- sites remain permanently blocked. 

I'm out of ideas.  For reference, my latest PKGBUILD follows:

pkgname=selfcontrol
pkgver=0.9
pkgrel=1
pkgdesc=""
arch=('any')
url="http://svn.jklmnop.net/projects/SelfControl.html"
license=('GPL' 'PerlArtistic')
depends=('perl>=5.10.0' 'at' 'ed' 'gtk2-perl' 'perl-yaml' 'iptables')
makedepends=('deb2targz')
source=(http://svn.jklmnop.net/projects/SelfControl/selfcontrol_0.9-1_all.deb)
md5sums=('d3c11e3811cb37f964af5ddc1f493e80')

build() {
# Make a tarball from the debian source file
   deb2targz ${srcdir}/selfcontrol_0.9-1_all.deb
# Expand the tarball
    tar xvzf ${srcdir}/selfcontrol_0.9-1_all.tar.gz
}

package() {
   cd "$srcdir/"
# Create directories and manually place all the files in required locations
    mkdir -p $pkgdir/etc/$pkgname
    install -Dm644 $srcdir/etc/init.d/$pkgname $pkgdir/etc/init.d/$pkgname
    install -Dm755 $srcdir/usr/bin/SelfControl $pkgdir/usr/bin/SelfControl
    mkdir -p $pkgdir/usr/share/perl5/vendor_perl/SelfControl
    cp -ra $srcdir/usr/share/perl5/SelfControl/*.pm $pkgdir/usr/share/perl5/vendor_perl/SelfControl
    install -Dm644 $srcdir/usr/share/perl5/SelfControl.pm $pkgdir/usr/share/perl5/vendor_perl/SelfControl.pm
    mkdir -p $pkgdir/usr/share/man/man3
    cp -ra $srcdir/usr/share/man/man3/*.gz $pkgdir/usr/share/man/man3/
    mkdir -p $pkgdir/usr/share/doc/$pkgname
    cp -ra $srcdir/usr/share/doc/$pkgname/*.* $pkgdir/usr/share/doc/$pkgname/
    cd "$srcdir/usr/share/applications/"
    sed -i 's:Icon=selfcontrol:Icon=selfcontrol.svg:' $pkgname.desktop
    install -Dm644 $srcdir/usr/share/applications/$pkgname.desktop $pkgdir/usr/share/applications/$pkgname.desktop
    install -Dm644 $srcdir/usr/share/icons/hicolor/scalable/apps/$pkgname.svg  $pkgdir/usr/share/pixmaps/$pkgname.svg
}

Offline

#11 2011-04-22 15:20:12

Stunts
Member
From: Portugal
Registered: 2009-03-28
Posts: 339
Website

Re: [REQUEST] SelfControl

I guess we're all dead in the water on this. Maybe the dev has some insightful input for this?
PS- I took a look at the .deb when building from source to rearrange the files. =-)

Offline

#12 2011-04-23 00:40:03

sportscliche
Member
From: Albuquerque, NM
Registered: 2010-11-30
Posts: 43

Re: [REQUEST] SelfControl

I verified that the selfcontrol debian binary installs with dpkg and works properly on Ubuntu (sites unblock after the pre-set time).  That means that it must (in principle) work on Arch and that the problem is not upstream.  I checked the Arch wiki on perl packaging and see that the .pm files are supposed to go in /usr/lib/perl5/vendor_perl/.  I tried installing the four .pm files there, ran the program, and again encountered the permanent site blockage problem.  On Ubuntu/Debian the .pm files are in /usr/share/perl5/.

Offline

#13 2011-04-25 08:30:51

sportscliche
Member
From: Albuquerque, NM
Registered: 2010-11-30
Posts: 43

Re: [REQUEST] SelfControl

I also found that if I re-boot the computer the site blocking can be cleared.  Logging off and logging back on will not fix it...must re-boot.

Offline

#14 2011-04-25 10:29:15

Stunts
Member
From: Portugal
Registered: 2009-03-28
Posts: 339
Website

Re: [REQUEST] SelfControl

Then you got further then I did. When I built the package I had to reboot the computer *and* clear the mess selfcontrol left in /etc/hosts.
Have you tired simply flushing the iptables rules? Maybe that will fix it, since it's something that happens when you reboot but not when you log off.

Offline

#15 2011-05-09 20:43:09

benji.ijneb
Member
Registered: 2008-12-13
Posts: 84

Re: [REQUEST] SelfControl

It's awesome to see so much happening! Perhaps we could point the developer in the direction of this thread and see what he makes of it?

Offline

#16 2011-05-09 21:59:32

Stunts
Member
From: Portugal
Registered: 2009-03-28
Posts: 339
Website

Re: [REQUEST] SelfControl

Sounds good to me. I will help in any way I can.

Offline

#17 2012-01-17 03:17:42

dontbugme
Banned
Registered: 2011-11-04
Posts: 166
Website

Re: [REQUEST] SelfControl

There's a direct port of SelfControl called SelfRestraint available now. It's currently available for Linux and Windows. You can read more at http://parker.kuivi.la/projects/selfrestraint.html and the source it on GitHub at https://github.com/ParkerK/selfrestraint/

Offline

Board footer

Powered by FluxBB