File netbeans.spec of Package Netbeans

%define install_dir %{_libdir}/%{name}
Name:           netbeans
Version:        20
Release:        0
Group:          Development/Tools/IDE
License:        Apache-2.0
Summary:        A World-Class Development Environment Written in Java
Url:            https://netbeans.apache.org/
Source0:        %{name}-%{version}-bin.zip 
Source1:        %{name}.desktop
Patch1:         %{name}_python3_shebang.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  update-desktop-files fdupes
BuildRequires:  unzip
BuildRequires:	dos2unix
Requires:       bash
Requires:       java >= 15
Requires:       java-devel >= 15
Requires:       gradle >= 6.3
Provides:       NetBeans
Obsoletes:		%{name} < %{version}


%description
The NetBeans IDE is a world-class development environment written in
Java. It can be used to develop code in Java, HTML, XML, JSP, C/C++,
and other languages. The IDE is modular and there is a huge variety of
commercial and free extensions for it that support various
technologies.

%prep
%setup -q -n %{name}
%patch1 -p1

%build
# empty for now...

%install
export NO_BRP_CHECK_BYTECODE_VERSION=true
rm -rf $RPM_BUILD_ROOT
mkdir %buildroot
# remove windows executables and libraries
find . -type f -name "*.exe" -delete
find . -type f -name "*.bat" -delete
find . -type f -name "*.dll" -delete
# remove macos executables and libraries
find . -type f -name "*.cmd" -delete
find . -type f -name "*.dylib" -delete
# remove NON-Linux libraries
find . -type d -maxdepth 10 -name "*SunOS*" | xargs rm -Rf
find . -type d -maxdepth 10 -name "*MacOSX*" | xargs rm -Rf
find . -type d -maxdepth 10 -name "*Windows*" | xargs rm -Rf
find . -type d -maxdepth 10 -name "*windows*" | xargs rm -Rf
find . -type d -maxdepth 10 -name "*hpux*" | xargs rm -Rf
find . -type d -maxdepth 10 -name "*solaris*" | xargs rm -Rf
find . -type d -maxdepth 10 -name "*sparc*" | xargs rm -Rf
find . -type d -maxdepth 10 -name "*FreeBSD*" | xargs rm -Rf
find . -type d -maxdepth 10 -name "*freebsd*" | xargs rm -Rf
find . -type d -maxdepth 10 -name "*linux-arm*" | xargs rm -Rf
find . -type d -maxdepth 10 -name "mac" | xargs rm -Rf
# Workaround
rm -rf profiler/lib/deployed/
# delete redundant files:
find . -type f -name ".lastModified" -delete
find . -type f -name ".document" -delete
rm -rf nb.cluster.*.build || :
%ifarch %ix86
rm -rf ide/bin/nativeexecution/Linux-x86_64
rm -rf cnd/bin/Linux-x86_64
rm -rf dlight/tools/Linux-x86_64
rm -rf platform/modules/lib/amd64/
rm -rf java/maven/lib/jansi-native/linux64/
%endif
%ifarch x86_64
rm -rf ide/bin/nativeexecution/Linux-x86
rm -rf cnd/bin/Linux-x86
rm -rf dlight/tools/Linux-x86
rm -rf platform/modules/lib/i386/
rm -rf java/maven/lib/jansi-native/linux32/
%endif
# move conf file to etc
install -m 755 -d $RPM_BUILD_ROOT%{_sysconfdir}
cp etc/netbeans.conf $RPM_BUILD_ROOT%{_sysconfdir}
cp etc/netbeans.clusters $RPM_BUILD_ROOT%{_sysconfdir}
cp etc/netbeans.import $RPM_BUILD_ROOT%{_sysconfdir}
rm -rf etc/*
ln -sf /etc/netbeans.conf etc/
ln -sf /etc/netbeans.clusters etc/
ln -sf /etc/netbeans.import etc/
# documentation
FILES_TO_COPY="*.html DEPENDENCIES LICENSE NOTICE"
mkdir -p $RPM_BUILD_ROOT%{_defaultdocdir}/%{name}
cp $FILES_TO_COPY $RPM_BUILD_ROOT%{_defaultdocdir}/%{name}
rm $FILES_TO_COPY
# remve Executable Bits from doc-Files
chmod -x $RPM_BUILD_ROOT%{_defaultdocdir}/%{name}/*.html
# ... and finally the rest:
install -m 755 -d $RPM_BUILD_ROOT%{install_dir}/
cp -rd *     $RPM_BUILD_ROOT%{install_dir}/
# install executable
install -m 755 -d $RPM_BUILD_ROOT/usr/bin/
ln -sf %{install_dir}/bin/netbeans $RPM_BUILD_ROOT/usr/bin/netbeans
# backward compactibillity
ln -sf netbeans $RPM_BUILD_ROOT/usr/bin/netbeans.sh
# documenation
for dir in `find . -maxdepth 2 -type d -name "docs" -print `
do
  DOCDIRNAME=`echo $dir | sed  's/^\.//g'` 
  LINKNAME=`dirname $dir | sed  's/^\.//g'` 
  ln -sf %{install_dir}${DOCDIRNAME} $RPM_BUILD_ROOT%{_defaultdocdir}/%{name}$LINKNAME
done
for dir in `find . -maxdepth 2 -type d -name "licenses" -print `
do
  DOCDIRNAME=`echo $dir | sed  's/^\.//g'` 
  LINKNAME=`dirname $dir | sed  's/^\.//g'` 
  ln -sf %{install_dir}${DOCDIRNAME} $RPM_BUILD_ROOT%{_defaultdocdir}/%{name}$LINKNAME
done
# freedesktop.org menu entry for netbeans
install -Dm 644 %{SOURCE1} $RPM_BUILD_ROOT%{_datadir}/applications/netbeans.desktop
%if 0%{?suse_version}
%suse_update_desktop_file $RPM_BUILD_ROOT%{_datadir}/applications/netbeans.desktop Development IDE
%endif
install -dm 755 $RPM_BUILD_ROOT%{_datadir}/pixmaps/
install -Dpm 644 nb/netbeans.png $RPM_BUILD_ROOT%{_datadir}/pixmaps/netbeans.png
# remove old backup files
find $RPM_BUILD_ROOT%{install_dir} -name "*.bak" -exec rm -rv {} \;
# fix executable bits
find $RPM_BUILD_ROOT%{install_dir} -name "*.sh" -exec chmod +x {} \;
find $RPM_BUILD_ROOT%{install_dir} -name "*.zip" -exec chmod -x {} \;
# fix wrong end-of-line-encoding
find $RPM_BUILD_ROOT%{install_dir} -name "*.html" -exec dos2unix -c ascii {} \;

%fdupes -s %buildroot

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root)
%dir %{_defaultdocdir}/%{name}
%doc %{_defaultdocdir}/%{name}/platform
%doc %{_defaultdocdir}/%{name}/*.html
%doc %{_defaultdocdir}/%{name}/ide
%doc %{_defaultdocdir}/%{name}/nb
%doc %{_defaultdocdir}/%{name}/harness
%doc %{_defaultdocdir}/%{name}/java
%doc %{_defaultdocdir}/%{name}/licenses
%doc %{_defaultdocdir}/%{name}/php
%doc %{_defaultdocdir}/%{name}/webcommon
%doc %{_defaultdocdir}/%{name}/enterprise
%doc %{_defaultdocdir}/%{name}/DEPENDENCIES
%doc %{_defaultdocdir}/%{name}/LICENSE
%doc %{_defaultdocdir}/%{name}/NOTICE
%{_libdir}/%{name}/netbeans.css
%{_bindir}/*
%dir %{install_dir}
%{install_dir}/bin
%{install_dir}/etc
%{install_dir}/harness
%{install_dir}/ide
%{install_dir}/nb
%{install_dir}/platform
%{install_dir}/extide
%{install_dir}/apisupport
%{install_dir}/java
%{install_dir}/profiler
%{install_dir}/javafx
%{install_dir}/licenses
%{install_dir}/websvccommon
%{install_dir}/ergonomics
%{install_dir}/groovy
%{install_dir}/php
%{install_dir}/webcommon
%{install_dir}/enterprise
%{install_dir}/cpplite
%config %{_sysconfdir}/netbeans.conf
%config %{_sysconfdir}/netbeans.clusters
%config %{_sysconfdir}/netbeans.import
%{_datadir}/applications/netbeans.desktop
%{_datadir}/pixmaps/netbeans.png

%changelog
openSUSE Build Service is sponsored by