[javapackages] Initial attempt to integrate bundling-detection tool
by Michal Srb
commit a6d6c500cc63b4218cfe891b9fd22c6a5e7c8def
Author: Michal Srb <msrb(a)redhat.com>
Date: Wed Jun 24 21:49:17 2015 +0200
Initial attempt to integrate bundling-detection tool
depgenerators/maven.req | 25 ++++++++++++++++++++++++-
1 files changed, 24 insertions(+), 1 deletions(-)
---
diff --git a/depgenerators/maven.req b/depgenerators/maven.req
index c144c0d..50ee30e 100755
--- a/depgenerators/maven.req
+++ b/depgenerators/maven.req
@@ -40,7 +40,9 @@ import traceback
from javapackages.common.config import get_config
from javapackages.common.util import (kill_parent_process,
init_rpmgen,
- get_logger)
+ get_logger,
+ get_buildroot_files,
+ execute_command)
from javapackages.cache.metadata import MetadataCache
from javapackages.maven.pom import POM
from javapackages.maven.dependency import Dependency
@@ -66,6 +68,27 @@ class TagBuilder(object):
self.provided_osgi = cache.get_provided_osgi()
self.metadata_dir = os.path.dirname(paths[0])
+ if cache.is_fresh():
+ detector = "/usr/bin/bundling-detector-java"
+ if os.path.exists(detector) and os.access(detector, os.X_OK):
+ check_files = get_buildroot_files(regexp="jar$")
+ if len(check_files):
+ check = " ".join(["'{f}'".format(f=x)
+ for x in check_files])
+ # TODO: do not hardcode these paths
+ check_against = "/usr/share/java /usr/lib/java"
+ cmd = "{c} -check {cf} -checkAgainst {ca}".format(c=detector,
+ cf=check,
+ ca=check_against)
+ _log.info("Running bundling detection tool...")
+ rc, stdout, stderr = execute_command(cmd)
+ if stderr:
+ _log.warn(stderr)
+ if stdout:
+ _log.info("===== bundling detection report =====")
+ _log.info(stdout)
+ _log.info("===== bundling detection report =====")
+
for path in paths:
metadata = cache.get_metadata_for_path(path)
self.print_requires(metadata)
8 years, 10 months
[javapackages] Revert "Conform to PEP 0440"
by Michal Srb
commit 1dc7dbb22dfeb5bbadac0a7ccd13770ae800e50d
Author: Michal Srb <msrb(a)redhat.com>
Date: Wed Jun 24 20:41:11 2015 +0200
Revert "Conform to PEP 0440"
This reverts commit a0a8f02620c1d323d157c1bfe23068b67d2daafc.
This would break CI, postpone this change.
VERSION | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/VERSION b/VERSION
index 2bcc750..8af5919 100644
--- a/VERSION
+++ b/VERSION
@@ -1,2 +1,2 @@
-4.7.0.dev1
+4.7.0-SNAPSHOT
8 years, 10 months
[javapackages] Conform to PEP 0440
by Michal Srb
commit a0a8f02620c1d323d157c1bfe23068b67d2daafc
Author: Michal Srb <msrb(a)redhat.com>
Date: Wed Jun 24 15:28:07 2015 +0200
Conform to PEP 0440
VERSION | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/VERSION b/VERSION
index 8af5919..2bcc750 100644
--- a/VERSION
+++ b/VERSION
@@ -1,2 +1,2 @@
-4.7.0-SNAPSHOT
+4.7.0.dev1
8 years, 10 months
[javapackages] Fix formatting in setup script
by Michal Srb
commit 83f36896e4d2aaa51fd47b7d63af6302cf389d14
Author: Michal Srb <msrb(a)redhat.com>
Date: Wed Jun 24 15:24:06 2015 +0200
Fix formatting in setup script
python/setup.py | 31 +++++++++++++++----------------
1 files changed, 15 insertions(+), 16 deletions(-)
---
diff --git a/python/setup.py b/python/setup.py
index 442f831..bc65f72 100644
--- a/python/setup.py
+++ b/python/setup.py
@@ -1,27 +1,26 @@
-"""
-Setup script
-"""
import os
from setuptools import setup
dirpath = os.path.dirname(os.path.realpath(__file__))
-versionpath = os.path.join(dirpath, '..', 'VERSION')
-moduleversion = os.path.join(dirpath, 'javapackages', 'version.py')
+versionpath = os.path.join(dirpath, "..", "VERSION")
+moduleversion = os.path.join(dirpath, "javapackages", "version.py")
with open(versionpath) as vp:
__version__ = vp.read().strip()
with open(moduleversion, "w") as mv:
mv.write("__version__ = '{v}'".format(v=__version__))
setup(
- name = 'javapackages',
- description = 'Module for handling, querying and manipulating of various '
- 'files for Java packaging in Linux distributions',
- version = __version__,
- license = 'BSD',
- download_url = 'https://fedorahosted.org/released/javapackages/',
- url = 'https://git.fedorahosted.org/git/javapackages.git',
- packages = ['javapackages', 'javapackages.maven', 'javapackages.metadata', 'javapackages.xmvn', 'javapackages.common', 'javapackages.ivy', 'javapackages.cache'],
- test_suite = "test",
- maintainer = 'javapackages maintainers',
- maintainer_email = 'java-devel(a)lists.fedoraproject.org'
+ name="javapackages",
+ description="Module for handling, querying and manipulating of various "
+ "files for Java packaging in Linux distributions",
+ version=__version__,
+ license="BSD",
+ download_url="https://fedorahosted.org/released/javapackages/",
+ url="https://git.fedorahosted.org/git/javapackages.git",
+ packages=["javapackages", "javapackages.maven", "javapackages.metadata",
+ "javapackages.xmvn", "javapackages.common", "javapackages.ivy",
+ "javapackages.cache"],
+ test_suite="test",
+ maintainer="javapackages maintainers",
+ maintainer_email="java-devel(a)lists.fedoraproject.org"
)
8 years, 10 months
[javapackages] Fix misleading/missing docstrings in config.py
by Michal Srb
commit 66b381a4d7f9ed7a84bf536fb99ef2a755b8f47a
Author: Michal Srb <msrb(a)redhat.com>
Date: Wed Jun 24 15:11:14 2015 +0200
Fix misleading/missing docstrings in config.py
python/javapackages/common/config.py | 29 +++++++++++++++++++++--------
1 files changed, 21 insertions(+), 8 deletions(-)
---
diff --git a/python/javapackages/common/config.py b/python/javapackages/common/config.py
index aaa6138..b6f98c0 100644
--- a/python/javapackages/common/config.py
+++ b/python/javapackages/common/config.py
@@ -35,22 +35,31 @@ import os
import json
from javapackages.common.exception import JavaPackagesToolsException
+# name of the cache file for metadata
metadata_cache_f = "metadata.cache"
+# name of the cache file for OSGi stuff
osgi_cache_f = "osgi.cache"
def get_config():
+ """Return dictionary representing configuration file,
+ None if no valid configuration was found.
+
+ Paths specified in JAVACONFDIRS environment variable are searched for
+ configuration file named 'javapackages-config.json'. Only first successfully
+ read configuration file is taken into account, rest is ignored. Paths in
+ JAVACONFDIRS are expected to be separated by 'os.pathsep'.
+
+ If the JAVACONFDIRS is not defined, '/etc/java/' is assumed.
"""
- Returns list of dictionaries which represent configuration files.
- """
- if 'JAVACONFDIRS' in os.environ:
- config_paths = os.environ['JAVACONFDIRS'].split(os.pathsep)
+ if "JAVACONFDIRS" in os.environ:
+ config_paths = os.environ["JAVACONFDIRS"].split(os.pathsep)
else:
- config_paths = ['/etc/java/']
+ config_paths = ["/etc/java/"]
for config_path in config_paths:
try:
- file_path = os.path.join(config_path, 'javapackages-config.json')
+ file_path = os.path.join(config_path, "javapackages-config.json")
with open(file_path) as config_file:
return json.load(config_file)
except (OSError, IOError):
@@ -60,8 +69,12 @@ def get_config():
def get_buildroot():
+ """Return buildroot path, raise JavaPackagesToolsException if the path
+ couldn't be determined.
+ """
try:
- buildroot = os.environ['RPM_BUILD_ROOT']
+ buildroot = os.environ["RPM_BUILD_ROOT"]
except KeyError:
- raise JavaPackagesToolsException("RPM_BUILD_ROOT environment variable is not set")
+ raise JavaPackagesToolsException("RPM_BUILD_ROOT environment "
+ "variable is not set")
return os.path.abspath(buildroot)
8 years, 10 months
[javapackages] [cache] Improve documentation
by Michal Srb
commit b2fa832484817492b76630d2f6fd12e72916708d
Author: Michal Srb <msrb(a)redhat.com>
Date: Wed Jun 24 14:45:31 2015 +0200
[cache] Improve documentation
python/javapackages/cache/cache.py | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
---
diff --git a/python/javapackages/cache/cache.py b/python/javapackages/cache/cache.py
index 898552b..4a5ffb8 100644
--- a/python/javapackages/cache/cache.py
+++ b/python/javapackages/cache/cache.py
@@ -91,5 +91,8 @@ class Cache(object):
return cache
def is_fresh(self):
- """Returns True if the cache was just created, False otherwise."""
+ """
+ Returns True if the cache was created during creation of this object,
+ False otherwise.
+ """
return self._fresh
8 years, 10 months
[javapackages] [test] Fix buildroot location
by Michal Srb
commit 75e2b6a6b1ad456122a8fc5b990c3edb7a4edf2b
Author: Michal Srb <msrb(a)redhat.com>
Date: Wed Jun 24 08:57:08 2015 +0200
[test] Fix buildroot location
python/test/util_test.py | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
---
diff --git a/python/test/util_test.py b/python/test/util_test.py
index 5740984..31e93f6 100644
--- a/python/test/util_test.py
+++ b/python/test/util_test.py
@@ -7,7 +7,8 @@ from javapackages.common.util import get_buildroot_files
class TestUtil(unittest.TestCase):
def test_br_files_basic(self):
- br_path = os.path.abspath("data/buildroots/br1/")
+ br_path = os.path.abspath(os.path.join(os.path.dirname(__file__),
+ "data/buildroots/br1/"))
files = get_buildroot_files(regexp="jar$", buildroot_path=br_path)
self.assertEqual(1, len(files))
self.assertTrue(next(iter(files)).endswith("/usr/share/java/regular.jar"))
8 years, 10 months
[javapackages] Implement auxiliary function for finding files in buildroot
by Michal Srb
commit 95ed9465c675a21b728a7b0dfc869b9a16385985
Author: Michal Srb <msrb(a)redhat.com>
Date: Wed Jun 24 08:21:34 2015 +0200
Implement auxiliary function for finding files in buildroot
python/javapackages/common/util.py | 29 ++++++++++++++++++++
.../maven/lib/symlink_outside_of_buildroot.jar | 1 +
python/test/util_test.py | 17 +++++++++++
3 files changed, 47 insertions(+), 0 deletions(-)
---
diff --git a/python/javapackages/common/util.py b/python/javapackages/common/util.py
index add1322..b892bba 100644
--- a/python/javapackages/common/util.py
+++ b/python/javapackages/common/util.py
@@ -37,8 +37,10 @@ import sys
import six
import subprocess
import logging
+import re
from optparse import OptionParser
from javapackages.common.exception import JavaPackagesToolsException
+from javapackages.common.config import get_buildroot
def kill_parent_process(rpmconf):
@@ -116,3 +118,30 @@ def get_logger(name):
handler.setFormatter(formatter)
logger.addHandler(handler)
return logger
+
+
+def get_buildroot_files(regexp=None,
+ inside_buildroot_only=True,
+ exclude_broken_symlinks=True,
+ buildroot_path=None):
+ if not buildroot_path:
+ buildroot_path = get_buildroot()
+ files = set()
+ for dirpath, dirnames, filenames in os.walk(buildroot_path):
+ for filename in filenames:
+ f = os.path.realpath(os.path.join(dirpath, filename))
+
+ if inside_buildroot_only:
+ if not f.startswith(buildroot_path):
+ continue
+
+ if exclude_broken_symlinks:
+ if not os.path.exists(f):
+ continue
+
+ if regexp:
+ match = re.search(regexp, f)
+ if not match:
+ continue
+ files.add(f)
+ return files
diff --git a/python/test/data/buildroots/br1/usr/share/java/regular.jar b/python/test/data/buildroots/br1/usr/share/java/regular.jar
new file mode 100644
index 0000000..e69de29
diff --git a/python/test/data/buildroots/br1/usr/share/maven-metadata/metadata.xml b/python/test/data/buildroots/br1/usr/share/maven-metadata/metadata.xml
new file mode 100644
index 0000000..e69de29
diff --git a/python/test/data/buildroots/br1/usr/share/maven/lib/symlink_outside_of_buildroot.jar b/python/test/data/buildroots/br1/usr/share/maven/lib/symlink_outside_of_buildroot.jar
new file mode 120000
index 0000000..f3c9549
--- /dev/null
+++ b/python/test/data/buildroots/br1/usr/share/maven/lib/symlink_outside_of_buildroot.jar
@@ -0,0 +1 @@
+/usr/share/java/this_target_definitely_doesnt_exist.jar
\ No newline at end of file
diff --git a/python/test/util_test.py b/python/test/util_test.py
new file mode 100644
index 0000000..5740984
--- /dev/null
+++ b/python/test/util_test.py
@@ -0,0 +1,17 @@
+import os
+import unittest
+
+from javapackages.common.util import get_buildroot_files
+
+
+class TestUtil(unittest.TestCase):
+
+ def test_br_files_basic(self):
+ br_path = os.path.abspath("data/buildroots/br1/")
+ files = get_buildroot_files(regexp="jar$", buildroot_path=br_path)
+ self.assertEqual(1, len(files))
+ self.assertTrue(next(iter(files)).endswith("/usr/share/java/regular.jar"))
+
+
+if __name__ == '__main__':
+ unittest.main()
8 years, 10 months