Skip to content

Commit

Permalink
portability: use interpreters from /usr/bin/env
Browse files Browse the repository at this point in the history
  • Loading branch information
nim65s committed Jul 23, 2024
1 parent c8c424c commit 40f2c62
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 43 deletions.
12 changes: 1 addition & 11 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,14 @@ stdenv.mkDerivation {
];
};

prePatch = ''
substituteInPlace scripts/auto-install-hpp.sh \
--replace-fail /bin/bash ${stdenv.shell}
substituteInPlace scripts/install-tar-on-remote \
--replace-fail /bin/bash ${stdenv.shell}
substituteInPlace scripts/generate-tar-doc \
--replace-fail /bin/sh ${stdenv.shell}
substituteInPlace scripts/packageDep \
--replace-fail /usr/bin/python ${python3Packages.python.interpreter}
'';

strictDeps = true;

nativeBuildInputs = [
cmake
doxygen
libsForQt5.wrapQtAppsHook
pkg-config
python3Packages.python
];
buildInputs = [ libsForQt5.qtbase ];
propagatedBuildInputs = [
Expand Down
2 changes: 1 addition & 1 deletion scripts/auto-install-hpp.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# Exit on error
set -e
Expand Down
2 changes: 1 addition & 1 deletion scripts/create-tags.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -e

Expand Down
2 changes: 1 addition & 1 deletion scripts/generate-tar-doc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash

# generate-tar-doc $DEVEL_HPP_DIR/install/share/doc http://gepettoweb.laas.fr/hpp
# then copy /tmp/hpp.tar.gz on server and inflate archive.
Expand Down
2 changes: 1 addition & 1 deletion scripts/install-tar-on-remote
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

VERSION="v4.6.0"
HOST=gepettoweb.laas.fr
Expand Down
65 changes: 37 additions & 28 deletions scripts/packageDep
Original file line number Diff line number Diff line change
@@ -1,44 +1,53 @@
#!/usr/bin/python
#!/usr/bin/env python3

from __future__ import print_function, with_statement

from optparse import OptionParser
import os
import re
import sys, os
import sys
from optparse import OptionParser

try: # python2
from commands import getstatusoutput
except: # python3
from subprocess import getstatusoutput

pkgConfigPath = os.environ.get("PKG_CONFIG_PATH")
pathList = re.split(':', pkgConfigPath)
pathList = re.split(":", pkgConfigPath)

usage = "usage: %prog [options] package-1 ... package-n"
parser = OptionParser(version="packageDep 0.1", usage=usage)

parser.add_option("-o", "--output", dest="filename",
help="write graph to FILE", metavar="FILE")
parser.add_option("-q", "--quiet", action="store_true", dest="quiet", default=False,
help="Do not print messages to stdout")
parser.add_option(
"-o", "--output", dest="filename", help="write graph to FILE", metavar="FILE"
)
parser.add_option(
"-q",
"--quiet",
action="store_true",
dest="quiet",
default=False,
help="Do not print messages to stdout",
)

(options, args) = parser.parse_args()

if options.filename is None:
parser.print_help()

if options.quiet:
sys.stdout = open(os.devnull, 'w')
sys.stdout = open(os.devnull, "w")

packageList = args
filename = options.filename

requireExpr = re.compile('(\s*Requires:\s+)(.+)')
pkgStdName = re.compile('\w+[\w\d\._-]*');
requireExpr = re.compile("(\s*Requires:\s+)(.+)")
pkgStdName = re.compile("\w+[\w\d\._-]*")

packageSet = set()
dependencySet = set()


def extractDep(inPkg):

packageSet.add(inPkg)
Expand All @@ -48,22 +57,22 @@ def extractDep(inPkg):

for path in pathList:
found = False
filePc = path+"/"+inPkg+".pc"
filePc = path + "/" + inPkg + ".pc"

try:
with open(filePc) as f:
for line in f:
matchLine = requireExpr.match(line)
if matchLine:
requireList = re.split(':', matchLine.group(0))
requireList = re.split(":", matchLine.group(0))
depLine = requireList[1]
depFullList = re.split(',', depLine)
depFullList = re.split(",", depLine)
for depFull in depFullList:
dep = pkgStdName.search(depFull)
if dep:
depName = dep.group(0)
depSet.add(depName)
depString = "\"" + depName + "\" -> \"" + inPkg + "\""
depString = '"' + depName + '" -> "' + inPkg + '"'
dependencySet.add(depString)

except IOError:
Expand All @@ -76,22 +85,22 @@ def extractDep(inPkg):

def getDocLink(package):
cmd = "pkg-config --variable=doxygendocdir " + package
status,output = getstatusoutput(cmd)
status, output = getstatusoutput(cmd)

if status != 0:
return ''
return ""

if output != '':
if output != "":
return output

cmd = "pkg-config --variable=docdir " + package
status,output = getstatusoutput(cmd)
status, output = getstatusoutput(cmd)

if status != 0:
return ''
return ""

if output != '':
return output + '/html'
if output != "":
return output + "/html"
return output


Expand All @@ -103,24 +112,24 @@ for pkg in packageList:
#

try:
f = open(filename, 'w')
f = open(filename, "w")
except IOError:
print("cannot open ", filename)

f.write("digraph CD {\n")
f.write("\tsize = \"12,15\"\n")
f.write('\tsize = "12,15"\n')
f.write("\trankdir = BT\n")
f.write("\tcompound=true\n")
f.write("\n")

for package in packageSet:
docLink = getDocLink(package)
if docLink != '':
docLink = docLink + '/index.html'
f.write("\t\"" + package + "\" [shape = box, href = \"" + docLink + "\"]\n")
if docLink != "":
docLink = docLink + "/index.html"
f.write('\t"' + package + '" [shape = box, href = "' + docLink + '"]\n')


for dependency in dependencySet:
f.write("\t" + dependency + "\n");
f.write("\t" + dependency + "\n")

f.write("}\n")

0 comments on commit 40f2c62

Please sign in to comment.