On the dangers of PKGNAME=.

Adriaan de Groot <adridg-FlD2LfDziEhmR6Xm/[email protected]>
Newsgroups gmane.comp.tools.aap.devel
Message-ID <[email protected]>
Since an empty PKGNAME isn't allowed, yet KDE expects to put things directly 
under $PREFIX/share and not in $PREFIX/share/$PKGNAME (It's often installed 
in a separate prefix entirely, so having $PKGNAME in there would be 
redundant), I've been reduced to setting PKGNAME=. in KDE recipes.

This triggers a bug, though:

eggs.ebn.kun.nl$aap install PREFIX=/tmp/kde
Aap: Creating directory "/tmp/kde/share/./apps/kpilot/sysinfoconduit"
Aap: Internal Error
Aap: Traceback (most recent call last):
   File "/home/adridg/aap/Exec-cvs/Process.py", line 1115, in Process
    exec script_string in recdict, recdict
   File "<string>", line 12, in ?
   File "/home/adridg/aap/Exec-cvs/RecPython.py", line 1022, in install_files
    os.makedirs(destloc)
   File "/usr/local/lib/python2.2/os.py", line 203, in makedirs
    makedirs(head, mode)
   File "/usr/local/lib/python2.2/os.py", line 203, in makedirs
    makedirs(head, mode)
   File "/usr/local/lib/python2.2/os.py", line 203, in makedirs
    makedirs(head, mode)
   File "/usr/local/lib/python2.2/os.py", line 204, in makedirs
    mkdir(name, mode)
 OSError: [Errno 17] File exists: '/tmp/kde/share/.'

I imagine this is because makedirs recurses and makes each component of the 
requested path, and /tmp/kde/share and /tmp/kde/share/., while separate 
components, are the same directory. The attached patch adds a special-case 
for PKGNAME=. to default.aap; it's probably not the best solution. It's 
probably better to catch OSError File exists exceptions in make_installdirs 
and deal with it there. I'll send a different patch shortly.
default.diff (text/x-diff, 926 B)
Index: default.aap
===================================================================
RCS file: /cvsroot/a-a-p/Exec/default.aap,v
retrieving revision 1.54
diff -u -3 -p -r1.54 default.aap
--- default.aap	1 Oct 2003 17:13:52 -0000	1.54
+++ default.aap	22 Oct 2003 06:17:30 -0000
@@ -578,12 +578,18 @@ DATAMODE ?= 0644
 :action installdata default 
     @if not _no.get("PKGNAME"):
 	:error For installing data you must set $($)PKGNAME
-    dest = $DATADIR$PKGNAME
+    @if _no.get("PKGNAME") == ".":
+	dest = $DATADIR
+    @else:
+        dest = $DATADIR$PKGNAME
     @install_files(dest, source, _no.DATAMODE)
 :action uninstalldata default
     @if not _no.get("PKGNAME"):
 	:error For installing data you must set $($)PKGNAME
-    dest = $DATADIR$PKGNAME
+    @if _no.get("PKGNAME") == ".":
+	dest = $DATADIR
+    @else:
+        dest = $DATADIR$PKGNAME
     @uninstall_files(dest, source)
 
 # :do installman/uninstallman
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.