File jdownloader2.spec of Package jdownloader

#
# spec file for package jdownloader2
#
# Copyright (c) 2025 SUSE LLC
# Copyright (c) 2025 itachi re <itachi_re@opensuse.org>
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
#

Name:           jdownloader2
Version:        2.0
Release:        0
Summary:        Download manager for file hosters
License:        GPL-3.0-or-later
Group:          Productivity/Networking/Web/Utilities
URL:            https://jdownloader.org/
Source0:        JDownloader.jar
Source1:        jdownloader2.png
BuildRequires:  javapackages-tools
BuildRequires:  desktop-file-utils
BuildRequires:  fdupes
Requires:       java >= 1.8.0
BuildArch:      noarch

%description
JDownloader is a free, open-source download management tool with a
huge community that makes downloading as easy and fast as it should be.
Users can start, stop or pause downloads, set bandwidth limitations,
auto-extract archives and much more. It's an easy-to-extend framework
that can save hours of your valuable time every day.

Features include:
- Download from multiple file hosters
- CAPTCHA recognition
- Automatic extraction
- Multiple parallel downloads
- Plugin system for extensibility

%prep
# No prep needed - using the JAR directly

%build
# No build needed - Java application

%check
# No test suite available in upstream JAR installer

%install
# Install directory structure
install -d -m 755 %{buildroot}%{_datadir}/%{name}
install -d -m 755 %{buildroot}%{_bindir}

# Install the JAR file
install -m 644 %{SOURCE0} %{buildroot}%{_datadir}/%{name}/JDownloader.jar

# Create wrapper script
cat > %{buildroot}%{_bindir}/%{name} << 'EOF'
#!/bin/bash
# JDownloader2 launcher script

JD_HOME="${HOME}/.jdownloader"
JD_JAR="%{_datadir}/%{name}/JDownloader.jar"

# Create JD_HOME if it doesn't exist
if [ ! -d "${JD_HOME}" ]; then
    mkdir -p "${JD_HOME}"
fi

# Copy the JAR to user's home on first run if not exists
if [ ! -f "${JD_HOME}/JDownloader.jar" ]; then
    cp "${JD_JAR}" "${JD_HOME}/JDownloader.jar"
fi

# Launch JDownloader
cd "${JD_HOME}"
exec java -jar "${JD_HOME}/JDownloader.jar" "$@"
EOF

chmod 755 %{buildroot}%{_bindir}/%{name}

# Create desktop file
install -d -m 755 %{buildroot}%{_datadir}/applications
cat > %{buildroot}%{_datadir}/applications/%{name}.desktop << 'EOF'
[Desktop Entry]
Version=1.0
Type=Application
Name=JDownloader 2
GenericName=Download Manager
Comment=Open source download management tool
Exec=jdownloader2
Icon=jdownloader2
Terminal=false
Categories=Network;FileTransfer;Java;
Keywords=download;manager;file;hoster;
StartupNotify=true
EOF

# Validate desktop file
desktop-file-validate %{buildroot}%{_datadir}/applications/%{name}.desktop

# Install PNG icon
install -d -m 755 %{buildroot}%{_datadir}/pixmaps
install -m 644 %{SOURCE1} %{buildroot}%{_datadir}/pixmaps/%{name}.png

# Also install in icons directory for better desktop integration
install -d -m 755 %{buildroot}%{_datadir}/icons/hicolor/48x48/apps
install -m 644 %{SOURCE1} %{buildroot}%{_datadir}/icons/hicolor/48x48/apps/%{name}.png

# Add this line to find and link duplicate files
%fdupes %{buildroot}

%files
%{_bindir}/%{name}
%{_datadir}/%{name}
%{_datadir}/applications/%{name}.desktop
%{_datadir}/pixmaps/%{name}.png
%{_datadir}/icons/hicolor/48x48/apps/%{name}.png
%dir %{_datadir}/icons/hicolor
%dir %{_datadir}/icons/hicolor/48x48
%dir %{_datadir}/icons/hicolor/48x48/apps

%changelog
* Mon Nov 03 2025 Your itachi_re <xanbenson99@gmail.com>
- Initial package for openSUSE Tumbleweed
- Package JDownloader 2 download manager
- Add desktop integration and launcher script
openSUSE Build Service is sponsored by