You are not logged in.

#1 2016-10-03 10:42:48

AlexIL
Member
From: Israel
Registered: 2016-01-02
Posts: 45
Website

[SOLVED] Creating a package that has an install script

Hello fellow archers.
I want to contribute to this package called gopanda.
Right now it doesn't work for me and I also saw some things that I think should be fixed which are listed on my comment there.
To test how the package installs I have downloaded the tarball from their website.
It seems that it has an install script that already does the copying and everything, see the code here:

#!/bin/bash

user_dirs=$HOME/.config/user-dirs.dirs
desktop_dir=$HOME/Desktop

if [ -a $user_dirs ]
then
    source $user_dirs
    desktop_dir=$XDG_DESKTOP_DIR
fi

bin_dir=$HOME/.local/bin
app_dir=$HOME/.local/share/applications
icon_dir=$HOME/.local/share/icons

function install_bin()
{
    mkdir -p $bin_dir
    echo "Installing GoPanda2 to $bin_dir"
    cp -p GoPanda2 nw.pak libffmpegsumo.so icudtl.dat $bin_dir/
}

function install_desktop_file()
{
    mkdir -p $desktop_dir
    mkdir -p $app_dir
    echo "Installing desktop file to $desktop_dir and $app_dir"
    cp -p GoPanda2.orig GoPanda2.desktop
    echo "Exec=$bin_dir/GoPanda2" >> GoPanda2.desktop
    echo "Icon=$icon_dir/GoPanda2.png" >> GoPanda2.desktop
    cp -p GoPanda2.desktop $desktop_dir/
    cp -p GoPanda2.desktop $app_dir/
}

function install_icon()
{
    mkdir -p $icon_dir
    echo "Installing icon to $icon_dir"
    cp -p GoPanda2.png $icon_dir/
}

function check_xdg_utils()
{
    command -v xdg-icon-resource >/dev/null 2>&1 || { echo >&2 "File type association requires xdg-utils to be installed."; exit 1; }
    command -v xdg-mime          >/dev/null 2>&1 || { echo >&2 "File type association requires xdg-utils to be installed."; exit 1; }
}

function install_ugi_mime()
{
    check_xdg_utils
    echo "Associating ugi file type"
    xdg-mime install ugf-mime.xml
    xdg-mime install ugi-mime.xml
    xdg-icon-resource install --context mimetypes --size 192 $icon_dir/GoPanda2.png application-x-go-ugf
    xdg-icon-resource install --context mimetypes --size 192 $icon_dir/GoPanda2.png application-x-go-ugi
    xdg-mime default GoPanda2.desktop application/x-go-ugf
    xdg-mime default GoPanda2.desktop application/x-go-ugi
}

function install_sgf_mime()
{
    check_xdg_utils
    echo "Associating sgf file type"
    xdg-mime install sgf-mime.xml
    xdg-icon-resource install --context mimetypes --size 192 $icon_dir/GoPanda2.png application-x-go-sgf
    xdg-mime default GoPanda2.desktop application/x-go-sgf
}

function associate_mime_types()
{
    echo "What file types do you want to associate with GoPanda2?"
    select choice in "Both" "Ugi" "Sgf" "None"; do
        case $choice in
            Both ) install_ugi_mime; install_sgf_mime; break ;;
            Ugi ) install_ugi_mime; break ;;
            Sgf ) install_sgf_mime; break ;;
            None ) break;;
        esac
    done
}

echo ""

install_bin
install_icon
install_desktop_file
associate_mime_types

echo ""
echo "Done!"
echo ""

So I was thinking it's not ideal for pacman because: 1. the files are already installed on the package phase and 2. pacman doesn't know how to remove them when removing the package.
Should I create a custom script to copy the files into $pkgdir instead of running the install script?

Last edited by AlexIL (2016-10-05 16:20:25)

Offline

#2 2016-10-03 11:10:55

WorMzy
Forum Moderator
From: Scotland
Registered: 2010-06-16
Posts: 11,866
Website

Re: [SOLVED] Creating a package that has an install script

That script is interactive and installs to a user's home directory, it shouldn't be run as root or replicated in a PKGBUILD (you should never touch anything in $HOME, see https://wiki.archlinux.org/index.php/Ar … _standards).

This AUR package is terrible, and should never have been submitted to the AUR as it is.

Should I create a custom script to copy the files into $pkgdir instead of running the install script?

If by "custom script", you mean PKGBUILD, yes, this would be the best approach. Replace $HOME directories with system directories. There are no guarantees that it will work, however. Since GoPanda's script doesn't install to system directories, perhaps there is a reason for this.


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

#3 2016-10-03 11:19:31

ayekat
Member
Registered: 2011-01-17
Posts: 1,590

Re: [SOLVED] Creating a package that has an install script

Also: Mapping `application/x-go-sgf` files to GoPanda by default should not be necessary on a system-wide level. The .desktop file (in /usr/share/applications) already states that GoPanda is able to handle that MIME type. Setting the default should be up to the user, IMHO.
So I think you can remove the entire bottom part (`check_xdg_utils()`, `install_ugi_mime()`, `install_sgf_mime()`, `associate_mime_types()`).


pkgshackscfgblag

Offline

#4 2016-10-03 16:32:24

AlexIL
Member
From: Israel
Registered: 2016-01-02
Posts: 45
Website

Re: [SOLVED] Creating a package that has an install script

WorMzy wrote:

That script is interactive and installs to a user's home directory, it shouldn't be run as root or replicated in a PKGBUILD (you should never touch anything in $HOME, see https://wiki.archlinux.org/index.php/Ar … _standards).

This AUR package is terrible, and should never have been submitted to the AUR as it is.

Should I create a custom script to copy the files into $pkgdir instead of running the install script?

If by "custom script", you mean PKGBUILD, yes, this would be the best approach. Replace $HOME directories with system directories. There are no guarantees that it will work, however. Since GoPanda's script doesn't install to system directories, perhaps there is a reason for this.

Yes, I meant that instead of executing the GoPanda's install script, I'll do all the preparing in build or package.
I'll check if it's possible, however what I'm afraid of is that if GoPanda will change their install script it will break the package...

ayekat wrote:

Also: Mapping `application/x-go-sgf` files to GoPanda by default should not be necessary on a system-wide level. The .desktop file (in /usr/share/applications) already states that GoPanda is able to handle that MIME type. Setting the default should be up to the user, IMHO.
So I think you can remove the entire bottom part (`check_xdg_utils()`, `install_ugi_mime()`, `install_sgf_mime()`, `associate_mime_types()`).

Thanks, I'll do that.

Offline

#5 2016-10-03 22:47:50

AlexIL
Member
From: Israel
Registered: 2016-01-02
Posts: 45
Website

Re: [SOLVED] Creating a package that has an install script

I have written a new PKGBUILD:

# Maintainer: Sébastien Feugère <smonff@riseup.net>
# Contributor: Alex Kubica <alexkubicail@gmail.com>
pkgname=gopanda
pkgver=2
pkgrel=3
pkgdesc="Client for the Pandanet-IGS go Server" 
arch=('i686' 'x86_64')
url="http://pandanet-igs.com/communities/$pkgname$pkgversion"
license=('custom')
depends=('nwjs-bin')
[ "$CARCH" = "i686" ]   && _platform=linux-32
[ "$CARCH" = "x86_64" ] && _platform=linux-64
source=("http://pandanet-igs.com/$pkgname$pkgver/installer/stable/$_platform/$pkgname$pkgver-$_platform.tar.gz")
md5sums=('d1fcd13d8de0f2c0331ee0a9cb58a58a')
_DEST="/usr/share/$pkgname"
_DESKTOP="/usr/share/applications/GoPanda2.desktop"
_ICON="/usr/share/pixmaps/GoPanda2.png"

package() {
	cd "$srcdir/GoPanda2"

	# Copy license
	echo "GoPanda2 belongs to Pandanet Inc, all rights reserved.

The software is delivered \"as is\" and we take no responsibility for
any problems that arise from usage.

GoPanda2 may be redistributed by third parties only when free of
charge or advertisements and without modifications to the
included source code or resource files." > LICENSE
	install -D -m644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"

	# Program
	install -dm755 "${pkgdir}${_DEST}"
  	install -m755 "GoPanda2" "${pkgdir}${_DEST}"
    	install -m644 "nw.pak" "${pkgdir}${_DEST}"
	install -m644 "libffmpegsumo.so" "${pkgdir}${_DEST}"
        install -m644 "icudtl.dat" "${pkgdir}${_DEST}"
	
	# Link to program
	install -dm755 "${pkgdir}/usr/bin"
	ln -s "${_DEST}/GoPanda2" "${pkgdir}/usr/bin/${pkgname}"

	# Icon
	install -Dm644 "GoPanda2.png" "${pkgdir}${_ICON}"

	# Desktop file
	install -Dm644 "GoPanda2.orig" "${pkgdir}${_DESKTOP}"
	echo "Exec=${_DEST}/GoPanda2" >> "${pkgdir}${_DESKTOP}"
	echo "Icon=${_ICON}" >> "${pkgdir}${_DESKTOP}"
}

It doesn't work though...
I have come to the conclusion that it's a nwjs application.
I can run it after extracting the tarball but it doesn't work after packaging and installing via pacman, I'm getting this screen:
67fd52fb6539f740d38337ffb2f6d6a0.png
And this is the output from the terminal:

[16943:1004/014914:ERROR:browser_main_loop.cc(170)] Running without the SUID sandbox! See https://code.google.com/p/chromium/wiki/LinuxSUIDSandboxDevelopment for more information on developing with the sandbox on.
ATTENTION: default value of option force_s3tc_enable overridden by environment.

If someone is familiar with nwjs applications I'll be glad to get some help, I'll try searching a fix for this issue tomorrow.

Edit:
It's very strange.
If I copy the files manually it work perfectly, but if I install them via pacman it doesn't work and I made sure they have the same permissions.
Maybe something happens during the fakeroot?

Last edited by AlexIL (2016-10-04 09:02:28)

Offline

#6 2016-10-05 04:12:56

AlexIL
Member
From: Israel
Registered: 2016-01-02
Posts: 45
Website

Re: [SOLVED] Creating a package that has an install script

It looks like options=(!strip) did the trick, thanks onny!
I'm marking this as solved, posted a PKGBUILD review request here.

Last edited by AlexIL (2016-10-05 16:20:06)

Offline

Board footer

Powered by FluxBB