Michael Semb Wever created CASSANDRA-21704:
----------------------------------------------
Summary: Make the packaging and build scripts follow the ant
project name
Key: CASSANDRA-21704
URL: https://issues.apache.org/jira/browse/CASSANDRA-21704
Project: Apache Cassandra
Issue Type: Improvement
Components: Packaging, Build
Reporter: Michael Semb Wever
The jar and the source tarball are named after the {{<project name="…">}}
attribute in {{build.xml}}, because ant builds
{{build/${ant.project.name}-${version}.jar}}. Nine sites in the build and
packaging scripts spell {{apache-cassandra}} instead:
{code:none}
.build/docker/_build-redhat.sh rm -rf ${DIST_DIR}/apache-cassandra-*.jar
cp ${DIST_DIR}/apache-cassandra-*-src.tar.gz …
.build/run-tests.sh [[ -f
"${DIST_DIR}/apache-cassandra-${version}.jar" ]] || …
.build/run-python-dtests.sh the same check
.build/sh/test/stub-ant-cases.sh touch
"${DIST_DIR}/apache-cassandra-${version}-SNAPSHOT.jar"
debian/rules dh_install
$(BUILD_DIR)/apache-cassandra-$(VERSION).jar
redhat/cassandra.spec %define relname
apache-cassandra-%{upstream_version}
bin/cassandra.in.sh ls -1
$CASSANDRA_HOME/build/apache-cassandra*.jar
tools/bin/cassandra.in.sh the same glob
redhat/cassandra.in.sh the same glob
{code}
Rename the project and every one of them misses. The debian and redhat
packaging cannot find the jar it just built, {{run-tests.sh}} reports {{Project
must be built first}} against a tree that is built, and {{bin/cassandra}}
constructs a classpath with no Cassandra jar on it.
The patch reads the name at each site, where that site already reads
{{build.xml}}: beside the {{base.version}} line in the two test runners, beside
{{buildxml_version}} in {{_build-redhat.sh}}, as a {{$(shell …)}} beside
{{VERSION}} in {{debian/rules}}, and from {{$CASSANDRA_HOME/build.xml}} in the
three {{cassandra.in.sh}} files, whose glob sits inside a {{[ -d
$CASSANDRA_HOME/build ]}} test and therefore runs against a source checkout.
One expression is used everywhere, {{grep '<project[[:space:]]*basedir='
build.xml | sed -ne 's/.*name="\([^"]*\)".*/\1/p'}}, with {{[[:space:]]}}
rather than {{\s}} because {{bin/cassandra.in.sh}} also runs under the BSD grep
on macOS.
{{redhat/cassandra.spec}} is the exception. It takes the name from
{{_build-redhat.sh}} as an {{rpmbuild --define}}, beside the {{version}} and
{{revision}} defines that call already passes, so the derivation stays in shell
and the spec carries no second copy of the regular expression. The spec
defaults to {{apache-cassandra}}, so {{rpmbuild -ba redhat/cassandra.spec}} run
by hand behaves as it does today.
Three limits are deliberate. The debian symlink keeps the name
{{apache-cassandra.jar}}: it is a published path, and only its target has to
follow the rename, so {{debian/init}} needs no change either. The classpath
globs derive the name rather than widening from {{apache-cassandra*.jar}} to
{{*-[0-9]*.jar}}, which would also match a built {{dtest-<version>.jar}} and
make the script refuse to start on "JAR artifacts for multiple versions". And
{{_build-redhat.sh}} alone refuses an empty name, because it is the one site
that hands the value to {{rm -rf}}.
Three sites are left alone: the sub-build names in {{.build/build-*.xml}},
which name ant projects rather than artifacts; the {{Conflicts}} and
{{Replaces}} on {{apache-cassandra1}} in {{debian/control}}, which name a
historical package; and {{toCopy}} in {{.jenkins/Jenkinsfile}}, which no code
in the tree reads.
Nothing changes for a build that keeps the name {{apache-cassandra}}, which is
every Apache build.
Patch:
[mck/upstream/packaging-project-name/trunk|https://github.com/thelastpickle/cassandra/tree/mck/upstream/packaging-project-name/trunk]
Provenance:
[2315d6f359|https://github.com/datastax/cassandra/commit/2315d6f359b963bb55c629c2416dc6f66903bf8f]
by [~mck], in
[datastax/cassandra#2193|https://github.com/datastax/cassandra/pull/2193],
where the fork's project name is {{dse-db}}. That pull request covers five of
these nine sites, and reaches the remaining fork needs by hardcoding {{dse-db}}
in the two {{cassandra.in.sh}} files and by widening the redhat glob. This
patch derives the name at all nine instead. The JDK 22 support and the docker
back-ports in that pull request are fork-only and are not here.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]