remove python2 script
This commit is contained in:
parent
5c8a8df263
commit
bde63c5430
@ -1,245 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
# Copyright 2013, 2014 Red Hat, Inc., and William C. Benton
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
import xml.etree.ElementTree as ET
|
|
||||||
import argparse
|
|
||||||
import StringIO
|
|
||||||
import re
|
|
||||||
import subprocess
|
|
||||||
import logging
|
|
||||||
|
|
||||||
from os.path import exists as pathexists
|
|
||||||
from os.path import realpath
|
|
||||||
from os.path import join as pathjoin
|
|
||||||
from os import makedirs
|
|
||||||
from os import symlink
|
|
||||||
from os import remove as rmfile
|
|
||||||
from shutil import copyfile
|
|
||||||
|
|
||||||
class Artifact(object):
|
|
||||||
def __init__(self, a, g, v):
|
|
||||||
self.artifact = a
|
|
||||||
self.group = g
|
|
||||||
self.version = v
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def fromCoords(k, coords):
|
|
||||||
g,a,v = coords.split(":")
|
|
||||||
return k(a, g, v)
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def fromSubtree(k, t, ns):
|
|
||||||
a = t.find("./%sartifactId" % ns).text
|
|
||||||
g = t.find("./%sgroupId" % ns).text
|
|
||||||
v = t.find("./%sversion" % ns).text
|
|
||||||
return k(a, g, v)
|
|
||||||
|
|
||||||
def contains(self, substrings):
|
|
||||||
for s in substrings:
|
|
||||||
if s in self.artifact or s in self.group:
|
|
||||||
cn_debug("ignoring %r because it contains %s" % (self, s))
|
|
||||||
return True
|
|
||||||
if len(substrings) > 0:
|
|
||||||
cn_debug("not ignoring %r; looked for %r" % (self, substrings))
|
|
||||||
return False
|
|
||||||
|
|
||||||
def __repr__(self):
|
|
||||||
return "%s:%s:%s" % (self.group, self.artifact, self.version)
|
|
||||||
|
|
||||||
class DummyPOM(object):
|
|
||||||
def __init__(self, groupID=None, artifactID=None, version=None):
|
|
||||||
self.groupID = groupID
|
|
||||||
self.artifactID = artifactID
|
|
||||||
self.version = version
|
|
||||||
self.deps = []
|
|
||||||
|
|
||||||
def interestingDep(dt, namespace):
|
|
||||||
if len(dt.findall("./%soptional" % namespace)) != 0:
|
|
||||||
cn_debug("ignoring optional dep %r" % Artifact.fromSubtree(dt, namespace))
|
|
||||||
return False
|
|
||||||
if [e for e in dt.findall("./%sscope" % namespace) if e.text == "test"] != []:
|
|
||||||
cn_debug("ignoring test dep %r" % Artifact.fromSubtree(dt, namespace))
|
|
||||||
return False
|
|
||||||
return True
|
|
||||||
|
|
||||||
class POM(object):
|
|
||||||
def __init__(self, filename, suppliedGroupID=None, suppliedArtifactID=None, ignored_deps=[], override=None, extra_deps=[]):
|
|
||||||
self.filename = filename
|
|
||||||
self.sGroupID = suppliedGroupID
|
|
||||||
self.sArtifactID = suppliedArtifactID
|
|
||||||
self.logger = logging.getLogger("com.freevariable.climbing-nemesis")
|
|
||||||
self.deps = []
|
|
||||||
self.ignored_deps = ignored_deps
|
|
||||||
self.extra_deps = extra_deps
|
|
||||||
cn_debug("POM: extra_deps is %r" % extra_deps)
|
|
||||||
self._parsePom()
|
|
||||||
self.claimedGroup, self.claimedArtifact = override is not None and override or (self.groupID, self.artifactID)
|
|
||||||
|
|
||||||
def _parsePom(self):
|
|
||||||
tree = ET.parse(self.filename)
|
|
||||||
project = tree.getroot()
|
|
||||||
self.logger.info("parsing POM %s", self.filename)
|
|
||||||
self.logger.debug("project tag is '%s'", project.tag)
|
|
||||||
tagmatch = re.match("[{](.*)[}].*", project.tag)
|
|
||||||
namespace = tagmatch and "{%s}" % tagmatch.groups()[0] or ""
|
|
||||||
self.logger.debug("looking for '%s'", ("./%sgroupId" % namespace))
|
|
||||||
groupIDtag = project.find("./%sgroupId" % namespace)
|
|
||||||
if groupIDtag is None:
|
|
||||||
groupIDtag = project.find("./%sparent/%sgroupId" % (namespace,namespace))
|
|
||||||
|
|
||||||
versiontag = project.find("./%sversion" % namespace)
|
|
||||||
if versiontag is None:
|
|
||||||
versiontag = project.find("./%sparent/%sversion" % (namespace,namespace))
|
|
||||||
self.logger.debug("group ID tag is '%s'", groupIDtag)
|
|
||||||
self.groupID = groupIDtag.text
|
|
||||||
self.artifactID = project.find("./%sartifactId" % namespace).text
|
|
||||||
self.version = versiontag.text
|
|
||||||
depTrees = project.findall(".//%sdependencies/%sdependency" % (namespace, namespace))
|
|
||||||
alldeps = [Artifact.fromSubtree(depTree, namespace) for depTree in depTrees if interestingDep(depTree, namespace)]
|
|
||||||
alldeps = [dep for dep in alldeps if not (dep.group == self.groupID and dep.artifact == self.artifactID)]
|
|
||||||
self.deps = [dep for dep in alldeps if not dep.contains(self.ignored_deps)] + [Artifact.fromCoords(xtra) for xtra in self.extra_deps]
|
|
||||||
jarmatch = re.match(".*JPP-(.*).pom", self.filename)
|
|
||||||
self.jarname = (jarmatch and jarmatch.groups()[0] or None)
|
|
||||||
|
|
||||||
def cn_debug(*args):
|
|
||||||
logging.getLogger("com.freevariable.climbing-nemesis").debug(*args)
|
|
||||||
|
|
||||||
def cn_info(*args):
|
|
||||||
logging.getLogger("com.freevariable.climbing-nemesis").info(*args)
|
|
||||||
|
|
||||||
def resolveArtifact(group, artifact, ver, pomfile=None, kind="jar", ignored_deps=[], override=None, extra_deps=[]):
|
|
||||||
# XXX: some error checking would be the responsible thing to do here
|
|
||||||
cn_debug("rA: extra_deps is %r" % extra_deps)
|
|
||||||
if pomfile is None:
|
|
||||||
try:
|
|
||||||
if getFedoraRelease() > 19:
|
|
||||||
[pom] = subprocess.check_output(["xmvn-resolve", "%s:%s:pom:%s" % (group, artifact, ver)]).split()
|
|
||||||
else:
|
|
||||||
[pom] = subprocess.check_output(["xmvn-resolve", "%s:%s:%s" % (group, artifact, kind)]).split()
|
|
||||||
return POM(pom, ignored_deps=ignored_deps, override=override, extra_deps=extra_deps)
|
|
||||||
except:
|
|
||||||
return DummyPOM(group, artifact)
|
|
||||||
else:
|
|
||||||
return POM(pomfile, ignored_deps=ignored_deps, override=override, extra_deps=extra_deps)
|
|
||||||
|
|
||||||
def resolveArtifacts(identifiers):
|
|
||||||
coords = ["%s:%s:jar" % (group, artifact) for (group, artifact) in identifiers]
|
|
||||||
poms = subprocess.check_output(["xmvn-resolve"] + coords).split()
|
|
||||||
return [POM(pom) for pom in poms]
|
|
||||||
|
|
||||||
def resolveJar(group, artifact, ver):
|
|
||||||
[jar] = subprocess.check_output(["xmvn-resolve", "%s:%s:jar:%s" % (group, artifact, ver)]).split()
|
|
||||||
return jar
|
|
||||||
|
|
||||||
def makeIvyXmlTree(org, module, revision, status="release", meta={}, deps=[]):
|
|
||||||
ivy_module = ET.Element("ivy-module", {"version":"1.0", "xmlns:e":"http://ant.apache.org/ivy/extra"})
|
|
||||||
info = ET.SubElement(ivy_module, "info", dict({"organisation":org, "module":module, "revision":revision, "status":status}.items() + meta.items()))
|
|
||||||
info.text = " " # ensure a close tag
|
|
||||||
confs = ET.SubElement(ivy_module, "configurations")
|
|
||||||
for conf in ["default", "provided", "test"]:
|
|
||||||
ET.SubElement(confs, "conf", {"name":conf})
|
|
||||||
pubs = ET.SubElement(ivy_module, "publications")
|
|
||||||
ET.SubElement(pubs, "artifact", {"name":module, "type":"jar"})
|
|
||||||
if len(deps) > 0:
|
|
||||||
deptree = ET.SubElement(ivy_module, "dependencies")
|
|
||||||
for dep in deps:
|
|
||||||
ET.SubElement(deptree, "dependency", {"org":dep.group, "name":dep.artifact, "rev":dep.version})
|
|
||||||
return ET.ElementTree(ivy_module)
|
|
||||||
|
|
||||||
def writeIvyXml(org, module, revision, status="release", fileobj=None, meta={}, deps=[]):
|
|
||||||
# XXX: handle deps!
|
|
||||||
if fileobj is None:
|
|
||||||
fileobj = StringIO.StringIO()
|
|
||||||
tree = makeIvyXmlTree(org, module, revision, status, meta=meta, deps=deps)
|
|
||||||
tree.write(fileobj, xml_declaration=True)
|
|
||||||
return fileobj
|
|
||||||
|
|
||||||
def ivyXmlAsString(org, module, revision, status, meta={}, deps=[]):
|
|
||||||
return writeIvyXml(org, module, revision, status, meta=meta, deps=deps).getvalue()
|
|
||||||
|
|
||||||
def placeArtifact(artifact_file, repo_dirname, org, module, revision, status="release", meta={}, deps=[], supplied_ivy_file=None, scala=None, override=None, override_dir_only=False):
|
|
||||||
if scala is not None:
|
|
||||||
module = module + "_%s" % scala
|
|
||||||
jarmodule = module
|
|
||||||
if override is not None:
|
|
||||||
org, module = override
|
|
||||||
if not override_dir_only:
|
|
||||||
jarmodule = module
|
|
||||||
repo_dir = realpath(repo_dirname)
|
|
||||||
artifact_dir = pathjoin(*[repo_dir] + [org] + [module, revision])
|
|
||||||
ivyxml_path = pathjoin(artifact_dir, "ivy.xml")
|
|
||||||
artifact_repo_path = pathjoin(artifact_dir, "%s-%s.jar" % (jarmodule, revision))
|
|
||||||
|
|
||||||
if not pathexists(artifact_dir):
|
|
||||||
makedirs(artifact_dir)
|
|
||||||
|
|
||||||
ivyxml_file = open(ivyxml_path, "w")
|
|
||||||
if supplied_ivy_file is None:
|
|
||||||
writeIvyXml(org, module, revision, status, ivyxml_file, meta=meta, deps=deps)
|
|
||||||
else:
|
|
||||||
copyfile(supplied_ivy_file, ivyxml_path)
|
|
||||||
|
|
||||||
if pathexists(artifact_repo_path):
|
|
||||||
rmfile(artifact_repo_path)
|
|
||||||
|
|
||||||
symlink(artifact_file, artifact_repo_path)
|
|
||||||
|
|
||||||
def getFedoraRelease():
|
|
||||||
cmd = "rpm -q --qf %{version} fedora-release"
|
|
||||||
return int(subprocess.check_output(cmd.split()))
|
|
||||||
|
|
||||||
def main():
|
|
||||||
parser = argparse.ArgumentParser(description="Place a locally-installed artifact in a custom local Ivy repository; get metadata from Maven")
|
|
||||||
parser.add_argument("group", metavar="GROUP", type=str, help="name of group")
|
|
||||||
parser.add_argument("artifact", metavar="ARTIFACT", type=str, help="name of artifact")
|
|
||||||
parser.add_argument("ver", metavar="VER", type=str, help="version of artifact")
|
|
||||||
parser.add_argument("repodir", metavar="REPO", type=str, help="location for local repo")
|
|
||||||
parser.add_argument("--version", metavar="VERSION", type=str, help="version to advertise this artifact as, overriding Maven metadata")
|
|
||||||
parser.add_argument("--meta", metavar="K=V", type=str, help="extra metadata to store in ivy.xml", action='append')
|
|
||||||
parser.add_argument("--jarfile", metavar="JAR", type=str, help="local jar file (use instead of POM metadata")
|
|
||||||
parser.add_argument("--pomfile", metavar="POM", type=str, help="local pom file (use instead of xmvn-resolved one")
|
|
||||||
parser.add_argument("--log", metavar="LEVEL", type=str, help="logging level")
|
|
||||||
parser.add_argument("--ivyfile", metavar="IVY", type=str, help="supplied Ivy file (use instead of POM metadata)")
|
|
||||||
parser.add_argument("--scala", metavar="VERSION", type=str, help="encode given scala version in artifact name")
|
|
||||||
parser.add_argument("--ignore", metavar="STR", type=str, help="ignore dependencies whose artifact or group contains str", action='append')
|
|
||||||
parser.add_argument("--override", metavar="ORG:NAME", type=str, help="override organization and/or artifact name")
|
|
||||||
parser.add_argument("--override-dir-only", action='store_true', help="override organization and/or artifact name")
|
|
||||||
parser.add_argument("--extra-dep", metavar="ORG:NAME:VERSION", action='append', help="add the given dependencya")
|
|
||||||
args = parser.parse_args()
|
|
||||||
|
|
||||||
if args.log is not None:
|
|
||||||
logging.basicConfig(level=getattr(logging, args.log.upper()))
|
|
||||||
|
|
||||||
override = args.override and args.override.split(":") or None
|
|
||||||
cn_debug("cl: args.extra_dep is %r" % args.extra_dep)
|
|
||||||
extra_deps = args.extra_dep is not None and args.extra_dep or []
|
|
||||||
|
|
||||||
pom = resolveArtifact(args.group, args.artifact, args.ver, args.pomfile, "jar", ignored_deps=(args.ignore or []), override=((not args.override_dir_only) and override or None), extra_deps=extra_deps)
|
|
||||||
|
|
||||||
if args.jarfile is None:
|
|
||||||
jarfile = resolveJar(pom.groupID or args.group, pom.artifactID or args.artifact, args.ver)
|
|
||||||
else:
|
|
||||||
jarfile = args.jarfile
|
|
||||||
|
|
||||||
version = (args.version or pom.version)
|
|
||||||
|
|
||||||
meta = dict([kv.split("=") for kv in (args.meta or [])])
|
|
||||||
cn_debug("meta is %r" % meta)
|
|
||||||
|
|
||||||
placeArtifact(jarfile, args.repodir, pom.groupID, pom.artifactID, version, meta=meta, deps=pom.deps, supplied_ivy_file=args.ivyfile, scala=args.scala, override=override, override_dir_only=args.override_dir_only)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
@ -1,16 +1,15 @@
|
|||||||
Name: mchange-commons
|
Name: mchange-commons
|
||||||
Version: 0.2.11
|
Version: 0.2.11
|
||||||
Release: 9
|
Release: 10
|
||||||
Summary: A collection of general purpose utilities for c3p0
|
Summary: A collection of general purpose utilities for c3p0
|
||||||
License: LGPLv2 or EPL
|
License: LGPLv2 or EPL
|
||||||
URL: https://github.com/swaldman/mchange-commons-java
|
URL: https://github.com/swaldman/mchange-commons-java
|
||||||
Source0: https://github.com/swaldman/mchange-commons-java/archive/mchange-commons-java-0.2.11/mchange-commons-0.2.11.tar.gz
|
Source0: https://github.com/swaldman/mchange-commons-java/archive/mchange-commons-java-0.2.11/mchange-commons-0.2.11.tar.gz
|
||||||
Source1: https://raw.github.com/willb/climbing-nemesis/master/climbing-nemesis.py
|
|
||||||
|
|
||||||
#Remove test about mchange
|
#Remove test about mchange
|
||||||
Patch0000: mchange-no-tests.patch
|
Patch0: mchange-no-tests.patch
|
||||||
|
|
||||||
BuildRequires: sbt ivy-local maven-local log4j12 slf4j typesafe-config python2 python-unversioned-command
|
BuildRequires: sbt ivy-local maven-local log4j12 slf4j typesafe-config
|
||||||
|
|
||||||
BuildArch: noarch
|
BuildArch: noarch
|
||||||
|
|
||||||
@ -25,23 +24,34 @@ Obsoletes: %{name}-javadoc < %{version}-%{release}
|
|||||||
%description help
|
%description help
|
||||||
The help for mchange-commons to use.
|
The help for mchange-commons to use.
|
||||||
|
|
||||||
|
|
||||||
%prep
|
%prep
|
||||||
%autosetup -n mchange-commons-java-mchange-commons-java-0.2.11 -p1
|
%autosetup -n mchange-commons-java-mchange-commons-java-0.2.11 -p1
|
||||||
|
|
||||||
find -name '*.class' -delete
|
find -name '*.class' -delete
|
||||||
find -name '*.jar' -delete
|
find -name '*.jar' -delete
|
||||||
|
|
||||||
cp %{SOURCE1} .
|
|
||||||
chmod 755 climbing-nemesis.py
|
|
||||||
sed -i -e 's/0.13.6/0.13.1/' project/build.properties
|
sed -i -e 's/0.13.6/0.13.1/' project/build.properties
|
||||||
cp -pr /usr/share/sbt/ivy-local .
|
cp -pr /usr/share/sbt/ivy-local .
|
||||||
|
mkdir -p ./ivy-local/com.typesafe/config/1.2.1/
|
||||||
|
mkdir -p ./ivy-local/log4j/log4j/1.2.14/
|
||||||
|
mkdir -p ./ivy-local/org.slf4j/slf4j-api/1.7.5/
|
||||||
|
pushd ./ivy-local/com.typesafe/config/1.2.1/
|
||||||
|
touch ivy.xml
|
||||||
|
ln -s /usr/share/java/typesafe-config.jar config-1.2.1.jar
|
||||||
|
echo "<ivy-module version=\"1.0\" xmlns:e=\"http://ant.apache.org/ivy/extra\"><info module=\"config\" organisation=\"com.typesafe\" revision=\"1.2.1\" status=\"release\"> </info><configurations><conf name=\"default\" /><conf name=\"provided\" /><conf name=\"test\" /></configurations><publications><artifact name=\"config\" type=\"jar\" /></publications></ivy-module>" > ivy.xml
|
||||||
|
popd
|
||||||
|
pushd ./ivy-local/log4j/log4j/1.2.14/
|
||||||
|
touch ivy.xml
|
||||||
|
ln -s /usr/share/java/log4j-1.2.17.jar log4j-1.2.14.jar
|
||||||
|
echo "<ivy-module version=\"1.0\" xmlns:e=\"http://ant.apache.org/ivy/extra\"><info module=\"log4j\" organisation=\"log4j\" revision=\"1.2.14\" status=\"release\"> </info><configurations><conf name=\"default\" /><conf name=\"provided\" /><conf name=\"test\" /></configurations><publications><artifact name=\"log4j\" type=\"jar\" /></publications></ivy-module>" > ivy.xml
|
||||||
|
popd
|
||||||
|
pushd ./ivy-local/org.slf4j/slf4j-api/1.7.5/
|
||||||
|
touch ivy.xml
|
||||||
|
ln -s /usr/share/java/slf4j/slf4j-api.jar slf4j-api-1.7.5.jar
|
||||||
|
echo "<ivy-module version=\"1.0\" xmlns:e=\"http://ant.apache.org/ivy/extra\"><info module=\"slf4j-api\" organisation=\"org.slf4j\" revision=\"1.7.5\" status=\"release\"> </info><configurations><conf name=\"default\" /><conf name=\"provided\" /><conf name=\"test\" /></configurations><publications><artifact name=\"slf4j-api\" type=\"jar\" /></publications></ivy-module>" > ivy.xml
|
||||||
|
popd
|
||||||
|
|
||||||
%build
|
%build
|
||||||
./climbing-nemesis.py com.typesafe config any ivy-local --version 1.2.1
|
|
||||||
./climbing-nemesis.py log4j log4j 12 ivy-local --version 1.2.14
|
|
||||||
./climbing-nemesis.py org.slf4j slf4j-api any ivy-local --version 1.7.5
|
|
||||||
|
|
||||||
export SBT_BOOT_DIR=$PWD/boot
|
export SBT_BOOT_DIR=$PWD/boot
|
||||||
export SBT_IVY_DIR=$PWD/ivy-local
|
export SBT_IVY_DIR=$PWD/ivy-local
|
||||||
sbt package make-pom doc
|
sbt package make-pom doc
|
||||||
@ -57,6 +67,9 @@ sbt package make-pom doc
|
|||||||
%files help -f .mfiles-javadoc
|
%files help -f .mfiles-javadoc
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Wed Oct 28 2020 Ge Wang <wangge20@huawei.com> - 0.2.11-10
|
||||||
|
- remove dependency of python2
|
||||||
|
|
||||||
* Thu Apr 9 2020 likexin <likexin4@huawei.com> - 0.2.11-9
|
* Thu Apr 9 2020 likexin <likexin4@huawei.com> - 0.2.11-9
|
||||||
- delete the stupid copy command
|
- delete the stupid copy command
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user