Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 27432 - python rewrite of distcc-config
Summary: python rewrite of distcc-config
Status: VERIFIED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: High enhancement (vote)
Assignee: Lisa Seelye (RETIRED)
URL:
Whiteboard:
Keywords:
: 36504 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-08-27 09:20 UTC by Markus Nigbur (RETIRED)
Modified: 2004-01-11 14:26 UTC (History)
5 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
python rewrite (distcc-config,3.49 KB, text/plain)
2003-08-27 09:21 UTC, Markus Nigbur (RETIRED)
Details
python rewrite (distcc-config,3.47 KB, text/plain)
2003-08-29 20:38 UTC, Markus Nigbur (RETIRED)
Details
Make /etc/distcc/hosts newline terminated. Enhanced Usage. (distcc.patch,1.67 KB, patch)
2003-09-11 06:21 UTC, Rob Davies
Details | Diff
python rewrite (distcc-config,4.24 KB, application/octet-stream)
2003-09-19 17:02 UTC, Markus Nigbur (RETIRED)
Details
python rewrite (distcc-config,4.55 KB, application/octet-stream)
2003-10-06 04:36 UTC, Markus Nigbur (RETIRED)
Details
python rewrite (distcc-config,4.58 KB, text/plain)
2003-10-17 03:10 UTC, Markus Nigbur (RETIRED)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Nigbur (RETIRED) gentoo-dev 2003-08-27 09:20:02 UTC
initial release :)
Comment 1 Markus Nigbur (RETIRED) gentoo-dev 2003-08-27 09:21:17 UTC
Created attachment 16695 [details]
python rewrite
Comment 2 Lisa Seelye (RETIRED) gentoo-dev 2003-08-27 09:22:32 UTC
Hi yall, please test this. :)
Comment 3 Disenchanted (RETIRED) gentoo-dev 2003-08-29 10:21:30 UTC
distcc-config when invoked w/o options should list the available option as --help does, as distcc-config w/o options has no use
Comment 4 Markus Nigbur (RETIRED) gentoo-dev 2003-08-29 20:38:14 UTC
Created attachment 16792 [details]
python rewrite

thanks, included.
Comment 5 Lisa Seelye (RETIRED) gentoo-dev 2003-09-09 10:25:59 UTC
--get-hosts and --set-hosts should not print anything ("such and such is...").

DISTCC_DIR would be great if it could be a global constant so its a bit easier to change.  If DISTCC_DIR does not exist it must be created with 1777 perms, owned by root (in the functions --set-env and --install and whatever.)

The config needs a --set-env command:  --set-env FOO VALUE will update /etc/env.d/02_distcc to include FOO=VALUE.



It also needs a Gentoo header. :)
Comment 6 Rob Davies 2003-09-11 06:21:47 UTC
Created attachment 17490 [details, diff]
Make /etc/distcc/hosts newline terminated. Enhanced Usage.  

The patch though small was tested with emerge.
Comment 7 Rob Davies 2003-09-11 06:25:14 UTC
I've tried it out, and I found a few things, perhaps because I am using distcc 
for first time, so had no expectations about how it would work.  These are my 
impressions  :) 
 
The patch is to address points 1) & 4) only. 
 
By the way, it has set me up, which is the main thing, and though I've a few 
points, that's inevitable once I had to tinkering with the source.  Let me know 
if you'ld like further submissions, addressing issues I've pointed out (yes, 
even the dreaded documentation). 
 
 
1)  The --install option seems necessary, and it's not in Usage 
 
 
2)  Documentation Guide http://www.gentoo.org/doc/en/distcc.xml 
 
I found I needed to look at the script source to figure out how to use it. 
 
a) I set the hosts, got the print message and nothing happened.  Looks like 
--install is necessary.  There wasn't a file made if I --set-hosts.  The 
section on bootstrapping with distcc does have a mention of --install. 
 
b) Server side; the guide should explain that distccd needs to be set up, 
minimum reminder about /etc/{conf,init}.d/distc, and hint about adding distcdd 
to runlevel. 
 
c) Quote terminator missing? 
 
Code listing 2.3: Sample command to set the hosts 
 
# /usr/bin/distcc-config --set-hosts "192.168.0.1 192.168.0.2 192.168.0.3 
 
d) No mention of log file 
 
 
3)  Using the --set-verbose 1 option to see what going on I got : 
 
oak gentoo # python distcc-config.py --set-verbose 1 --install 
Traceback (most recent call last): 
  File "distcc-config.py", line 88, in ? 
    writeenv('DISTCC_VERBOSE',tmpcmdline[1]) 
  File "distcc-config.py", line 37, in writeenv 
    distcc_env    = open(envfile, 'r').readlines() 
IOError: [Errno 2] No such file or directory: '/etc/env.d/02distcc' 
oak gentoo # python distcc-config.py --install 
Creating /etc/env.d/02distcc ... 
 
Looks like account should be taken that /etc/env.d/02distcc may not exist. 
 
 
4) /etc/distcc/hosts 
 
It's entry is written without a \n line terminator, this confused my vi editor 
(nvi), unlike  nano it didn't display anything, which seems to add termination 
to last line if missing. 
 
 
5) On the interface design. 
 
I'm not sure why it's necesary to make options mutually exclusive.  For example 
it ought to be perfectly reasonable to : 
 
distcc-config --install --set-hosts "127.0.0.2/4 10.0.0.1/2 10.0.0.2/2" 
 
As it is, the user has to run distcc-config multiple times, and understand that 
it's actually creating various environment files.  If fact, why doesn't 
--set-hosts implicitly do a --install, if stuff is missing?  It's what the user 
wants to do!  Perhaps distcc-config --install host1 host2/2 .. hostN, then you 
can have a sensible default for : 
 
distcc-config 10.0.0.9/4 10.0.0.8/2 10.0.0.7/2 
 
Wouldn't that be the most common usage?  Most users won't change the log file, 
or verbosity, and not providing short flag alternatives adds error prone 
typing. 
 
 
Standard kind of pattern for option processing flags and values is : 
 
Initalise option map to set defaults. 
loop through command line switches 
    validate option 
    If flag option 
       set options{ current } on 
    else 
       get option value 
       set options{ current } to option value 
 
Do processing modified by flags, for example are we listing or setting things?  
In C and perl there's access to standard modules getopt_long for arg processing 
which does help a fair bit.  I've just checked Programming Python, doesn't talk 
about it, but presumably there's some binding to get access to getopt_long(3) 
in glibc. The getopt_long() function works like getopt() except that it also 
accepts long options, started out by two dashes. Long option names may be 
abbreviated if the abbreviation is unique or is an exact match for some defined 
option. A long option may take a parameter, of the form --arg=param or --arg 
param. 
Comment 8 Markus Nigbur (RETIRED) gentoo-dev 2003-09-19 17:02:21 UTC
Created attachment 18006 [details]
python rewrite

Issues of comment #5 fixed.
Added the new line character and fixed the 'usage' to uppercase as in the patch
of comment #6.
Comment 9 Markus Nigbur (RETIRED) gentoo-dev 2003-09-19 17:05:17 UTC
--install runs once to setup the initial distcc environment. it's called from the distcc ebuild. All problems are related to the fact, that it wasn't called, because the current distcc-config script handles the installation in several subroutines.
Comment 10 Lisa Seelye (RETIRED) gentoo-dev 2003-10-04 10:31:41 UTC
if the user is not root, --set-hosts should set ~/.distcc/hosts

further

for --get-hosts, if 
$DISTCC_HOSTS is not null, return that, else
~/.distcc/hosts is not empty, return contents, else
return contents of /etc/distcc/hosts
Comment 11 Markus Nigbur (RETIRED) gentoo-dev 2003-10-06 04:36:47 UTC
Created attachment 18852 [details]
python rewrite

your wish is my command.
Comment 12 Markus Nigbur (RETIRED) gentoo-dev 2003-10-11 01:47:36 UTC
Reminder:
Restart daemon after upgrade.
Comment 13 Lisa Seelye (RETIRED) gentoo-dev 2003-10-16 18:12:35 UTC
Also, DISTCC_DIR should be removed from the /etc/env.d/02distcc file.


	distcc_env.write('DISTCC_DIR="/tmp"\n')
	
	createdistccdir('/tmp')

can be removed

I also got this Traceback error when using the distcc-config in atttachment
18852 : (Use an unmodified 2.11 ebuild with this distcc-config)

Traceback (most recent call last):
  File "/usr/bin/distcc-config", line 111, in ?
    open(FILE, 'w').write(cmdline + '\n')
TypeError: can only concatenate list (not "str") to list

Furthermore, with a modified ebuild to just run --install this is the output:

Traceback (most recent call last):
  File "/usr/bin/distcc-config", line 111, in ?
    open(FILE, 'w').write(cmdline + '\n')
TypeError: can only concatenate list (not "str") to list
 * Installing links to native compilers...
Creating /etc/env.d/02distcc ...
Creating /usr/lib/distcc/bin/gcc symlink...
Already exists. Skipping...
Creating /usr/lib/distcc/bin/cc symlink...
Already exists. Skipping...
Creating /usr/lib/distcc/bin/c++ symlink...
Already exists. Skipping...
Creating /usr/lib/distcc/bin/g++ symlink...
Already exists. Skipping...
Creating /usr/lib/distcc/bin/i586-pc-linux-gnu-gcc symlink...
Already exists. Skipping...
Creating /usr/lib/distcc/bin/i586-pc-linux-gnu-c++ symlink...
Already exists. Skipping...
Creating /usr/lib/distcc/bin/i586-pc-linux-gnu-g++ symlink...
Already exists. Skipping...
Configuring /usr/lib/distcc/bin/.keep...
Configuring /usr/lib/distcc/bin/gcc...
Configuring /usr/lib/distcc/bin/cc...
Configuring /usr/lib/distcc/bin/c++...
Configuring /usr/lib/distcc/bin/g++...
Configuring /usr/lib/distcc/bin/i686-pc-linux-gnu-gcc...
Configuring /usr/lib/distcc/bin/i686-pc-linux-gnu-c++...
Configuring /usr/lib/distcc/bin/i686-pc-linux-gnu-g++...
Configuring /usr/lib/distcc/bin/i586-pc-linux-gnu-gcc...
Configuring /usr/lib/distcc/bin/i586-pc-linux-gnu-c++...
Configuring /usr/lib/distcc/bin/i586-pc-linux-gnu-g++...
Configuring /var/run/distccd/.keep...

---

Can the output be silenced a bit? And what's it doing to /var/run/distccd/.keep?
Comment 14 Lisa Seelye (RETIRED) gentoo-dev 2003-10-16 23:02:28 UTC
Also, DISTCC_LOG should not be set to anything by default.
Comment 15 Markus Nigbur (RETIRED) gentoo-dev 2003-10-17 03:10:12 UTC
Created attachment 19348 [details]
python rewrite

fixed everything and added restart of distccd after call of --install. :)
Comment 16 Lisa Seelye (RETIRED) gentoo-dev 2003-10-18 13:19:12 UTC
Committed in CVS as distcc-2.11.1-r1, its in package.mask, so you will have
to force it:

  emerge /usr/portage/sys-devel/distcc/distcc-2.11.1-r1.ebuild

Comment 17 Joe Stroller 2003-10-18 15:09:39 UTC
Have been testing here for the last 36 hours or so with compiles of a couple
of small apps, then kdelibs & glibc on different machines. Seem to work fine.
Comment 18 Lisa Seelye (RETIRED) gentoo-dev 2003-11-12 12:33:35 UTC
Just a formal reminder to create /etc/distcc or ~/.distcc if they aren't present.
Comment 19 Lisa Seelye (RETIRED) gentoo-dev 2003-11-12 12:34:06 UTC
reopened waiting a fix for comment 18 :-)
Comment 20 ferret 2003-11-12 17:19:59 UTC
I'm having a problem with the distccd init script not creating a pid file. I did:  emerge =distcc-2.11.2 /sbin/depscan.sh # told me to do so at the end of emerge, for some reason nano -w /etc/make.conf # added -jX to MAKEOPTS, added distcc to FEATURES /usr/sbin/distcc-config --set-hosts "xxx.xxx.xxx.xxx ..." /etc/init.d/distccd start # appears to work but doesn't create pidfile /etc/init.d/distccd stop # "succeeds" but doesn't stop processes /etc/init.d/distccd start # fails  Manually creating the pidfile containing the correct value and it all works...
Comment 21 ferret 2003-11-12 17:24:23 UTC
argh, links -g has retarded key bindings of some sort. My carriage returns were
destroyed. :|
Comment 22 Markus Nigbur (RETIRED) gentoo-dev 2003-11-16 15:21:53 UTC
worked.

marked stable in x86
Comment 23 Lisa Seelye (RETIRED) gentoo-dev 2003-11-21 20:46:53 UTC
this is in as distcc-2.11.2-r1

thanks a lot Markus and testers.
Comment 24 Maurice van der Pot (RETIRED) gentoo-dev 2003-12-09 14:41:27 UTC
I have some additional comments about distcc-config.
I'm only using distcc with portage.

After I've emerged distcc, if I do (as root) distcc-config --get-hosts or distcc-config --set-hosts "10.0.0.2", I get errors. The error for --get-hosts looks sorta like this:

Traceback (...): 
blahblah... 
print rstrip(open('/etc/distcc/hosts', 'r').read()) 
blahblah no such file or directory

The message I get with --set-hosts is similar (although I don't think I saw a filename in that error message).

At this time the /etc/distcc directory does not exist.
If I create this directory and try again, only --get-hosts still fails (because the hosts file doesn't exist).

Once I've --set-hosts, also --get-hosts succeeds.

I think the script needs some additional checks.

# $Header: /home/cvsroot/gentoo-x86/sys-devel/distcc/files/2.11.1p/distcc-config,v 1.3 2003/12/06 17:31:04 lisa Exp $

How to reproduce (probably):
1) remove or rename /etc/distcc
2) run distcc-config --get-hosts or distcc-config --set-hosts "10.0.0.2"
3) mkdir /etc/distcc
4) run distcc-config --get-hosts
Comment 25 Lisa Seelye (RETIRED) gentoo-dev 2003-12-09 14:49:05 UTC
Markus?
Comment 26 Markus Nigbur (RETIRED) gentoo-dev 2003-12-11 07:52:17 UTC
nice catch. fixed it in cvs.
Comment 27 Lisa Seelye (RETIRED) gentoo-dev 2003-12-18 14:24:54 UTC
Nother bug.

Running distcc-config --install with no distcc user in the /etc/passwd (such as during bootstrap) results in:

Creating /etc/env.d/02.distcc...
Traceback...
   File "/usr/bin/distcc-config", line 134, in ?
     foobar = getpwnam('distcc')
KeyError: getpwnam(): name not found
Comment 28 Lisa Seelye (RETIRED) gentoo-dev 2003-12-18 14:38:50 UTC
Another bug:

# distcc-config --set-hosts " .... "
Traceback...
  File /usr/bin/distcc-config, line 153, in ?
    createdistccidr(PATH)
  File /usr/bin/distcc-config, line 85, in createdistccdir
    os.chmod(dir, '1777')
TypeError: an integer is required

This is on a bootstrap, with a virgin make.conf aside from FEATURES, MAKEOPTS, and USE changes.

/etc/distcc/ exists.

after this dir is created /var/tmp/portage/.distcc does not.
Comment 29 Markus Nigbur (RETIRED) gentoo-dev 2003-12-19 03:49:02 UTC
lisa, what distcc-config cvs revision were you using at comment #28?
I just fixed this 7 days ago.

the one in comment #27.. well we should consider an additional flag for bootstrapping or something. isn't --install called while using the distcc ebuild from bootstrap?

i actually hadn't the time to test the script while bootstrapping.

.. i'll catch you on irc.
Comment 30 Vaclav Slavik 2003-12-26 08:35:51 UTC
> lisa, what distcc-config cvs revision were you using at comment #28?
> I just fixed this 7 days ago.

But it is still in Portage tree fetched via rsync, today.
Comment 31 Joshua Kinard gentoo-dev 2003-12-27 15:18:19 UTC
Here's an obscure bug.

If /etc/distcc does not exist, then invoking:
distcc-config --set-hosts "hostname>/<num jobs>" will trigger a python traceback ONLY once.  Any further invocations works fine.

[root@minas-tirith distfiles]# distcc-config --set-hosts "isengard/4"
Traceback (most recent call last):
  File "/usr/bin/distcc-config", line 113, in ?
    createdistccdir(PATH)
  File "/usr/bin/distcc-config", line 85, in createdistccdir
    os.chmod(dir, '1777')
TypeError: an integer is required
[root@minas-tirith distfiles]# distcc-config --set-hosts "isengard/4"
[root@minas-tirith distfiles]#
[root@minas-tirith distfiles]# rm -Rf /etc/distcc
[root@minas-tirith distfiles]# distcc-config --set-hosts "isengard/4"
Traceback (most recent call last):
  File "/usr/bin/distcc-config", line 113, in ?
    createdistccdir(PATH)
  File "/usr/bin/distcc-config", line 85, in createdistccdir
    os.chmod(dir, '1777')
TypeError: an integer is required
[root@minas-tirith distfiles]#


Using a straight IP address instead of the histname during the first call doesn't trigger the bug either.
Comment 32 Markus Nigbur (RETIRED) gentoo-dev 2003-12-27 15:46:29 UTC
verfied fixed.
Comment 33 Lisa Seelye (RETIRED) gentoo-dev 2003-12-31 09:50:23 UTC
*** Bug 36504 has been marked as a duplicate of this bug. ***
Comment 34 Markus Nigbur (RETIRED) gentoo-dev 2004-01-11 07:59:48 UTC
all issues should be fixed.
Comment 35 Lisa Seelye (RETIRED) gentoo-dev 2004-01-11 14:26:36 UTC
All issues with the Python rewrite of distcc-config should be filed in a new bug.