diff --git a/.gitignore b/.gitignore index 9f04920..acc83fa 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,14 @@ /byteman-2.0.4.tar.xz /2.1.2.tar.gz /373601b4e608ea622b2fec947824b99cd0edb124.tar.gz +/3.0.4.tar.gz +/byteman-3.0.4/ +/3.0.6.tar.gz +/byteman-3.0.6/ +/4.0.2.tar.gz +/4.0.3.tar.gz +/4.0.4.tar.gz +/4.0.5.tar.gz +/4.0.15.tar.gz +/4.0.16.tar.gz +/4.0.26.tar.gz diff --git a/byteman.spec b/byteman.spec index 4c47cfd..32d6d4a 100644 --- a/byteman.spec +++ b/byteman.spec @@ -1,47 +1,63 @@ +# Note to the interested reader: +# fedpkg mockbuild --without tests +# will make mvn_build macro skip tests. +# See: https://github.com/fedora-java/javapackages/issues/62 + +%global javacup_or_asm java_cup:java_cup|org\\.ow2\\.asm:asm.* +# Don't have generated mvn()-style requires for java_cup or asm +%global mvn_javacup_or_asm_matcher .*mvn\\(%{javacup_or_asm}\\) +# Don't have generated requires for java-headless >= 1:1.9 +%global java_headless_matcher java-headless >= 1:(1\\.9|9) +%global __requires_exclude ^%{mvn_javacup_or_asm_matcher}|%{java_headless_matcher}$ + %global homedir %{_datadir}/%{name} %global bindir %{homedir}/bin -%global hash 373601b4e608ea622b2fec947824b99cd0edb124 Name: byteman -Version: 2.1.4.1 -Release: 1%{?dist} +Version: 4.0.26 +Release: 4%{?dist} Summary: Java agent-based bytecode injection tool -License: LGPLv2+ +# most of the code is LGPL-2.1-or-later +# agent/src/main/java/org/jboss/byteman/agent/adapter/RuleGeneratorAdapter.java is BSD-3-Clause +License: LGPL-2.1-or-later AND BSD-3-Clause URL: http://www.jboss.org/byteman -Source0: https://github.com/bytemanproject/byteman/archive/%{hash}.tar.gz +# wget -O 4.0.16.tar.gz https://github.com/bytemanproject/byteman/archive/4.0.16.tar.gz +Source0: https://github.com/bytemanproject/byteman/archive/%{version}.tar.gz BuildArch: noarch +ExclusiveArch: %{java_arches} noarch -BuildRequires: jpackage-utils -BuildRequires: javapackages-tools -BuildRequires: java-devel -BuildRequires: maven-local +# Byteman 4.x requires JDK 9+ to build. Require JDK 10 explicitly. +BuildRequires: java-25-devel >= 1:11 +BuildRequires: maven-local-openjdk25 BuildRequires: maven-shade-plugin +BuildRequires: maven-source-plugin +BuildRequires: maven-plugin-plugin +BuildRequires: maven-bundle-plugin +BuildRequires: maven-assembly-plugin BuildRequires: maven-failsafe-plugin BuildRequires: maven-jar-plugin BuildRequires: maven-surefire-plugin BuildRequires: maven-surefire-provider-testng -BuildRequires: maven-surefire-provider-junit4 +BuildRequires: maven-surefire-provider-junit +BuildRequires: maven-surefire-provider-junit5 BuildRequires: maven-verifier-plugin +BuildRequires: maven-dependency-plugin BuildRequires: java_cup -BuildRequires: jarjar BuildRequires: objectweb-asm -BuildRequires: junit4 +BuildRequires: junit +BuildRequires: junit5 BuildRequires: testng -Requires: jpackage-utils -Requires: java-devel +Provides: bundled(objectweb-asm) = 9.1 +Provides: bundled(java_cup) = 1:0.11b-17 +# We are filtering java-headless >= 1:1.9 requirement. Add +# JDK 8 requirement here explicitly which shouldn't match the filter. +Requires: java-25-headless >= 1:1.8 -# Bundling -#BuildRequires: java_cup = 1:0.11a-12 -#BuildRequires: objectweb-asm = 0:3.3.1-7 -Provides: bundled(java_cup) = 1:0.11a-15 - -%if 0%{?fedora} > 20 -Provides: bundled(objectweb-asm) = 0:5.0-0.2.beta -%else -Provides: bundled(objectweb-asm) = 0:3.3.1-8 -%endif +# Related pieces removed via pom_xpath_remove macros +Patch1: remove_submit_integration_test_verification.patch +Patch2: testng7_port.patch %description Byteman is a tool which simplifies tracing and testing of Java programs. @@ -55,25 +71,92 @@ repackage or redeploy your application. In fact you can remove injected code and reinstall different code while the application continues to execute. %package javadoc -Summary: Javadocs for %{name} +Summary: Javadoc for %{name} %description javadoc This package contains the API documentation for %{name}. +%package rulecheck-maven-plugin +Summary: Maven plugin for checking Byteman rules. + +%description rulecheck-maven-plugin +This package contains the Byteman rule check maven plugin. + +%package bmunit +Summary: TestNG and JUnit integration for Byteman. + +%description bmunit +The Byteman bmunit jar provides integration of Byteman into +TestNG and JUnit tests. + +%package dtest +Summary: Remote byteman instrumented testing. + +%description dtest +The Byteman dtest jar supports instrumentation of test code executed on +remote server hosts and validation of assertions describing the expected +operation of the instrumented methods. + %prep -%setup -q -n byteman-%{hash} +%setup -q -n byteman-%{version} # Fix the gid:aid for java_cup sed -i "s|net.sf.squirrel-sql.thirdparty-non-maven|java_cup|" agent/pom.xml sed -i "s|java-cup|java_cup|" agent/pom.xml +sed -i "s|net.sf.squirrel-sql.thirdparty-non-maven|java_cup|" tests/pom.xml +sed -i "s|java-cup|java_cup|" tests/pom.xml -# Remove tools.jar from dependencyManagement (Fedora-specific patch). -# In Fedora tools.jar doesn't need to use system scope or provide -# systemPath - Maven will find it anyways. -%pom_remove_dep com.sun:tools +# Remove Submit integration test invocations (agent) +%pom_xpath_remove "pom:build/pom:plugins/pom:plugin[pom:artifactId='maven-failsafe-plugin']/pom:executions/pom:execution[pom:id='submit.TestSubmit']" agent +%pom_xpath_remove "pom:build/pom:plugins/pom:plugin[pom:artifactId='maven-failsafe-plugin']/pom:executions/pom:execution[pom:id='submit.TestSubmit.compiled']" agent +%patch -P1 -p2 +%patch -P2 -p2 + +# Remove Submit integration test invocations (tests) +%pom_xpath_remove "pom:build/pom:plugins/pom:plugin[pom:artifactId='maven-failsafe-plugin']/pom:executions/pom:execution[pom:id='submit.TestSubmit']" tests +%pom_xpath_remove "pom:build/pom:plugins/pom:plugin[pom:artifactId='maven-failsafe-plugin']/pom:executions/pom:execution[pom:id='submit.TestSubmit.compiled']" tests + +# Remove scope=system and systemPath for com.sun:tools +%pom_xpath_remove "pom:profiles/pom:profile/pom:dependencies/pom:dependency[pom:artifactId='tools']/pom:scope" install +%pom_xpath_remove "pom:profiles/pom:profile/pom:dependencies/pom:dependency[pom:artifactId='tools']/pom:systemPath" install +%pom_xpath_remove "pom:profiles/pom:profile/pom:dependencies/pom:dependency[pom:artifactId='tools']/pom:scope" contrib/bmunit +%pom_xpath_remove "pom:profiles/pom:profile/pom:dependencies/pom:dependency[pom:artifactId='tools']/pom:systemPath" contrib/bmunit + +# Some tests fail intermittently during builds. Disable them. +%pom_xpath_remove "pom:build/pom:plugins/pom:plugin[pom:artifactId='maven-surefire-plugin']/pom:executions" contrib/bmunit +%pom_xpath_set "pom:build/pom:plugins/pom:plugin[pom:artifactId='maven-surefire-plugin']/pom:configuration" 'true' contrib/bmunit + +# source/target 1.6 is not supported by 17; default is now 1.8 +%pom_xpath_remove "pom:build/pom:plugins/pom:plugin[pom:artifactId='maven-compiler-plugin']/pom:configuration/pom:source" pom.xml +%pom_xpath_remove "pom:build/pom:plugins/pom:plugin[pom:artifactId='maven-compiler-plugin']/pom:configuration/pom:target" pom.xml + +# Don't build download, docs modules +%pom_disable_module download + + +# Don't use javadoc plugin, use XMvn for javadocs +%pom_remove_plugin -r :maven-javadoc-plugin +%pom_remove_plugin -r :central-publishing-maven-plugin +%pom_remove_dep 'org.apache.maven:maven-project' contrib/rulecheck-maven-plugin +%pom_xpath_remove 'pom:execution[pom:id="make-javadoc-assembly"]' byteman + +# Put byteman-rulecheck-maven-plugin into a separate package +%mvn_package ":byteman-rulecheck-maven-plugin" rulecheck-maven-plugin + +# CNFE being thrown without this for bmunit5 in rawhide and with tests enabled +%pom_add_dep "org.apache.commons:commons-lang3" contrib/bmunit5 +# Put byteman-bmunit/byteman-dtest into a separate packages since they +# runtime require junit +%mvn_package ":byteman-bmunit" bmunit +%mvn_package ":byteman-dtest" dtest %build -%mvn_build +export JAVA_HOME=/usr/lib/jvm/java-openjdk +# Use --xmvn-javadoc so as to avoid maven-javadoc-plugin issue +# (fixed in 3.1.0, fedora has 3.0.1): +# See https://issues.apache.org/jira/browse/MJAVADOC-555 +# https://bugs.openjdk.java.net/browse/JDK-8212233 +%mvn_build --xmvn-javadoc -f %install %mvn_install @@ -106,62 +189,47 @@ for m in bmunit dtest install sample submit; do ln -s %{_javadir}/byteman/byteman-${m}.jar $RPM_BUILD_ROOT%{homedir}/lib/byteman-${m}.jar done +# Create contrib/jboss-module-system structure since bminstall expects it +# for the -m option. +install -d -m 755 $RPM_BUILD_ROOT%{homedir}/contrib +install -d -m 755 $RPM_BUILD_ROOT%{homedir}/contrib/jboss-modules-system +ln -s %{_javadir}/byteman/byteman-jboss-modules-plugin.jar $RPM_BUILD_ROOT%{homedir}/contrib/jboss-modules-system/byteman-jboss-modules-plugin.jar + ln -s %{_javadir}/byteman/byteman.jar $RPM_BUILD_ROOT%{homedir}/lib/byteman.jar %files -f .mfiles -%dir %{_javadir}/%{name} -%{homedir}/* +%{homedir}/lib/byteman.jar +%{homedir}/lib/byteman-install.jar +%{homedir}/lib/byteman-sample.jar +%{homedir}/lib/byteman-submit.jar +%{homedir}/contrib/* +%{bindir}/* %{_bindir}/* -%doc README docs/ProgrammersGuide.pdf docs/copyright.txt +%doc README +%license docs/copyright.txt %files javadoc -f .mfiles-javadoc -%doc docs/copyright.txt +%license docs/copyright.txt + +%files rulecheck-maven-plugin -f .mfiles-rulecheck-maven-plugin +%license docs/copyright.txt + +%files bmunit -f .mfiles-bmunit +%license docs/copyright.txt +%{homedir}/lib/byteman-bmunit.jar + +%files dtest -f .mfiles-dtest +%license docs/copyright.txt +%{homedir}/lib/byteman-dtest.jar %changelog -* Fri Feb 14 2014 Marek Goldmann - 2.1.4.1-1 -- Upstream release 2.1.4.1 +* Wed Jul 15 2026 Fedora Release Engineering - 4.0.26-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_45_Mass_Rebuild -* Sat Aug 03 2013 Fedora Release Engineering - 2.1.2-2 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild +* Fri Jan 16 2026 Fedora Release Engineering - 4.0.26-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_44_Mass_Rebuild -* Thu Jul 04 2013 Marek Goldmann - 2.1.2-1 -- Upstream release 2.1.2 - -* Wed Jun 5 2013 Mikolaj Izdebski - 2.0.4-5 -- Remove tools.jar from dependencyManagement - -* Wed May 29 2013 Marek Goldmann - 2.0.4-4 -- New guidelines - -* Thu Apr 25 2013 Marek Goldmann - 2.0.4-3 -- Fixes to the launch scripts - -* Wed Apr 24 2013 Marek Goldmann - 2.0.4-2 -- Added bmsubmit, bminstall and bmjava scripts, RHBZ#951560 - -* Thu Feb 21 2013 Marek Goldmann - 2.0.4-1 -- Upstream release 2.0.4 -- Switched to Maven -- Bundling java_cup and objectweb-asm (fpc#226) - -* Wed Feb 13 2013 Fedora Release Engineering - 1.5.2-6 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild - -* Wed Jul 18 2012 Fedora Release Engineering - 1.5.2-5 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild - -* Thu Jan 12 2012 Fedora Release Engineering - 1.5.2-4 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild - -* Tue Sep 20 2011 Marek Goldmann 1.5.2-3 -- Removed binary files from src.rpm - -* Mon Sep 19 2011 Marek Goldmann 1.5.2-2 -- Cleaned spec file - -* Wed Jul 27 2011 Marek Goldmann 1.5.2-1 -- Upstream release: 1.5.2 - -* Thu Jul 21 2011 Marek Goldmann 1.5.1-1 -- Initial packaging +* Fri Jan 16 2026 Fedora Release Engineering - 4.0.26-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_44_Mass_Rebuild +%autochangelog diff --git a/remove_submit_integration_test_verification.patch b/remove_submit_integration_test_verification.patch new file mode 100644 index 0000000..dae9507 --- /dev/null +++ b/remove_submit_integration_test_verification.patch @@ -0,0 +1,14 @@ +diff --git a/byteman-4.0.2/agent/verification.xml b/byteman-4.0.2/agent/verification.xml +index f530cfe..52ece06 100644 +--- a/byteman-4.0.2/agent/verification.xml ++++ b/byteman-4.0.2/agent/verification.xml +@@ -171,9 +171,5 @@ + target/failsafe-reports/org.jboss.byteman.tests.misc.TestThrowBinding.txt + + +- +- target/failsafe-reports/org.jboss.byteman.tests.submit.TestSubmit.txt +- +- + + diff --git a/sources b/sources index 579bf24..1a074db 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -dc505eb23c4cd44a395f74223f83b73a 373601b4e608ea622b2fec947824b99cd0edb124.tar.gz +SHA512 (4.0.26.tar.gz) = 06c8bf688d237d8dbac1e4558a8e2916f1212d2746d81a64e8bc44f9074f5b1c205bb98ac3a8e835f0c8b225df665e40c93c8b60ff5ff77f6ce8272c25679d76 diff --git a/testng7_port.patch b/testng7_port.patch new file mode 100644 index 0000000..16e43e9 --- /dev/null +++ b/testng7_port.patch @@ -0,0 +1,22 @@ +diff --git a/byteman-4.0.15/contrib/bmunit/src/org/jboss/byteman/contrib/bmunit/BMNGListener.java b/byteman-4.0.15/contrib/bmunit/src/org/jboss/byteman/contrib/bmunit/BMNGListener.java +index 2f784bc..9e4fec9 100644 +--- a/byteman-4.0.15/contrib/bmunit/src/org/jboss/byteman/contrib/bmunit/BMNGListener.java ++++ b/byteman-4.0.15/contrib/bmunit/src/org/jboss/byteman/contrib/bmunit/BMNGListener.java +@@ -61,7 +61,7 @@ public class BMNGListener extends BMNGAbstractRunner implements IInvokedMethodLi + } + + public void beforeInvocation(IInvokedMethod method, ITestResult testResult) { +- Method javaMethod = method.getTestMethod().getMethod(); ++ Method javaMethod = method.getTestMethod().getConstructorOrMethod().getMethod(); + Class clazz = javaMethod.getDeclaringClass(); + if (!checkBMNGListener(clazz)) { + return; +@@ -81,7 +81,7 @@ public class BMNGListener extends BMNGAbstractRunner implements IInvokedMethodLi + } + + public void afterInvocation(IInvokedMethod method, ITestResult testResult) { +- Method javaMethod = method.getTestMethod().getMethod(); ++ Method javaMethod = method.getTestMethod().getConstructorOrMethod().getMethod(); + Class clazz = javaMethod.getDeclaringClass(); + if (!checkBMNGListener(clazz)) { + return; diff --git a/tests/smoke/test-smoke.sh b/tests/smoke/test-smoke.sh new file mode 100644 index 0000000..24e4322 --- /dev/null +++ b/tests/smoke/test-smoke.sh @@ -0,0 +1,147 @@ +#!/bin/bash +# +set -e + +############################################################## +# +# Test 1: bmjava +# +############################################################## +test1_dir=$(mktemp -d) +pushd $test1_dir +##### +## The Java program under test (via bmjava) +##### +cat > HelloWait.java < trace1.btm < out1.log +grep -q "argument was: World!" out1.log +grep -q "Hello bar" out1.log +output=$(tail -n1 out1.log) +if [ ! "${output}_" == "Hello bar_" ]; then + echo Test FAILED! + exit 1 +fi + +echo Test 1 PASSED! + +popd +rm -rf $test1_dir + + +############################################################## +# +# Test 2: bminstall + bmsubmit +# +############################################################## +test2_dir=$(mktemp -d) +pushd $test2_dir +##### +## The Java program under test +##### +cat > HelloWait.java < out2.log 2>&1 & +pid_of_java=$$ +echo "Forked java process with pid $pid_of_java" +sleep 2 +##### +## The byteman rule(s) (used via bmsubmit) +##### +cat > change_arg.btm < throw_excptn.btm <