You are not logged in.

#1 2014-08-19 03:18:24

dfeng
Member
Registered: 2012-06-18
Posts: 23

[Solved] package required: ChinaDNS ( in AUR repo )

I live in China where the GFW blocks many good services overseas.
I need and like a small tool ChinaDNS to get rid of dns pollution.
https://github.com/clowwindy/ChinaDNS
I'm not good at packaging and programming.
Can somebody help to make this package?

Last edited by dfeng (2014-08-19 21:26:10)

Offline

#2 2014-08-19 03:24:15

headkase
Member
Registered: 2011-12-06
Posts: 1,988

Re: [Solved] package required: ChinaDNS ( in AUR repo )

See Legality at the bottom.  It would be against local Chinese laws to circumvent the Great Fire Wall.  However, the cultural values of the West do not agree with the GFW so there is a disconnect over which should be applied to your thread.

Offline

#3 2014-08-19 03:48:17

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: [Solved] package required: ChinaDNS ( in AUR repo )

Moving to AUR Issues...


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#4 2014-08-19 05:27:42

dfeng
Member
Registered: 2012-06-18
Posts: 23

Re: [Solved] package required: ChinaDNS ( in AUR repo )

@headkase, no laws but only government orders which are actually against the constitution in China are about the GFW. and the government has never admitted the existence of GFW.
@jasonwryan, thx.

Last edited by dfeng (2014-08-19 13:48:10)

Offline

#5 2014-08-19 07:13:02

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: [Solved] package required: ChinaDNS ( in AUR repo )

dfeng wrote:

I'm not good at packaging and programming.

Well, you don't need any programming skills for this. When you say you're "not good at packaging", does that mean you have tried and it didn't go so well? There are a million¹ examples of packages built with setup.py in the Arch repos and the AUR, I'd suggest you use any or all of them for inspiration.

¹Exaggeration - there are actually only half a million.

Offline

#6 2014-08-19 07:28:07

ooo
Member
Registered: 2013-04-10
Posts: 1,638

Re: [Solved] package required: ChinaDNS ( in AUR repo )

I got it to build and install fine, but got an error about shadowsocks when I tried to run it.
also I'm not sure whether it should depend on python or python2, which could be part of the issue.

anyway, here's the PKGBUILD if anyone wants to work on it

pkgname=chinadns-git
_realname=ChinaDNS
pkgver=20140808
pkgrel=1
pkgdesc="Fix weird things with DNS in China"
arch=('any')
url="https://github.com/clowwindy/ChinaDNS"
license=('custom')
depends=('python' 'shadowsocks')
makedepends=('git' 'python-setuptools')
source=('git+https://github.com/clowwindy/ChinaDNS.git')
md5sums=('SKIP')

pkgver() {
  cd "$srcdir/$_realname"
  git log -1 --format="%cd" --date=short | tr -d -
}

package() {
  cd "$srcdir/$_realname"
  python setup.py install --root="$pkgdir/" --optimize=1
}

Offline

#7 2014-08-19 13:44:14

dfeng
Member
Registered: 2012-06-18
Posts: 23

Re: [Solved] package required: ChinaDNS ( in AUR repo )

@tomk, Because of lack of skills, I have to spend hours of searching and learning to make a package. However, an expert like you can make it within half an hour.
@ooo, In setup.py, it requires shadowsocks==2.0.11 and depends on python2.7. shadowsocks is in the community repo.
https://www.archlinux.org/packages/comm … adowsocks/

Last edited by dfeng (2014-08-19 17:34:34)

Offline

#8 2014-08-19 15:41:40

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: [Solved] package required: ChinaDNS ( in AUR repo )

dfeng wrote:

I have to spend hours of searching and learning to make a package.

OK, if you say so. That's why I suggested you take a short cut by examining how similar packages are built. But never mind, you got someone else to do it for you, so everyone's happy.

Offline

#9 2014-08-19 19:44:46

dfeng
Member
Registered: 2012-06-18
Posts: 23

Re: [Solved] package required: ChinaDNS ( in AUR repo )

Learning from https://www.archlinux.org/packages/comm … adowsocks/
I have maked this:
PKGBUILD

# $Id$
# Maintainer: dfeng

pkgname=chinadns
pkgver=0.2.0
pkgrel=1
pkgdesc="A DNS forwarder that ignores incorrect(you know it) responses."
license=("MIT")
url="http://pypi.python.org/pypi/chinadns"
depends=('shadowsocks')
source=("http://pypi.python.org/packages/source/c/chinadns/chinadns-${pkgver}.tar.gz"
        "$pkgname-LICENSE::https://raw.github.com/clowwindy/ChinaDNS/master/LICENSE"
        "chinadns.service")
arch=('any')
install=${pkgname}.install

prepare() {
  # python2 fix
  cd "$srcdir/chinadns-$pkgver/chinadns"
  sed -e 's_#!/usr/bin/env python$_#!/usr/bin/env python2_' \
      -e 's_#!/usr/bin/python$_#!/usr/bin/python2_' \
      -i dnsrelay.py __init__.py
  # shadowsocks version fix
  cd "$srcdir/chinadns-$pkgver"
  sed -e 's_shadowsocks==2.0.11_shadowsocks>=2.0.11_' \
      -i setup.py
  cd "$srcdir/chinadns-$pkgver/chinadns.egg-info"
  sed -e 's_shadowsocks==2.0.11_shadowsocks>=2.0.11_' \
      -i requires.txt
}

package() {
  cd "$srcdir/chinadns-$pkgver"
  python2 setup.py install -O1 --root="$pkgdir"
  
  install -Dm644 "$srcdir/chinadns.service" "$pkgdir/usr/lib/systemd/system/chinadns.service"
  install -Dm644 "$srcdir/$pkgname-LICENSE" "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}

sha512sums=('52f6a592d62e2c49fc8ffc39212313a0613fcab7a99ba4b77e6a2c093b2751b49f72fe55b341f1a89cc9876d06954041b4524c482ed750c29db1fe631309ac27'
            '88abf42d51d7b7baa2b9cef016bfd194373fd178980c2c6f1bbb3ce31d3267dfca71efb013c6596c57c0390fdb95d716ff4acca97bdf960e56e9edf16f770352'
            '558f9de2a3df444a840e89d9bbe094931dff939fc37ffebc81653390adbd4bbc9b82f252ace6e1ccc350a4a4e9fd5d08fa368ce973257694628660a305852da8')

chinadns.install

post_install() {
    echo "# systemctl start/stop chinadns.service"
}

chinadns.service

[Unit]
Description=ChinaDNS Service
After=network.target

[Service]
Type=simple
User=nobody
ExecStart=/usr/bin/chinadns

[Install]
WantedBy=multi-user.target

It's builded and installed fine.
But the service failed to run

$ sudo systemctl status chinadns
● chinadns.service - ChinaDNS Service
   Loaded: loaded (/usr/lib/systemd/system/chinadns.service; enabled)
   Active: failed (Result: exit-code) since ****** 5s ago
  Process: 5749 ExecStart=/usr/bin/chinadns (code=exited, status=1/FAILURE)
 Main PID: 5749 (code=exited, status=1/FAILURE)

But it actually works.

$ sudo /usr/bin/chinadns
2014-08-20 03:36:57 INFO     starting dns at 127.0.0.1:53
2014-08-20 03:37:10 INFO     request www.youtube.com
2014-08-20 03:37:10 INFO     response from 8.8.8.8 www.youtube.com: [('37.61.54.158', 1, 1)]
2014-08-20 03:37:10 INFO     response from 8.8.8.8 www.youtube.com: [('59.24.3.173', 1, 1)]
2014-08-20 03:37:10 INFO     response from 114.114.114.114 www.youtube.com: [('youtube-ui.l.google.com', 5, 1), ('youtube-ui-china.l.google.com', 5, 1), ('37.61.54.158', 1, 1)]
2014-08-20 03:37:10 INFO     response from 8.8.8.8 www.youtube.com: [('youtube-ui.l.google.com', 5, 1), ('youtube-ui-china.l.google.com', 5, 1), ('173.194.72.139', 1, 1), ('173.194.72.101', 1, 1), ('173.194.72.102', 1, 1), ('173.194.72.100', 1, 1), ('173.194.72.138', 1, 1), ('173.194.72.113', 1, 1)]
2014-08-20 03:37:10 INFO     response from 208.67.222.222 www.youtube.com: [('youtube-ui.l.google.com', 5, 1), ('youtube-ui-china.l.google.com', 5, 1), ('74.125.31.102', 1, 1), ('74.125.31.100', 1, 1), ('74.125.31.113', 1, 1), ('74.125.31.101', 1, 1), ('74.125.31.138', 1, 1), ('74.125.31.139', 1, 1)]

What's wrong?

Offline

#10 2014-08-19 21:01:54

dfeng
Member
Registered: 2012-06-18
Posts: 23

Re: [Solved] package required: ChinaDNS ( in AUR repo )

Sorry, I have turn off journal log, so miss some important message.

sudo journalctl _PID=672
-- Logs begin at ***, end at ***. --
*** DFENG chinadns[672]: *** INFO     starting dns at 127.0.0.1:53
*** DFENG chinadns[672]: *** ERROR    [Errno 13] Permission denied
*** DFENG chinadns[672]: *** INFO     please use sudo to run this program

To fix it, just delete  User=nobody in chinadns.service:
chinadns.service

[Unit]
Description=ChinaDNS Service
After=network.target

[Service]
Type=simple
ExecStart=/usr/bin/chinadns

[Install]
WantedBy=multi-user.target

Offline

#11 2014-08-19 21:23:03

dfeng
Member
Registered: 2012-06-18
Posts: 23

Re: [Solved] package required: ChinaDNS ( in AUR repo )

@westmin helps me to make this package into AUR. Thx all guys.
https://aur.archlinux.org/packages/chinadns/
If you like it, pls vote. with more votes to make it into community repo. ^_^

Offline

Board footer

Powered by FluxBB