You are not logged in.

#1 2022-01-26 19:41:08

_urd
Member
Registered: 2022-01-24
Posts: 3

PKGBULID review request: nrf-connect-sdk-git

This is my first PKGBUILD. Could I get some feedback on what could be done better?

I made an PKGBUILD for the nRF Connect SDK.
It basically performs the steps described in the Manual Installation Guide.
In addition, I put some comments/questions at the bottom of this, but here are the files:

PKGBUILD:

# Maintainer: Sigurd Hellesvik <sigurd.hellesvik@protonmail.com>

# Disclaimer: This package is not from Nordic Semiconductor
pkgname=nrf-connect-sdk-git
pkgver=1.8.0
pkgrel=1
pkgdesc="The nRF Connect SDK"
arch=('x86_64')
url="https://github.com/nrfconnect/sdk-nrf"
license=('custom:LicenseRef-Nordic-5-Clause')
install=nrf-connect-sdk.install
options=(!strip)
depends=(
'cmake'
'ninja'
'gperf'
'ccache'
'dfu-util'
'dtc'
'python'
'python-setuptools'
'tk'
'python-wheel'
'xz'
'file'
'make'
'gcc'
'python-intelhex'
'python-pyelftools' 
#AUR dependencies
'gcc-arm-none-eabi-bin'
'python-west'
'nrf5x-command-line-tools'
)
makedepends=(
'git'
'wget'
)
#All Python dependencies are from the nRF Connect SDK Python requirements.
#They are described in the documentation at 
#https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.8.0/nrf/gs_installing.html#id9
#The packages from those scripts found in pacman/AUR is listed below
#If you need them, concider installing them using a Virtual Environment instead.
optdepends=(
'gn-m85: Matter support'
'python-ecdsa: nrf-sdk requirements-build.txt'
'python-imagesize: nrf-sdk requirements-build.txt'
'python-pylint: nrf-sdk requirements-build.txt'
'python-regex: nrf-sdk requirements-build.txt' 
'python-recommonmark: nrf-sdk requirements-docs.txt '
'python-commonmark: nrf-sdk requirements-docs.txt'
'python-sphinx: nrf-sdk requirements-docs.txt'
'python-pygments: nrf-sdk requirements-docs.txt'
'python-m2r2: nrf-sdk requirements-docs.txt'
'python-sphinxcontrib-plantuml: nrf-sdk requirements-docs.txt'
'python-pygit2: nrf-sdk requirements-docs.txt'
'python-azure-storage: nrf-sdk requirements-docs.txt'
'python-sphinx-markdown-tables: nrf-sdk requirements-docs.txt'
'python-markdown: nrf-sdk requirements-docs.txt'
'python-mistune: nrf-sdk requirements-docs.txt'
'python-pyaml: zephyr-sdk requirements-base.txt'
'python-pykwalify: zephyr-sdk requirements-base.txt'
'python-packaging: zephyr-sdk requirements-base.txt'
'python-progress: zephyr-sdk requirements-base.txt'
'python-psutil: zephyr-sdk requirements-base.txt'
'python-anytree: zephyr-sdk requirements-base.txt'
'pylink: zephyr-sdk requirements-base.txt'
'python-colorama: zephyr-sdk requirements-build-test.txt'
'python-ply: zephyr-sdk requirements-build-test.txt'
'gcovr: zephyr-sdk requirements-build-test.txt'
'python-coverage: zephyr-sdk requirements-build-test.txt'
'python-pytest: zephyr-sdk requirements-build-test.txt'
'mypy: zephyr-sdk requirements-build-test.txt'
'python-mock: zephyr-sdk requirements-build-test.txt'
'python-breathe: zephyr-sdk requirements-doc,txt'
'python-sphinx_rtd_theme: zephyr-sdk requirements-doc,txt'
'python-pyserial: zephyr-sdk requirements-run-tests,txt'
'pyocd: zephyr-sdk requirements-run-tests.txt'
'python-tabulate: zephyr-sdk requirements-run-tests.txt'
'python-magic: zephyr-sdk requirements-compliance.txt'
'python-cryptography: mcuboot-sdk requirements.txt'
'python-clic: mcuboot-sdk requirements.txtk'
'python-cbor: mcuboot-sdk requirements.txt'
)
provides=("nrf-connect-sdk")
conflicts=("nrf-connect-sdk")
source=('nrf::git+https://github.com/nrfconnect/sdk-nrf.git')
md5sums=('SKIP')

build() {
	#Checkout correct version
	cd "${srcdir}/nrf"
	git checkout "v${pkgver}"

	#Initilize and clone other repos usinf python-west
	cd "${srcdir}"
	if [ -d ".west" ]; then
		rm -rf ".west"
	fi
	west init --local "nrf"
	west update
}

package() {
	install -Dm644 "${srcdir}/nrf/LICENSE" "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
	install -dm775 "${pkgdir}/opt/"
	cp -R "${srcdir}" "${pkgdir}/opt/nrf-connect-sdk"
	
	mkdir -p "${pkgdir}/etc/profile.d"
    echo "export ZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb" > "${pkgdir}/etc/profile.d/nrf-connect-sdk-env.sh"
    echo "export GNUARMEMB_TOOLCHAIN_PATH='/usr'" >> "${pkgdir}/etc/profile.d/nrf-connect-sdk-env.sh"
    echo "source /opt/nrf-connect-sdk/zephyr/zephyr-env.sh" >> "${pkgdir}/etc/profile.d/nrf-connect-sdk-env.sh"
    echo "west zephyr-export" >> "${pkgdir}/etc/profile.d/nrf-connect-sdk-env.sh"
}

nrf-connect-sdk.install:

post_install(){
	chmod -R 775 "/opt/nrf-connect-sdk"
    chown -R :users "/opt/nrf-connect-sdk" 

    echo ">>>"  
    echo ">>> The nRF Connect SDK have been installed to /opt/nrf-connect-sdk/"
    echo ">>> Also some scripts and environment variables  have been added to /etc/profile.d/nrf-connect-sdk-env.sh" 
    echo ">>>" 
}

post_remove(){
	cd /opt/
	if [ -d "nrf-connect-sdk" ]; then
		rm -rf "nrf-connect-sdk"
	fi

	cd /etc/profile.d
	if [ -f "nrf-connect-sdk-env.sh" ]; then
		rm -rf "nrf-connect-sdk-env.sh"
	fi
}

Here are a couple of things I know are sketchy, but they are the best solutions I got so far.

The SDK is installed to /opt/. However, since it is owned by root by default, users do not have write access.
To make it easier to use the SDK, I added it to the "users" group and set Group permissions to 775.

I make  "/etc/profile.d/nrf-connect-sdk.sh" run some shell scripts for setup in addition to setting ENV, is this fine?

Offline

#2 2022-01-26 20:47:43

loqs
Member
Registered: 2014-03-06
Posts: 14,701

Re: PKGBULID review request: nrf-connect-sdk-git

pkgname=nrf-connect-sdk-git

The -git suffix indicates the package will track updates from the git repository automatically

	git checkout "v${pkgver}"

If you want to use a fixed version please use a pinned commit in the source entry unless the tag is signed e.g.

_commit=######
source=("nrf::git+https://github.com/nrfconnect/sdk-nrf.git#commit=$_commit")
post_install(){
	chmod -R 775 "/opt/nrf-connect-sdk"
    chown -R :users "/opt/nrf-connect-sdk"

This can all be done in package() ?

post_remove(){
	cd /opt/
	if [ -d "nrf-connect-sdk" ]; then
		rm -rf "nrf-connect-sdk"
	fi

This removes user created files?

	cd /etc/profile.d
	if [ -f "nrf-connect-sdk-env.sh" ]; then
		rm -rf "nrf-connect-sdk-env.sh"
	fi

/etc/profile.d/nrf-connect-sdk-env.sh is installed by the package,  so why is this needed?

Offline

#3 2022-01-27 09:42:33

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

Re: PKGBULID review request: nrf-connect-sdk-git

Several of the packages in depends= should be in makedepends .

example : cmake , ninja

some don't need to be mentioned explicitly :

https://wiki.archlinux.org/title/Arch_User_Repository#Prerequisites wrote:

Note: Packages in the AUR assume that the base-devel group is installed, i.e. they do not list the group's members as build dependencies explicitly.

The choice whether or not to use ccache is left to the user and is usually made in makepkg.conf .

Is there a specific reason you added ccache to depends ?

Last edited by Lone_Wolf (2022-01-27 09:42:46)


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.
Did you use the guided installer ? If yes, I can't help you.

(A works at time B)  && (time C > time B ) ≠  (A works at time C)

Offline

#4 2022-01-30 17:16:10

_urd
Member
Registered: 2022-01-24
Posts: 3

Re: PKGBULID review request: nrf-connect-sdk-git

Thanks for the comments!

loqs:

loqs wrote:

The -git suffix indicates the package will track updates from the git repository automatically

Fixed this.

loqs wrote:

If you want to use a fixed version please use a pinned commit in the source entry unless the tag is signed e.g.

Added pinned tag.
Since I am using pinned tag, I think I should use shasums, right?
I tried "makepkg -g", but this returns "SKIP". I also tried to generate sha256 manually from  the tar.gz release and the github downloaded .zip, but none of these work.
Do I need to generate a shasum for the git tag? If yes, how can I do this?

loqs wrote:

This can all be done in package() ?

Yep, I now do this.

loqs wrote:

This removes user created files?

Yep. If the user builds examples inside /opt/nrf-connect-sdk, a lot of files will be generated. These are not removed automatically on uninstall.

loqs wrote:

/etc/profile.d/nrf-connect-sdk-env.sh is installed by the package,  so why is this needed?

It is not. Removed it.

Lone_Wolf:

Lone_Wolf wrote:

Several of the packages in depends= should be in makedepends .

The SDK is used for building code for microcontrollers. This building relies on typical makedepends such as cmake and ninja.

Lone_Wolf wrote:

some don't need to be mentioned explicitly :

Removed depends included in base-devel.

Lone_Wolf wrote:

Is there a specific reason you added ccache to depends ?

As the SDK has a lot going on, I do not have a complete overview to everything its different dependencies are used for.
I added the dependencies listed in the nRF Connect SDK Manual Install Guide.
However, I did some testing, and normal usage does not seem like it used cchace. So I moved it to optdepends.
Would this be a good solution?

Here are the updated PKGBUILD and nrf-connect-sdk.install:
PKGBUILD:

# Maintainer: Sigurd Hellesvik <sigurd.hellesvik@protonmail.com>

# Disclaimer: This package is not from Nordic Semiconductor
pkgname=nrf-connect-sdk
pkgver=1.8.0
pkgrel=1
pkgdesc="The nRF Connect SDK"
arch=('x86_64')
url="https://github.com/nrfconnect/sdk-nrf"
license=('custom:LicenseRef-Nordic-5-Clause')
install=nrf-connect-sdk.install
options=(!strip)
_tag="v${pkgver}"
depends=(
'cmake'
'ninja'
'gperf'
'dfu-util'
'dtc'
'python'
'python-setuptools'
'tk'
'python-wheel'
'xz'
'python-intelhex'
'python-pyelftools' 
#AUR dependencies
'gcc-arm-none-eabi-bin'
'python-west'
'nrf5x-command-line-tools'
)
makedepends=(
'git'
'wget'
)
#All Python dependencies are from the nRF Connect SDK Python requirements.
#They are described in the documentation at 
#https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.8.0/nrf/gs_installing.html#id9
#The packages from those scripts found in pacman/AUR is listed below
#If you need them, concider installing them using a Virtual Environment instead.
optdepends=(
'ccache: Listed in nRF Connect SDK install dependencies'
'gn-m85: Matter support'
'python-ecdsa: nrf-sdk requirements-build.txt'
'python-imagesize: nrf-sdk requirements-build.txt'
'python-pylint: nrf-sdk requirements-build.txt'
'python-regex: nrf-sdk requirements-build.txt' 
'python-recommonmark: nrf-sdk requirements-docs.txt '
'python-commonmark: nrf-sdk requirements-docs.txt'
'python-sphinx: nrf-sdk requirements-docs.txt'
'python-pygments: nrf-sdk requirements-docs.txt'
'python-m2r2: nrf-sdk requirements-docs.txt'
'python-sphinxcontrib-plantuml: nrf-sdk requirements-docs.txt'
'python-pygit2: nrf-sdk requirements-docs.txt'
'python-azure-storage: nrf-sdk requirements-docs.txt'
'python-sphinx-markdown-tables: nrf-sdk requirements-docs.txt'
'python-markdown: nrf-sdk requirements-docs.txt'
'python-mistune: nrf-sdk requirements-docs.txt'
'python-pyaml: zephyr-sdk requirements-base.txt'
'python-pykwalify: zephyr-sdk requirements-base.txt'
'python-packaging: zephyr-sdk requirements-base.txt'
'python-progress: zephyr-sdk requirements-base.txt'
'python-psutil: zephyr-sdk requirements-base.txt'
'python-anytree: zephyr-sdk requirements-base.txt'
'pylink: zephyr-sdk requirements-base.txt'
'python-colorama: zephyr-sdk requirements-build-test.txt'
'python-ply: zephyr-sdk requirements-build-test.txt'
'gcovr: zephyr-sdk requirements-build-test.txt'
'python-coverage: zephyr-sdk requirements-build-test.txt'
'python-pytest: zephyr-sdk requirements-build-test.txt'
'mypy: zephyr-sdk requirements-build-test.txt'
'python-mock: zephyr-sdk requirements-build-test.txt'
'python-breathe: zephyr-sdk requirements-doc,txt'
'python-sphinx_rtd_theme: zephyr-sdk requirements-doc,txt'
'python-pyserial: zephyr-sdk requirements-run-tests,txt'
'pyocd: zephyr-sdk requirements-run-tests.txt'
'python-tabulate: zephyr-sdk requirements-run-tests.txt'
'python-magic: zephyr-sdk requirements-compliance.txt'
'python-cryptography: mcuboot-sdk requirements.txt'
'python-clic: mcuboot-sdk requirements.txtk'
'python-cbor: mcuboot-sdk requirements.txt'
)
provides=("nrf-connect-sdk")
conflicts=("nrf-connect-sdk")
source=("nrf::git+https://github.com/nrfconnect/sdk-nrf.git#tag=${_tag}")
sha256sums=('SKIP')

build() {
	#Initilize and clone other repos usinf python-west
	cd "${srcdir}"
	if [ -d ".west" ]; then
		rm -rf ".west"
	fi
	west init --local "nrf"
	west update
}

package() {
	install -Dm644 "${srcdir}/nrf/LICENSE" "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
	install -dm755 "${pkgdir}/opt/"

	cp -R "${srcdir}" "${pkgdir}/opt/nrf-connect-sdk"
	chmod -R 775 "${pkgdir}/opt/nrf-connect-sdk"
	chown -R :users "${pkgdir}/opt/nrf-connect-sdk"
	
	mkdir -p "${pkgdir}/etc/profile.d"
    echo "export ZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb" > "${pkgdir}/etc/profile.d/nrf-connect-sdk-env.sh"
    echo "export GNUARMEMB_TOOLCHAIN_PATH='/usr'" >> "${pkgdir}/etc/profile.d/nrf-connect-sdk-env.sh"
    echo "source /opt/nrf-connect-sdk/zephyr/zephyr-env.sh" >> "${pkgdir}/etc/profile.d/nrf-connect-sdk-env.sh"
    echo "west zephyr-export" >> "${pkgdir}/etc/profile.d/nrf-connect-sdk-env.sh"
}

nrf-connect-sdk.install

post_install(){
    echo ">>>"  
    echo ">>> The nRF Connect SDK have been installed to /opt/nrf-connect-sdk/"
    echo ">>> Also some scripts and environment variables  have been added to /etc/profile.d/nrf-connect-sdk-env.sh" 
    echo ">>>" 
}

post_remove(){
	cd /opt/
	if [ -d "nrf-connect-sdk" ]; then
		rm -rf "nrf-connect-sdk"
	fi
}

Offline

#5 2022-01-30 17:53:04

Slithery
Forum Moderator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 5,239

Re: PKGBULID review request: nrf-connect-sdk-git

You should edit the pkgdesc to not be self-referencing. Currently it gives no useful information apart from the package name.
https://wiki.archlinux.org/title/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

Offline

#6 2022-01-30 19:16:42

_urd
Member
Registered: 2022-01-24
Posts: 3

Re: PKGBULID review request: nrf-connect-sdk-git

Slithery wrote:

You should edit the pkgdesc to not be self-referencing. Currently it gives no useful information apart from the package name.

Changed it to "Software development kit for Nordic Semiconductor products"

Offline

Board footer

Powered by FluxBB