From 53b4e138575d7900ba85e135324fcb2c3453a841 Mon Sep 17 00:00:00 2001 From: Jonas8272 Date: Mon, 23 Nov 2026 06:24:49 +0000 Subject: [PATCH] add jdownloader (official bootstrap JAR via Scoop Java): manifest, daily hash updater, install script, README --- .forgejo/workflows/autoupdate-jdownloader.yml | 28 ++++++ README.md | 18 ++++ bucket/jdownloader.json | 15 +++ installations/install-all.ps1 | 8 ++ installations/install-jdownloader.ps1 | 97 +++++++++++++++++++ scripts/update-jdownloader.sh | 26 +++++ 6 files changed, 192 insertions(+) create mode 100644 .forgejo/workflows/autoupdate-jdownloader.yml create mode 100644 bucket/jdownloader.json create mode 100644 installations/install-jdownloader.ps1 create mode 100644 scripts/update-jdownloader.sh diff --git a/.forgejo/workflows/autoupdate-jdownloader.yml b/.forgejo/workflows/autoupdate-jdownloader.yml new file mode 100644 index 0000000..f4a3fa3 --- /dev/null +++ b/.forgejo/workflows/autoupdate-jdownloader.yml @@ -0,0 +1,28 @@ +name: autoupdate-jdownloader +on: + schedule: + - cron: '53 5 * * *' + workflow_dispatch: + +jobs: + update: + runs-on: ubuntu-latest + container: + image: data.forgejo.org/oci/node:20-bookworm + steps: + - name: Install tools + run: apt-get update -qq && apt-get install -y -qq jq + + - uses: actions/checkout@v4 + + - name: Update manifest + run: tr -d '\r' < scripts/update-jdownloader.sh | bash + + - name: Commit and push + run: | + git config user.name "autoupdate" + git config user.email "autoupdate@users.noreply.codefloe.com" + if ! git diff --quiet; then + git commit -am "jdownloader: update to $(jq -r .version bucket/jdownloader.json)" + git push + fi diff --git a/README.md b/README.md index 45c14ff..87be53d 100644 --- a/README.md +++ b/README.md @@ -204,6 +204,24 @@ irm https://codefloe.com/Jonas8272/scoop-bucket/raw/branch/master/installations/ > **Note:** For other versions check out [gandli's](https://github.com/gandli/scoop-vmware) bucket +## Installing jdownloader + +JDownloader 2: a download manager that grabs files and links from many sites. + +```powershell +scoop install Jonas8272/jdownloader +``` + +Or set up everything and install it with one script: + +```powershell +irm https://codefloe.com/Jonas8272/scoop-bucket/raw/branch/master/installations/install-jdownloader.ps1 | iex +``` + +> **Note:** This uses JDownloader's official JAR file, so it needs Java. Scoop installs `java/temurin-jre` for you from the official `java` bucket (the scripts add that bucket if it is missing). The first time you start JDownloader, it downloads the rest of the app from its own servers. + +> **Note:** JDownloader updates itself. The bucket re-checks the official JAR every day and updates the manifest when the file changes, so `scoop update` only fetches the small bootstrap file again. + ## Updating Update Scoop and its bucket manifests: diff --git a/bucket/jdownloader.json b/bucket/jdownloader.json new file mode 100644 index 0000000..68ea5e8 --- /dev/null +++ b/bucket/jdownloader.json @@ -0,0 +1,15 @@ +{ + "version": "0.0.0", + "description": "JDownloader 2 download manager (official bootstrap JAR; it downloads the app on first run)", + "homepage": "https://jdownloader.org/", + "license": "Freeware", + "depends": "java/temurin-jre", + "url": "https://installer.jdownloader.org/JDownloader.jar", + "hash": "0000000000000000000000000000000000000000000000000000000000000000", + "pre_install": "Set-Content -Path \"$dir\\JDownloader.cmd\" -Value '@echo off', 'start \"\" javaw -jar \"%~dp0JDownloader.jar\"' -Encoding Ascii", + "bin": "JDownloader.cmd", + "shortcuts": [ + ["JDownloader.cmd", "JDownloader 2"] + ], + "persist": "cfg" +} diff --git a/installations/install-all.ps1 b/installations/install-all.ps1 index b44d540..7848962 100644 --- a/installations/install-all.ps1 +++ b/installations/install-all.ps1 @@ -115,6 +115,14 @@ if (-not $manifests) { throw "No app manifests found in $bucketDir." } +# Some apps (for example jdownloader) depend on packages from the official 'java' bucket +$needsJava = $manifests | Where-Object { (Get-Content -Path $_.FullName -Raw) -match '"depends"\s*:\s*"java/' } +if ($needsJava -and -not (scoop bucket list | Where-Object { $_.Name -eq 'java' })) { + Write-Host "Adding the 'java' bucket..." -ForegroundColor Cyan + scoop bucket add java + if ($LASTEXITCODE -ne 0) { throw "Failed to add the 'java' bucket." } +} + # 5. Install them ------------------------------------------------------------ $isAdmin = Test-Admin $results = @() diff --git a/installations/install-jdownloader.ps1 b/installations/install-jdownloader.ps1 new file mode 100644 index 0000000..09c38c4 --- /dev/null +++ b/installations/install-jdownloader.ps1 @@ -0,0 +1,97 @@ +<# +.SYNOPSIS + Installs JDownloader from the Jonas8272 bucket. Sets up Scoop, git and the + bucket first if they are missing. + +.DESCRIPTION + JDownloader is installed from its official JAR file, so it needs Java. Scoop + installs java/temurin-jre for you from the official 'java' bucket, which this + script adds if it is missing. The first time you start JDownloader it + downloads the rest of the app from its own servers. + +.EXAMPLE + irm https://codefloe.com/Jonas8272/scoop-bucket/raw/branch/master/installations/install-jdownloader.ps1 | iex + +.NOTES + Run in a normal (non-admin) PowerShell window if Scoop is not installed yet. +#> + +$ErrorActionPreference = 'Stop' + +$App = 'jdownloader' +$BucketName = 'Jonas8272' +$BucketUrl = 'https://codefloe.com/Jonas8272/scoop-bucket' + +function Test-Command($name) { + return [bool](Get-Command $name -ErrorAction SilentlyContinue) +} + +function Test-Admin { + $id = [Security.Principal.WindowsIdentity]::GetCurrent() + $principal = New-Object Security.Principal.WindowsPrincipal($id) + return $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) +} + +$scoopRoot = if ($env:SCOOP) { $env:SCOOP } else { Join-Path $env:USERPROFILE 'scoop' } + +# 1. Scoop ------------------------------------------------------------------- +if (-not (Test-Command 'scoop')) { + Write-Host 'Scoop not found. Installing Scoop...' -ForegroundColor Cyan + Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser -Force + if (Test-Admin) { + Invoke-Expression "& {$(Invoke-RestMethod -Uri 'https://get.scoop.sh')} -RunAsAdmin" + } else { + Invoke-RestMethod -Uri 'https://get.scoop.sh' | Invoke-Expression + } + + # Make scoop available in this session without reopening PowerShell + $env:PATH = "$scoopRoot\shims;$env:PATH" + + if (-not (Test-Command 'scoop')) { + throw 'Scoop was installed but is not on PATH. Open a new PowerShell window and run this script again.' + } +} else { + Write-Host 'Scoop is already installed.' -ForegroundColor Green +} + +# 2. git (needed to add buckets) ---------------------------------------------- +if (-not (Test-Command 'git')) { + Write-Host 'git not found. Installing git through Scoop...' -ForegroundColor Cyan + scoop install git + if ($LASTEXITCODE -ne 0) { throw 'Failed to install git through Scoop.' } + $env:PATH = "$scoopRoot\shims;$env:PATH" +} else { + Write-Host 'git is already installed.' -ForegroundColor Green +} + +# 3. Bucket ------------------------------------------------------------------ +$existing = scoop bucket list | Where-Object { + $_.Name -eq $BucketName -or $_.Source -like '*Jonas8272/scoop-bucket*' +} | Select-Object -First 1 + +if ($existing) { + $BucketName = $existing.Name + Write-Host "Bucket '$BucketName' is already added. Updating it..." -ForegroundColor Green + scoop update +} else { + Write-Host "Adding bucket '$BucketName'..." -ForegroundColor Cyan + scoop bucket add $BucketName $BucketUrl + if ($LASTEXITCODE -ne 0) { throw "Failed to add bucket '$BucketName'." } +} + +# 4. The official 'java' bucket (jdownloader depends on java/temurin-jre) ------ +$javaBucket = scoop bucket list | Where-Object { $_.Name -eq 'java' } | Select-Object -First 1 +if (-not $javaBucket) { + Write-Host "Adding the 'java' bucket..." -ForegroundColor Cyan + scoop bucket add java + if ($LASTEXITCODE -ne 0) { throw "Failed to add the 'java' bucket." } +} + +# 5. The app ----------------------------------------------------------------- +Write-Host '' +Write-Host "Installing $App..." -ForegroundColor Cyan +scoop install "$BucketName/$App" +if ($LASTEXITCODE -ne 0) { throw "Failed to install $App." } + +Write-Host '' +Write-Host "Done. $App is installed." -ForegroundColor Green diff --git a/scripts/update-jdownloader.sh b/scripts/update-jdownloader.sh new file mode 100644 index 0000000..9ada22f --- /dev/null +++ b/scripts/update-jdownloader.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +set -euo pipefail + +M=bucket/jdownloader.json +URL=https://installer.jdownloader.org/JDownloader.jar + +# Download the official bootstrap JAR and hash it. +curl -fsSL -o /tmp/JDownloader.jar "$URL" +[ "$(head -c2 /tmp/JDownloader.jar)" = "PK" ] || { echo "download is not a jar" >&2; exit 1; } +hash=$(sha256sum /tmp/JDownloader.jar | cut -d' ' -f1) +cur_hash=$(jq -r .hash "$M") + +if [ "$hash" = "$cur_hash" ]; then + echo "up to date ($hash)" + exit 0 +fi + +# Version = date and time the file was last modified (falls back to now). +lm=$(curl -fsSI "$URL" | tr -d '\r' | grep -i '^last-modified:' | head -1 | cut -d' ' -f2- || true) +ver=$(date -u -d "${lm:-now}" +%Y.%m.%d.%H%M 2>/dev/null || date -u +%Y.%m.%d.%H%M) +cur=$(jq -r .version "$M") + +jq --indent 4 --arg v "$ver" --arg h "$hash" '.version=$v | .hash=$h' \ + "$M" > "$M.tmp" && mv "$M.tmp" "$M" + +echo "updated $cur -> $ver"