You are not logged in.

#1 2019-11-22 21:04:31

Brunste
Member
From: United States
Registered: 2018-01-28
Posts: 19

[SOLVED] Creating packages that require an environment variable

I am rather new to creating and modifying packages, but out of necessity I have been trying to modify the existing modustoolbox package on the AUR to build the newest 2.0.0 version rather than the 1.1.0 version the package is currently left at. Despite somehow managing to get the package installed and running successfully, the program now requires an environment variable pointing to a folder within the installation directory to be set before I can do anything useful with it.  What is the best way to go about doing this within the package?

The environment variable I need to set is:

CY_TOOLS_PATHS=/opt/ModusToolbox/tools_2.0/

My current PKGBUILD file is:

pkgname=modustoolbox
pkgver=2.0.0
pkgrel=234
pkgdesc="ModusToolbox simplifies development for IoT designers. IDE for PSoC 6"
arch=('x86_64')
license=(custom)
depends=('make' 'coreutils' 'perl' 'diffutils')
url="https://www.cypress.com/products/modustoolbox-software-environment"
options=('!strip')

source=(http://dlm.cypress.com.edgesuite.net/akdlm/downloadmanager/WICED_MODUS/P-ModusToolbox_2.0.0.1703-linux-install.tar.gz)
sha256sums=('8726d73c5f7bf7cb29d4d245b30ad2954922f4e40a12fdaedd5be83658b691f8')

package() {
	cd "${srcdir}"

	install -d -m755 "${pkgdir}/opt/${pkgname}"

	cp -r "${srcdir}/ModusToolbox/" "${pkgdir}/opt/"

	# Installing udev rules
	install -Dm644 "${srcdir}/ModusToolbox/tools_2.0/fw-loader/udev_rules/57-cypress_programmer.rules" "${pkgdir}/etc/udev/rules.d/57-cypress_programmer.rules"
	install -Dm644 "${srcdir}/ModusToolbox/tools_2.0/openocd/udev_rules/60-openocd.rules" "${pkgdir}/etc/udev/rules.d/60-opencd.rules"
	install -Dm644 "${srcdir}/ModusToolbox/tools_2.0/openocd/udev_rules/66-wiced-JTAG.rules" "${pkgdir}/etc/udev/rules.d/66-wiced-JTAG.rules"
	install -Dm644 "${srcdir}/ModusToolbox/tools_2.0/driver_media/67-wiced-JTAG.rules" "${pkgdir}/etc/udev/rules.d/67-wiced-JTAG.rules"
	install -Dm644 "${srcdir}/ModusToolbox/tools_2.0/driver_media/cypress_ftdi.sh" "${pkgdir}/opt/cypress/cypress_ftdi.sh"
	install -Dm644 "${srcdir}/ModusToolbox/tools_2.0/driver_media/cypress_cdc_acm.sh" "${pkgdir}/opt/cypress/cypress_cdc_acm.sh"


	# Run final install script
	sh ${srcdir}/ModusToolbox/tools_2.0/modus-shell/postinstall

	# symbolic link to make
	ln -sf /usr/bin/make ${pkgdir}/opt/ModusToolbox/tools_2.0/modus-shell/bin/make
	
	# Installing desktop shortcuts
	install -d -m755 "${pkgdir}/usr/share/applications"
cat <<EOF > "${pkgdir}/usr/share/applications/ModusToolbox-x86_64-${pkgver}.desktop"
[Desktop Entry]
Name=ModusToolbox
Version=${pkgver}
Comment=${pkgdesc}
GenericName=ModusToolbox
Exec=/opt/ModusToolbox/ide_2.0/eclipse/ModusToolbox
Icon=/opt/ModusToolbox/ide_2.0/eclipse/icon.xpm
Path=/opt/ModusToolbox/ide_2.0/eclipse/
Terminal=false
StartupNotify=true
Type=Application
Categories=Development
EOF
}

Feel free to critique any unrelated mistakes or bad practices that may be obvious in what I have done so far too. I would greatly appreciate any feedback that gives me the opportunity to improve.

Last edited by Brunste (2019-11-25 23:02:46)

Offline

#2 2019-11-22 21:29:54

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 22,409
Website

Re: [SOLVED] Creating packages that require an environment variable

Brunste wrote:

the program now requires an environment variable pointing to a folder within the installation directory to be set before I can do anything useful with it.

The variable needs to be set in the runtime environment right, not (just) at build time?  If so, just include a file to be installed to /etc/profile.d/ that sets the variable.

I'm glad you did not try to run all their install scripts but instead just copied over those udev rules directly - their scripts would not have worked.  As for the postinstall script, if that is to do anything useful at all, it will need to be be moved to the pkgdir before being executed - but this one too should just be done manually.  It just creates (tries to create) a handful of symlinks.

Also note that the pkgname should be modustoolbox-bin as this is distributing precompiled binaries.

Last edited by Trilby (2019-11-23 00:10:44)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2019-11-23 14:36:54

Lone_Wolf
Member
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 7,467

Re: [SOLVED] Creating packages that require an environment variable

With a custom license you need to copy the license file(s) to the correct location, https://wiki.archlinux.org/index.php/PKGBUILD#license


Multi-init booting with apg Openrc and systemd coexisting
Automounting : not needed, i prefer pmount
Aur helpers : makepkg + my own local repo === rarely need them

Offline

#4 2019-11-25 23:02:15

Brunste
Member
From: United States
Registered: 2018-01-28
Posts: 19

Re: [SOLVED] Creating packages that require an environment variable

Thank you all for your suggestions. I rebuilt and installed the package again and it seems to be working. I'll include the updated copy of my PKGBUILD below and mark this thread as solved.

pkgname=modustoolbox-bin
pkgver=2.0.0
pkgrel=234
pkgdesc="Set of multi-platform development tools by Cypress. IDE for PSoC 6"
arch=('x86_64')
license=(custom)
depends=('make' 'coreutils' 'perl' 'diffutils')
url="https://www.cypress.com/products/modustoolbox-software-environment"
options=('!strip')

source=(http://dlm.cypress.com.edgesuite.net/akdlm/downloadmanager/WICED_MODUS/P-ModusToolbox_2.0.0.1703-linux-install.tar.gz)
sha256sums=('8726d73c5f7bf7cb29d4d245b30ad2954922f4e40a12fdaedd5be83658b691f8')

package() {
	cd "${srcdir}"

	install -d -m755 "${pkgdir}/opt/${pkgname}"

	cp -r "${srcdir}/ModusToolbox/" "${pkgdir}/opt/"

	# Create environment variable
	echo "EXPORT CY_TOOLS_PATHS=/opt/ModusToolbox/tools_2.0/" >> ${srcdir}/modustoolbox
	install -Dm644 "${srcdir}/modustoolbox" "{$pkgdir}/etc/profile.d/modustoolbox"

	# Installing udev rules
	install -Dm644 "${srcdir}/ModusToolbox/tools_2.0/fw-loader/udev_rules/57-cypress_programmer.rules" "${pkgdir}/etc/udev/rules.d/57-cypress_programmer.rules"
	install -Dm644 "${srcdir}/ModusToolbox/tools_2.0/openocd/udev_rules/60-openocd.rules" "${pkgdir}/etc/udev/rules.d/60-opencd.rules"
	install -Dm644 "${srcdir}/ModusToolbox/tools_2.0/openocd/udev_rules/66-wiced-JTAG.rules" "${pkgdir}/etc/udev/rules.d/66-wiced-JTAG.rules"
	install -Dm644 "${srcdir}/ModusToolbox/tools_2.0/driver_media/67-wiced-JTAG.rules" "${pkgdir}/etc/udev/rules.d/67-wiced-JTAG.rules"
	install -Dm644 "${srcdir}/ModusToolbox/tools_2.0/driver_media/cypress_ftdi.sh" "${pkgdir}/opt/cypress/cypress_ftdi.sh"
	install -Dm644 "${srcdir}/ModusToolbox/tools_2.0/driver_media/cypress_cdc_acm.sh" "${pkgdir}/opt/cypress/cypress_cdc_acm.sh"

	# Install license
	install -Dm644 "${srcdir}/ModusToolbox/CYPRESS END USER LICENSE AGREEMENT.txt" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"

	# symbolic link to tools
	ln -sf /usr/bin/cat    ${pkgdir}/opt/ModusToolbox/tools_2.0/modus-shell/bin/cat
	ln -sf /usr/bin/cp     ${pkgdir}/opt/ModusToolbox/tools_2.0/modus-shell/bin/cp
	ln -sf /usr/bin/make   ${pkgdir}/opt/ModusToolbox/tools_2.0/modus-shell/bin/make
	ln -sf /usr/bin/mkdir  ${pkgdir}/opt/ModusToolbox/tools_2.0/modus-shell/bin/mkdir
	ln -sf /usr/bin/mktemp ${pkgdir}/opt/ModusToolbox/tools_2.0/modus-shell/bin/mktemp
	ln -sf /usr/bin/mv     ${pkgdir}/opt/ModusToolbox/tools_2.0/modus-shell/bin/mv
	ln -sf /usr/bin/perl   ${pkgdir}/opt/ModusToolbox/tools_2.0/modus-shell/bin/perl
	ln -sf /usr/bin/rm     ${pkgdir}/opt/ModusToolbox/tools_2.0/modus-shell/bin/rm
	ln -sf /usr/bin/rmdir  ${pkgdir}/opt/ModusToolbox/tools_2.0/modus-shell/bin/rmdir
	ln -sf /usr/bin/sh     ${pkgdir}/opt/ModusToolbox/tools_2.0/modus-shell/bin/sh
	ln -sf /usr/bin/bash   ${pkgdir}/opt/ModusToolbox/tools_2.0/modus-shell/bin/bash

	# Installing desktop shortcuts
	install -d -m755 "${pkgdir}/usr/share/applications"
cat <<EOF > "${pkgdir}/usr/share/applications/ModusToolbox-x86_64-${pkgver}.desktop"
[Desktop Entry]
Name=ModusToolbox
Version=${pkgver}
Comment=${pkgdesc}
GenericName=ModusToolbox
Exec=/opt/ModusToolbox/ide_2.0/eclipse/ModusToolbox
Icon=/opt/ModusToolbox/ide_2.0/eclipse/icon.xpm
Path=/opt/ModusToolbox/ide_2.0/eclipse/
Terminal=false
StartupNotify=true
Type=Application
Categories=Development
EOF
}

Last edited by Brunste (2019-11-26 15:13:04)

Offline

#5 2019-11-25 23:15:38

Slithery
Forum Moderator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 3,504

Re: [SOLVED] Creating packages that require an environment variable

The pkgdesc variable shouldn't contain the name of the program...
https://wiki.archlinux.org/index.php/PKGBUILD#pkgdesc


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Online

#6 2019-11-25 23:35:08

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 22,409
Website

Re: [SOLVED] Creating packages that require an environment variable

Trilby wrote:

the pkgname should be modustoolbox-bin as this is distributing precompiled binaries.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#7 2019-11-26 15:13:07

Brunste
Member
From: United States
Registered: 2018-01-28
Posts: 19

Re: [SOLVED] Creating packages that require an environment variable

Slithery wrote:

The pkgdesc variable shouldn't contain the name of the program...
https://wiki.archlinux.org/index.php/PKGBUILD#pkgdesc

Trilby wrote:
Trilby wrote:

the pkgname should be modustoolbox-bin as this is distributing precompiled binaries.

Whoops. Edited my last post to resolve these issues. Thank you all again for your help (and patience).

Last edited by Brunste (2019-11-26 15:18:29)

Offline

#8 2019-11-26 15:28:09

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 22,409
Website

Re: [SOLVED] Creating packages that require an environment variable

Thanks.  Nice work on this.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

Board footer

Powered by FluxBB