Name:           logback
Version:        1.2.8
Release:        3
Summary:        A Java logging library
License:        LGPLv2 or EPL-1.0
URL:            http://logback.qos.ch/
Source0:        https://github.com/qos-ch/logback/archive/v_%{version}.tar.gz

Patch0001:      logback-1.2.8-jetty.patch
Patch0002:      CVE-2023-6378-and-CVE-2023-6481.patch

BuildRequires:  java-devel >= 1:1.6.0 maven-local mvn(javax.mail:mail)
BuildRequires:  mvn(javax.servlet:javax.servlet-api) mvn(junit:junit) mvn(log4j:log4j:1.2.17)
BuildRequires:  mvn(org.apache.ant:ant-junit) mvn(org.apache.felix:maven-bundle-plugin)
BuildRequires:  mvn(org.apache.felix:org.apache.felix.main)
BuildRequires:  mvn(org.apache.geronimo.specs:geronimo-jms_1.1_spec)
BuildRequires:  mvn(org.apache.maven.plugins:maven-antrun-plugin)
BuildRequires:  mvn(org.apache.tomcat:tomcat-catalina) mvn(org.apache.tomcat:tomcat-coyote)
BuildRequires:  mvn(org.codehaus.gmavenplus:gmavenplus-plugin) mvn(org.codehaus.groovy:groovy-all)
BuildRequires:  mvn(org.codehaus.janino:janino) mvn(org.eclipse.jetty:jetty-server)
BuildRequires:  mvn(org.eclipse.jetty:jetty-util) mvn(org.fusesource:fusesource-pom:pom:) 
BuildRequires:  mvn(org.fusesource.jansi:jansi) mvn(org.slf4j:slf4j-api) mvn(org.slf4j:slf4j-ext)
BuildRequires:  mvn(antlr:antlr) mvn(commons-cli:commons-cli) mvn(org.ow2.asm:asm-all)
BuildRequires:  mvn(org.slf4j:slf4j-nop)

BuildArch:      noarch

%description
Logback is intended as a successor to the popular log4j project. 

Logback's architecture is sufficiently generic so as to apply under 
different circumstances. At present time, logback is divided into 
three modules, logback-core, logback-classic and logback-access.

The logback-core module lays the groundwork for the other two modules. The
logback-classic module can be assimilated to a significantly improved
version of log4j. Moreover, logback-classic natively implements the SLF4J
API so that you can readily switch back and forth between logback and other
logging frameworks such as log4j or java.util.logging (JUL).

The logback-access module integrates with Servlet containers, such as
Tomcat and Jetty, to provide HTTP-access log functionality. Note that you
could easily build your own module on top of logback-core.

%package help
Summary:        Javadoc for %{name}
Provides:       %{name}-javadoc = %{version}-%{release}
Obsoletes:      %{name}-javadoc < %{version}-%{release}

%description help
API documentation for the Logback library

%package access
Summary:        Logback-access module for Servlet integration

%description access
The logback-access module is integrated with servlet containers
(such as Tomcat and Jetty) to provide HTTP-access logging capabilities.
Note that you can easily build your own modules on top of logback-core.

%package examples
Summary:        Logback Examples Module

%description examples
logback-examples module.

%prep
%autosetup -p1 -n %{name}-v_%{version}
find . -name "*.class" -delete
find . -name "*.cmd" -delete
find . -name "*.jar" -delete

%pom_remove_plugin :maven-source-plugin
%pom_remove_plugin :findbugs-maven-plugin
%pom_remove_plugin -r :maven-dependency-plugin
%pom_remove_plugin -r :cobertura-maven-plugin

sed -i 's/\r//' LICENSE.txt

sed -i 's#javax.servlet.*;version="2.5"#javax.servlet.*;version="3.1"#' %{name}-access/pom.xml

rm -r %{name}-*/src/test/java/*
%pom_xpath_remove -r "pom:dependency[pom:type = 'test-jar']"
%pom_xpath_remove -r "pom:dependency[pom:scope = 'test']"

%pom_xpath_remove -r "pom:plugin[pom:artifactId = 'maven-jar-plugin']/pom:executions"

%pom_xpath_remove "pom:project/pom:profiles/pom:profile[pom:id = 'host-orion']" %{name}-access
%pom_xpath_remove "pom:project/pom:profiles" %{name}-classic

%pom_xpath_remove "pom:project/pom:profiles/pom:profile[pom:id = 'javadocjar']"
%pom_xpath_remove "pom:executions/pom:execution/pom:goals/pom:goal[text() = 'generateTestStubs']" logback-classic
%pom_xpath_remove "pom:executions/pom:execution/pom:goals/pom:goal[text() = 'compileTests']" logback-classic

%pom_disable_module logback-site

%pom_xpath_remove "pom:build/pom:extensions"

%mvn_package ":%{name}-access" access
%mvn_package ":%{name}-examples" examples

%build

%mvn_build -f -- -Dorg.slf4j:slf4j-api:jar=$(build-classpath slf4j/api) \
  -Dorg.apache.felix:org.apache.felix.main:jar=$(build-classpath felix/org.apache.felix.main)

%install
%mvn_install

install -d -m 755 %{buildroot}%{_datadir}/%{name}/examples
cp -r %{name}-examples/pom.xml %{name}-examples/src %{buildroot}%{_datadir}/%{name}/examples

%files -f .mfiles
%license LICENSE.txt

%files access -f .mfiles-access
%license LICENSE.txt

%files examples -f .mfiles-examples
%license LICENSE.txt
%{_datadir}/%{name}

%files help -f .mfiles-javadoc

%changelog
* Tue Dec 12 2023 wangkai <13474090681@163.com> - 1.2.8-3
- Fix CVE-2023-6378,CVE-2023-6481

* Mon Aug 8 2022 Chenyx <chenyixiong3@huawei.com> - 1.2.8-2
- License compliance rectification

* Mon Dec 27 2021 houyingchao <houyingchao@huawei.com> - 1.2.8-1
- Upgrade to 1.2.8
- Fix CVE-2021-42550
* Sat Sep 19 2020 wangxiao <wangxiao65@huawei.com> - 1.1.7-7
- fix CVE-2017-5929
* Wed Mar 4 2020 dingyiming <dingyiming3@huawei.com> - 1.1.7-6
- Package init
