Help in placing an AUR package

I am trying to build a package for the AUR. The package by default installs to /usr/local but the package guidelines say specifically not to install packages there. The problem is that when I put it on other places such as /opt, /usr/bin, /etc, etc. It does not run in the terminal without going to the directory with the program in it. Where do I need to put my package’s compiled file so that it can be ran by anyone, anywhere, anytime?

What package?

this is the original I’ve forked. It’s very easy to modify directory placement how the make install is built

It’s right in the README:

compile and install

$ make install # by default, install path is set to /usr/local/bin/. Use PREFIX=PATH to override.

In your package() function, do:

make PREFIX="$pkgdir/usr" install
1 Like

The problem is even if I do that, or no matter where I put the package, typing “dogefetch” when I’m not in the directory where the program is in throws “command not found” unless I install it to /usr/local. I need to put it somewhere else and have it still work when I’m not in the directory running the program directly with ./dogefetch

What does your PKGBUILD look like?

like this currently although I’m not building with the PKGBUILD right now, I’m doing it by hand. That’s why it just has “sudo make install” Obviously it needs some cleaning up, this is my first time dipping my toes into building an AUR package or really any package for that matter

# This is an example PKGBUILD file. Use this as a start to creating your own,
# and remove these comments. For more information, see 'man PKGBUILD'.
# NOTE: Please fill out the license field for your package! If it is unknown,
# then please put 'unknown'.

# Maintainer: Noah Puhl <noahrpuhl@protonmail.com>
pkgname=dogefetch
pkgver=1.2.1
pkgrel=1
pkgdesc="A CLI hardware information tool"
arch=('any')
url="https://github.com/ali019283/dogefetch"
license=('GPL3' 'MIT')
makedepends=('git' 'tar')
checkdepends=('nerd-fonts-noto-sans-mono')
source=('https://github.com/chowder3907/dogefetch-arch/archive/refs/tags/1.2.1-arch.tar.gz')
md5sums=('22044ba14520e6f22fd1d0b6e7abb2bf')
prepare() {
  tar -xvzf 1.2.1-arch.tar.gz
}

build() {
	cd dogefetch-arch-1.2.1-arch
	make




}

package() {
	cd dogefetch-arch-1.2.1-arch
	sudo make install
}

As an aside, don’t invoke “sudo” in any PKGBUILD.

should I run “su” first instead of using sudo? I didn’t think using sudo would be the best but I haven’t gotten to resolving that yet

makepkg uses a chroot/jail (think “pseudo filesystem”). Don’t invoke any sudo or su commands. The same principle applies in included .install files.

Where is that coming from? I can’t find that tag.

  • The license is GPL3, there is no MIT license
  • makedepends() and checkdepends() are not needed at all.
  • makepkg will automatically extract the tarball, no need for the prepare() function.
PKGBUILD
# Maintainer: Noah Puhl <noahrpuhl@protonmail.com>
pkgname=dogefetch
pkgver=1.2.1
pkgrel=1
pkgdesc="A CLI hardware information tool"
arch=('x86_64')
url="https://github.com/ali019283/dogefetch"
license=('GPL3')
depends=('glibc')
source=("https://github.com/ali019283/dogefetch/archive/refs/tags/$pkgname-$pkgver.tar.gz")
sha256sums=('08cb3730e1e51f306adfc92c1088c96a06c5b48927276cbfb5875be92b65d156')

build() {
	cd "$pkgname-$pkgname-$pkgver"
	make
}

package() {
	cd "$pkgname-$pkgname-$pkgver"
	make PREFIX="$pkgdir/usr" install
}

This builds fine and installs in the proper directories, but the binary segfaults:

❯ dogefetch
zsh: segmentation fault (core dumped)  dogefetch

The tag is from my fork of it, it’s just part of my testing branch and is going to be taken out. It’s more for me to keep track of things.
The MIT license came from when I was packaging some fonts as a dependency but wisened up and removed them as they weren’t needed, and yeah I’ll go back and remove all the empty lines. Good to know about the tarball. The program will segfault if it doesn’t have the “doggo” file with it in the right places.

yeah I know about the fakeroot environment, I’ll see about removing the sudo. Ty for a little bit of a better explaination, I’ll make sure not to involve any sudo or su-ing

That tag only exists in your fork, not the original repo.

It’s in /usr/share/dogefetch/. Maybe the Makefile needs to be fixed if the files are not in the right places.

you’re probably right, thanks. I’ll work on it. So just to make things clear, in changing the make command to what you wrote above, it should be fine even if I put the prgram in /opt or somewhere else?

Aha! Figured it out. The path is hardcoded in doge.c. Add a prepare() function to fix it:

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

	# Fix path
	sed -i 's|usr/local|usr|g' doge.c
}
❯ dogefetch
  __      _     serw12
o'')}____//     AMD Ryzen 7 3700X 8-Core Processor
 `_/      )     Manjaro Linux 
 (_(_/-(_/   ﳔ   8975 MB/32767 MB
PKGBUILD (updated)
# Maintainer: Noah Puhl <noahrpuhl@protonmail.com>
pkgname=dogefetch
pkgver=1.2.1
pkgrel=1
pkgdesc="A CLI hardware information tool"
arch=('x86_64')
url="https://github.com/ali019283/dogefetch"
license=('GPL3')
depends=('glibc')
source=("https://github.com/ali019283/dogefetch/archive/refs/tags/$pkgname-$pkgver.tar.gz")
sha256sums=('08cb3730e1e51f306adfc92c1088c96a06c5b48927276cbfb5875be92b65d156')

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

	# Fix path
	sed -i 's|usr/local|usr|g' doge.c
}

build() {
	cd "$pkgname-$pkgname-$pkgver"
	make
}

package() {
	cd "$pkgname-$pkgname-$pkgver"
	make PREFIX="$pkgdir/usr" install
}
1 Like

I was manually editing the doge.c file to look for it in /opt or wherever. The problem hasn’t been in the program working, it’s in making it to where I can run the command like normal without the program being in /usr/local. Is this something that will be handled by the makepkg and pacman?

I thought we already went over this. :wink:

I guess you mean changing it in the source for your fork? Just change the default prefix in the Makefile along with in doge.c

If you’re going to add it to the AUR, make a patch from your fork using the original repo. It’s frowned upon to use forks as a source.

well I already ran it with

and with variations of it like
make PREFIX="/opt" install

the files go in the right place and it works, but not from anywhere. Sorry if I’m being stupid, I’m new to this

Did you use my PKGBUILD with the addition of the prepare() function? It works for me. I added an updated one to my post above.

❯ pacman -Ql dogefetch
dogefetch /usr/
dogefetch /usr/bin/
dogefetch /usr/bin/dogefetch
dogefetch /usr/share/
dogefetch /usr/share/dogefetch/
dogefetch /usr/share/dogefetch/doggo

That’s not a valid prefix.