Skip to content

Instantly share code, notes, and snippets.

@felipe19930
Created July 26, 2021 15:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save felipe19930/ccffeff49b961073632a37107cee30e3 to your computer and use it in GitHub Desktop.
Save felipe19930/ccffeff49b961073632a37107cee30e3 to your computer and use it in GitHub Desktop.
wallpaperdownloader
# Maintainer: Eloy Garcia Almaden <eloy.garcia.pca@gmail.com>
# Contributor: gbr <gbr@protonmail.com>
pkgname=wallpaperdownloader
pkgver=4.2
pkgrel=1
pkgdesc='Download, manage and change automatically your favorite wallpapers from the Internet'
arch=('any')
url='https://bitbucket.org/eloy_garcia_pca/wallpaperdownloader'
license=('GPL2')
depends=('java-runtime>=8' 'xdg-utils')
makedepends=('java-environment>=8' 'maven')
source=("$pkgname-$pkgver.tar.gz::$url/get/v$pkgver.tar.gz"
wallpaperdownloader.{desktop,sh})
noextract=("${source[@]%%::*}")
sha256sums=('76e8d523f6127032d08f33167e9182ae52d5900d98c314a85c7f7aba73592a12'
'SKIP' 'SKIP')
prepare() {
mkdir -p "$pkgname-$pkgver"
bsdtar -C "$pkgname-$pkgver" -x -f "$pkgname-$pkgver.tar.gz" --strip-components 1
}
build() {
cd "$pkgname-$pkgver"
mvn clean package -DpackagingPhase=none
}
package() {
cd "$pkgname-$pkgver"
install -Dm644 "target/$pkgname.jar" "$pkgdir/usr/share/java/$pkgname/$pkgname.jar"
install -Dm755 "$srcdir/$pkgname.sh" "$pkgdir/usr/bin/$pkgname"
install -Dm644 "$srcdir/$pkgname.desktop" "$pkgdir/usr/share/applications/$pkgname.desktop"
install -Dm644 "aur/$pkgname.svg" "$pkgdir/usr/share/icons/hicolor/scalable/apps/$pkgname.svg"
}
[Desktop Entry]
Name=WallpaperDownloader
GenericName=Wallpaper Downloader
Comment=Download, manage and change your wallpapers automatically from the Internet
Keywords=wallpaper;gallery;internet;download;downloader;changer;picture;desktop
Exec=/usr/bin/wallpaperdownloader
Icon=wallpaperdownloader
Terminal=false
Type=Application
Categories=Utility;
#!/bin/sh
if /usr/bin/java -version 2>&1 | grep 'version "1.7' >/dev/null
then
echo "WallpaperDownloader requires Java 8 or higher" >&2
exit 1
fi
# Memory usage is limited to 256 MBytes of RAM
exec /usr/bin/java -Xmx256m -Xms128m -jar '/usr/share/java/wallpaperdownloader/wallpaperdownloader.jar' "$@"
@egara
Copy link

egara commented Jul 27, 2021

Hi @felipe19930 I'm the WallpaperDownloader developer. Thank you very much for your contribution to the project and to the packaging!. Of course, I'll take a look at your solution and test it. If everything is working fine, I will incorporate all your suggestions.

Again, thank you very much for helping to improve the AUR package!!! :D

@felipe19930
Copy link
Author

@egara awesome! let me know if you have any questions

@egara
Copy link

egara commented Aug 1, 2021

Hi again @felipe19930

I've been testing it and it works like a charm. It is a very good contribution and I'm going to include all your files in AUR. For version 4.2, I'm going to change only the AUR repository, but I would like to include all these changes upstream, so I would modify the launching script and desktop file in the project's repository accordingly for version 4.3.

With all this in mind, I have modified a little bit PKGBUILD. Could you check it? If you think everything would work fine, I'll push all these changes into devel branch of WallpaperDownloader git repository.

# Maintainer: Eloy Garcia Almaden <eloy.garcia.pca@gmail.com>
# Contributor: gbr <gbr@protonmail.com>
pkgname=wallpaperdownloader
pkgver=4.3
pkgrel=1  
pkgdesc='Download, manage and change automatically your favorite wallpapers from the Internet'
arch=('any')
url='https://bitbucket.org/eloy_garcia_pca/wallpaperdownloader'
license=('GPL3')
depends=('java-runtime>=8' 'xdg-utils')
makedepends=('java-environment>=8' 'maven')
source=("$pkgname-$pkgver.tar.gz::$url/get/v$pkgver.tar.gz")
noextract=()  
sha256sums=('TODO:CALCULATETHISVALUE')
 
build() {
    cd "$pkgname-$pkgver"
    mvn clean package -DpackagingPhase=none
}

package() {
    cd "$pkgname-$pkgver"

    # Complete jar
    install -Dm644 "target/$pkgname.jar" "$pkgdir/usr/share/java/$pkgname/$pkgname.jar"

    # Launching script 
    install -Dm755 "aur/$pkgname.sh" "$pkgdir/usr/bin/$pkgname"

    # .desktop file and icon
    install -Dm644 "aur/$pkgname.desktop" "$pkgdir/usr/share/applications/$pkgname.desktop"
    install -Dm644 "aur/$pkgname.svg" "$pkgdir/usr/share/icons/hicolor/scalable/apps/$pkgname.svg"
}

Take into account that wallpaperdownloader.desktop and wallpaperdownloader.sh would be included directly in the repository so no need to patch them in AUR.

Thank you very much!! :)

Best,

Eloy

@felipe19930
Copy link
Author

Hi @egara, sorry I took too long to respond you.

Unfortunately, your modifications won't work as-is. Specifically, the prepare() function I originally added, is actually necessary to extract the tarball to the "right" directory. Let me try to explain a bit better.

When you download a versioned tarball from BitBucket, the root directory inside the tarball is named like this: $PROJECT_OWNER-$PROJECT_NAME-$COMMIT, i.e.: /eloy_garcia_pca-wallpaperdownloader-7d8fd7a68b34/<source_code_here>

So, by removing the prepare() function and the noextract variable, makepkg will automatically extract the tarball, but we won't be able to easily cd into the right directory to build Wallpaper Downloader, unless we also store the commit of the version each time there's an update.

My original approach, however, prevents makepkg from extracting the tarball, and then we manually extract it using bsdtar in prepare(), but onto a more "standardized" directory name, i.e. "wallpaperdownloader-$VERSION".

Aside from that, I agree with you that there's no need to also upload the .desktop and .sh files to the AUR, so I was hoping you could upstream them to your repository, eventually.

Cheers.

@egara
Copy link

egara commented Aug 14, 2021

Hi @felipe19930 and no worries at all. Thank you very much for answering and thanks for the explanation. Now, everything is much clearer for me. I think this final version would suit all the requirements when I include modified wallpaperdownloader.desktop and wallpaperdownloader.sh files upstream in the aur directory of my project:


# Maintainer: Eloy Garcia Almaden <eloy.garcia.pca@gmail.com>
# Contributor: gbr <gbr@protonmail.com>
pkgname=wallpaperdownloader
pkgver=4.3
pkgrel=1  
pkgdesc='Download, manage and change automatically your favorite wallpapers from the Internet'
arch=('any')
url='https://bitbucket.org/eloy_garcia_pca/wallpaperdownloader'
license=('GPL3')
depends=('java-runtime>=8' 'xdg-utils')
makedepends=('java-environment>=8' 'maven')
source=("$pkgname-$pkgver.tar.gz::$url/get/v$pkgver.tar.gz")
noextract=("${source[@]%%::*}")
sha256sums=('TODO:CALCULATETHISVALUE')

prepare() {
    mkdir -p "$pkgname-$pkgver"
    bsdtar -C "$pkgname-$pkgver" -x -f "$pkgname-$pkgver.tar.gz" --strip-components 1
}

build() {
    cd "$pkgname-$pkgver"
    mvn clean package -DpackagingPhase=none
}

package() {
    cd "$pkgname-$pkgver"

    # Complete jar
    install -Dm644 "target/$pkgname.jar" "$pkgdir/usr/share/java/$pkgname/$pkgname.jar"

    # Launching script 
    install -Dm755 "aur/$pkgname.sh" "$pkgdir/usr/bin/$pkgname"

    # .desktop file and icon
    install -Dm644 "aur/$pkgname.desktop" "$pkgdir/usr/share/applications/$pkgname.desktop"
    install -Dm644 "aur/$pkgname.svg" "$pkgdir/usr/share/icons/hicolor/scalable/apps/$pkgname.svg"
}

If you give me your OK I update those files in my devel branch to get them ready for my next release.

Best,

Eloy

@felipe19930
Copy link
Author

Everything seems fine now. :)

You have my blessing 😄

@egara
Copy link

egara commented Aug 15, 2021

Great, thanks!!! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment