projects.py: Allow projects with non-existing project directory

proj_dir() raises an exception for projects which don't have a dedicated
project directory, even though for some projects this is legal. php-cli, for
instance, only installs stuff below /srv/www/proj/php-cli.

This commit makes projects.py tolerate that.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2025-03-30 12:24:10 +00:00
commit 8b8f1cc306

View file

@ -110,6 +110,9 @@ class Projects(object):
r = d + '/' + name r = d + '/' + name
if os.path.exists(r): if os.path.exists(r):
return r return r
if os.path.exists(f'/usr/share/doc/packages/{name}/VERSION'):
# The package exists but does not have a dedicated project directory
return None
raise Exception('No project path found for module "{}"'.format(name)) raise Exception('No project path found for module "{}"'.format(name))
def re_section(self, name): def re_section(self, name):
@ -142,6 +145,8 @@ class Projects(object):
# TODO: add support for customizing this in project.conf # TODO: add support for customizing this in project.conf
def htdocs_dir(self, name): def htdocs_dir(self, name):
pd = self.proj_dir(name) pd = self.proj_dir(name)
if pd is None:
return None
for r in [ pd + "/tools/html/htdocs", pd + "/htdocs", "/srv/www/proj/" + name ]: for r in [ pd + "/tools/html/htdocs", pd + "/htdocs", "/srv/www/proj/" + name ]:
if isdir(r): if isdir(r):
return r return r
@ -704,7 +709,10 @@ class Projects(object):
scope = 2, add_self=True, names_only=True) scope = 2, add_self=True, names_only=True)
r = '' r = ''
for m in deps: for m in deps:
r = r + ':' + self.proj_dir(m) + '/lib' pd = self.proj_dir(m)
if pd is None:
continue
r = r + ':' + pd + '/lib'
print(r[1:]) print(r[1:])
def cmd_pythonpath(self, args_): def cmd_pythonpath(self, args_):
@ -715,9 +723,11 @@ class Projects(object):
scope = 2, add_self=True, names_only=True) scope = 2, add_self=True, names_only=True)
r = '' r = ''
for m in deps: for m in deps:
pdir = self.proj_dir(m) pd = self.proj_dir(m)
if pd is None:
continue
for subdir in [ 'src/python', 'tools/python' ]: for subdir in [ 'src/python', 'tools/python' ]:
cand = pdir + "/" + subdir cand = pd + "/" + subdir
if isdir(cand): if isdir(cand):
r = r + ':' + cand r = r + ':' + cand
print(r[1:]) print(r[1:])
@ -731,7 +741,10 @@ class Projects(object):
self.debug('deps = ', deps) self.debug('deps = ', deps)
r = '' r = ''
for m in deps: for m in deps:
r = r + ':' + self.proj_dir(m) + '/bin' pd = self.proj_dir(m)
if pd is None:
continue
r = r + ':' + pd + '/bin'
print(r[1:]) print(r[1:])
def cmd_libname(self, args_): def cmd_libname(self, args_):
@ -758,9 +771,12 @@ class Projects(object):
r = '' r = ''
for m in reversed(deps): for m in reversed(deps):
try: try:
r = r + ' -I' + self.proj_dir(m) + '/include' pd = self.proj_dir(m)
except: if pd is None:
self.warn('No include path for module "{}", ignoring'.format(m)) continue
r = r + ' -I' + pd + '/include'
except Exception as e:
self.warn(f'No include path for module "{m}", ignoring: {e}')
print(r[1:]) print(r[1:])
def cmd_path(self, args_): def cmd_path(self, args_):
@ -771,7 +787,10 @@ class Projects(object):
scope = 2, add_self=True, names_only=True) scope = 2, add_self=True, names_only=True)
r = '' r = ''
for m in deps: for m in deps:
r = r + ':' + self.proj_dir(m) + '/bin' pd = self.proj_dir(m)
if pd is None:
continue
r = r + ':' + pd + '/bin'
print(r[1:]) print(r[1:])
# TODO: seems at least partly redundant to cmd_pkg_requires / print_pkg_relations # TODO: seems at least partly redundant to cmd_pkg_requires / print_pkg_relations
@ -834,9 +853,12 @@ class Projects(object):
r = [] r = []
for m in args.module: for m in args.module:
try: try:
r.append(self.proj_dir(m)) pd = self.proj_dir(m)
except: if pd is None:
self.warn('No project directory for module "{}"'.format(module)) continue
r.append(pd)
except Exception as e:
self.warn(f'No project directory for module "{module}: {e}')
continue continue
print(' '.join(r)) print(' '.join(r))