You are not logged in.

#1 2020-12-05 15:10:57

CarbonChauvinist
Member
Registered: 2012-06-16
Posts: 412
Website

[SOLVED] makepkg $BUILDDIR - building in RAM - $startdir vs $srcdir

I'm interested in exploring building packages in memory, as per the wiki.

Arch Wiki wrote:

Persistent configuration can be done in makepkg.conf by uncommenting the BUILDDIR option, which is found at the end of the BUILD ENVIRONMENT section in the default /etc/makepkg.conf file. Setting its value to e.g. BUILDDIR=/tmp/makepkg will make use of the Arch's default /tmp temporary file system.

However, in reading the man page for makepge, there's this cryptic, at least to me, warning (my emphasis):

makepkg.conf man page wrote:

BUILDDIR="/path/to/directory"

If this value is not set, packages will, by default, be built in subdirectories of the directory that makepkg is called from. This option allows setting the build location to another directory. Incorrect use of $startdir in a PKGBUILD may cause building with this option to fail.

Which is even more confusing to me because man PKGBUILD states the following (again my emphasis):

man PKGBUILD wrote:

startdir

    This contains the absolute path to the directory where the PKGBUILD is located, which is usually the output of $(pwd) when makepkg is started. Use of this variable is deprecated and strongly discouraged.

So I guess my questions are:
1. Will permanently setting my BUILDDIR to /tmp/makepkg cause issues for me?
2. If so, it sounds like it will be limited to PKGBUILDs that are improperly created? (i.e. improperly using a startdir variable that is strongly discouraged anyway?
3. What exactly is the danger with setting this variable that would cause improperly configured PKGBUILDs to fail?

tldr;
I ask because I've recently been having a string of aur packages fail to build, randomly and I'm wondering if it's related to my recent change to makepkg.conf, or if I've just been really unlucky in picking aur packages lately.

Here's my makepkg.conf

~ $ rg -v "^#|^$" /etc/makepkg.conf
12:DLAGENTS=('file::/usr/bin/curl -gqC - -o %o %u'
13:          'ftp::/usr/bin/curl -gqfC - --ftp-pasv --retry 3 --retry-delay 3 -o %o %u'
14:          'http::/usr/bin/curl -gqb "" -fLC - --retry 3 --retry-delay 3 -o %o %u'
15:          'https::/usr/bin/curl -gqb "" -fLC - --retry 3 --retry-delay 3 -o %o %u'
16:          'rsync::/usr/bin/rsync --no-motd -z %u %o'
17:          'scp::/usr/bin/scp -C %u %o')
26:VCSCLIENTS=('bzr::bzr'
27:            'git::git'
28:            'hg::mercurial'
29:            'svn::subversion')
35:CARCH="x86_64"
36:CHOST="x86_64-pc-linux-gnu"
39:CPPFLAGS="-D_FORTIFY_SOURCE=2"
40:CFLAGS="-march=native -O2 -pipe -fstack-protector-strong -fno-plt"
41:CXXFLAGS="${CFLAGS}"
43:LDFLAGS="-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now"
45:RUSTFLAGS="-C opt-level=2 -C target-cpu=native"
48:MAKEFLAGS="-j$(nproc)"
50:DEBUG_CFLAGS="-g -fvar-tracking-assignments"
51:DEBUG_CXXFLAGS="-g -fvar-tracking-assignments"
67:BUILDENV=(!distcc color !ccache check !sign)
74:BUILDDIR=/tmp/makepkg
93:OPTIONS=(strip docs !libtool !staticlibs emptydirs zipman purge !debug)
96:INTEGRITY_CHECK=(sha256)
99:STRIP_BINARIES="--strip-all"
101:STRIP_SHARED="--strip-unneeded"
103:STRIP_STATIC="--strip-debug"
105:MAN_DIRS=({usr{,/local}{,/share},opt/*}/{man,info})
107:DOC_DIRS=(usr/{,local/}{,share/}{doc,gtk-doc} opt/*/{doc,gtk-doc})
109:PURGE_TARGETS=(usr/{,share}/info/dir .packlist *.pod)
111:DBGSRCDIR="/usr/src/debug"
120:PKGDEST=/pkg/packages
122:SRCDEST=/pkg/sources
124:SRCPKGDEST=/pkg/srcpackages
126:LOGDEST=/pkg/makepkglogs
128:PACKAGER="cc <carbonchauvinist@protonmail.ch>"
136:COMPRESSGZ=(gzip -c -f -n)
137:COMPRESSBZ2=(bzip2 -c -f)
139:COMPRESSXZ=(xz -c -z --threads=0 -)
141:COMPRESSZST=(zstd -c -T0 -20 --ultra -)
142:COMPRESSLRZ=(lrzip -q)
143:COMPRESSLZO=(lzop -q)
144:COMPRESSZ=(compress -c -f)
145:COMPRESSLZ4=(lz4 -q)
146:COMPRESSLZ=(lzip -c -f)
152:PKGEXT='.pkg.tar.zst'
153:SRCEXT='.src.tar.gz'

Relevant portion of fstab:

# /tmp explicitly set size > 50% default
tmpfs                   /tmp            tmpfs           rw,nodev,nosuid,size=12G                0  0

Recent package that won't build (yambar):

~/.git/yambar ⑂master $ makepkg -s
==> Making package: yambar 1.5.0-1 (Sat 05 Dec 2020 09:59:49 AM EST)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving sources...
  -> Found yambar-1.5.0.tar.gz
==> Validating source files with md5sums...
    yambar-1.5.0.tar.gz ... Passed
==> Extracting sources...
  -> Extracting yambar-1.5.0.tar.gz with bsdtar
==> Starting prepare()...
bsdtar: Error opening archive: Failed to open '../yambar-1.5.0.tar.gz'
==> ERROR: A failure occurred in prepare().
    Aborting...

Here's the pkgbuild. And I realize this may not be a great example of a pkgbuild (i.e. installs to /usr/local).

But even trying to simply make with no extract the package fails and seems to reference an issue with the location of my builddir:

~/.git/yambar ⑂master $ makepkg -se
==> Making package: yambar 1.5.0-1 (Sat 05 Dec 2020 10:02:57 AM EST)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> WARNING: Using existing $srcdir/ tree
==> Removing existing $pkgdir/ directory...
==> Starting build()...
/home/ghost/.git/yambar/PKGBUILD: line 41: cd: /tmp/makepkg/yambar/src/yambar/bld/release: No such file or directory
==> ERROR: A failure occurred in build().
    Aborting...

Which does exist, though with some ?wonky? permissions...:

/tmp/makepkg $ tree yambar/
yambar/
├── pkg [error opening dir]
└── src

2 directories, 0 files
/tmp/makepkg $ ls -alR yambar/
yambar/:
total 0
drwxr-xr-x  4 ghost ghost  80 Dec  5 10:02 .
drwxr-xr-x 12 ghost ghost 240 Dec  5 09:22 ..
d--x--x--x  2 ghost ghost  40 Dec  5 10:02 pkg
drwxr-xr-x  2 ghost ghost  40 Dec  5 09:59 src
ls: cannot open directory 'yambar/pkg': Permission denied

yambar/src:
total 0
drwxr-xr-x 2 ghost ghost 40 Dec  5 09:59 .
drwxr-xr-x 4 ghost ghost 80 Dec  5 10:02 ..

What am I doing wrong here?

Last edited by CarbonChauvinist (2020-12-12 14:22:58)


"the wind-blown way, wanna win? don't play"

Offline

#2 2020-12-05 16:35:39

GaKu999
Member
From: US/Eastern
Registered: 2020-06-21
Posts: 696

Re: [SOLVED] makepkg $BUILDDIR - building in RAM - $startdir vs $srcdir

Just post the makepkg.conf otherwise that looks bogus AF. (to my eyes)

~/.local/etc/pacman/makepkg.conf:

#!/hint/bash
# $XDG_CONFIG_HOME/pacman/makepkg.conf
# vim:ft=bash:fenc=utf-8:nu:ai:noet:ts=3:sw=3:tw=80:

MAKEFLAGS="-j$(nproc)"

RUSTFLAGS='-C opt-level=2'
DEBUG_RUSTFLAGS='-C debuginfo=2'

BUILDDIR=/tmp/makepkg
BUILDENV=(!distcc color !ccache check sign)

INTEGRITY_CHECK=(sha256)

Many of my makepkg flags are actually global because I want them to be handled also by my lately more used tmpfs chroot building system, quite nice way to cleanly update everything at once on my system. (tho i'm still upping my ABI break-detect game and such)

...

The file is not there as sample usage, on the other hand, I though you might like the idea/discovery of configuring makepkg for your user's desires in `${XDG_CONFIG_HOME:-$HOME/.config}/pacman/makepkg.conf`

Last edited by GaKu999 (2020-12-05 17:13:57)


My reposSome snippets

Heisenberg might have been here.

Offline

#3 2020-12-05 18:56:58

CarbonChauvinist
Member
Registered: 2012-06-16
Posts: 412
Website

Re: [SOLVED] makepkg $BUILDDIR - building in RAM - $startdir vs $srcdir

I think that's just the output formatting of rg which includes the line numbers and and a colon before the lines. Here's with grep which is more readable:

~ $ grep -Ev "^#|^$" /etc/makepkg.conf
DLAGENTS=('file::/usr/bin/curl -gqC - -o %o %u'
          'ftp::/usr/bin/curl -gqfC - --ftp-pasv --retry 3 --retry-delay 3 -o %o %u'
          'http::/usr/bin/curl -gqb "" -fLC - --retry 3 --retry-delay 3 -o %o %u'
          'https::/usr/bin/curl -gqb "" -fLC - --retry 3 --retry-delay 3 -o %o %u'
          'rsync::/usr/bin/rsync --no-motd -z %u %o'
          'scp::/usr/bin/scp -C %u %o')
VCSCLIENTS=('bzr::bzr'
            'git::git'
            'hg::mercurial'
            'svn::subversion')
CARCH="x86_64"
CHOST="x86_64-pc-linux-gnu"
CPPFLAGS="-D_FORTIFY_SOURCE=2"
CFLAGS="-march=native -O2 -pipe -fstack-protector-strong -fno-plt"
CXXFLAGS="${CFLAGS}"
LDFLAGS="-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now"
RUSTFLAGS="-C opt-level=2 -C target-cpu=native"
MAKEFLAGS="-j$(nproc)"
DEBUG_CFLAGS="-g -fvar-tracking-assignments"
DEBUG_CXXFLAGS="-g -fvar-tracking-assignments"
BUILDENV=(!distcc color !ccache check !sign)
BUILDDIR=/tmp/makepkg
OPTIONS=(strip docs !libtool !staticlibs emptydirs zipman purge !debug)
INTEGRITY_CHECK=(sha256)
STRIP_BINARIES="--strip-all"
STRIP_SHARED="--strip-unneeded"
STRIP_STATIC="--strip-debug"
MAN_DIRS=({usr{,/local}{,/share},opt/*}/{man,info})
DOC_DIRS=(usr/{,local/}{,share/}{doc,gtk-doc} opt/*/{doc,gtk-doc})
PURGE_TARGETS=(usr/{,share}/info/dir .packlist *.pod)
DBGSRCDIR="/usr/src/debug"
PKGDEST=/pkg/packages
SRCDEST=/pkg/sources
SRCPKGDEST=/pkg/srcpackages
LOGDEST=/pkg/makepkglogs
PACKAGER="cc <carbonchauvinist@protonmail.ch>"
COMPRESSGZ=(gzip -c -f -n)
COMPRESSBZ2=(bzip2 -c -f)
COMPRESSXZ=(xz -c -z --threads=0 -)
COMPRESSZST=(zstd -c -T0 -20 --ultra -)
COMPRESSLRZ=(lrzip -q)
COMPRESSLZO=(lzop -q)
COMPRESSZ=(compress -c -f)
COMPRESSLZ4=(lz4 -q)
COMPRESSLZ=(lzip -c -f)
PKGEXT='.pkg.tar.zst'
SRCEXT='.src.tar.gz'

and the actual full

~ $ cat /etc/makepkg.conf
#!/hint/bash
#
# /etc/makepkg.conf
#

#########################################################################
# SOURCE ACQUISITION
#########################################################################
#
#-- The download utilities that makepkg should use to acquire sources
#  Format: 'protocol::agent'
DLAGENTS=('file::/usr/bin/curl -gqC - -o %o %u'
          'ftp::/usr/bin/curl -gqfC - --ftp-pasv --retry 3 --retry-delay 3 -o %o %u'
          'http::/usr/bin/curl -gqb "" -fLC - --retry 3 --retry-delay 3 -o %o %u'
          'https::/usr/bin/curl -gqb "" -fLC - --retry 3 --retry-delay 3 -o %o %u'
          'rsync::/usr/bin/rsync --no-motd -z %u %o'
          'scp::/usr/bin/scp -C %u %o')

# Other common tools:
# /usr/bin/snarf
# /usr/bin/lftpget -c
# /usr/bin/wget

#-- The package required by makepkg to download VCS sources
#  Format: 'protocol::package'
VCSCLIENTS=('bzr::bzr'
            'git::git'
            'hg::mercurial'
            'svn::subversion')

#########################################################################
# ARCHITECTURE, COMPILE FLAGS
#########################################################################
#
CARCH="x86_64"
CHOST="x86_64-pc-linux-gnu"

#-- Compiler and Linker Flags
CPPFLAGS="-D_FORTIFY_SOURCE=2"
CFLAGS="-march=native -O2 -pipe -fstack-protector-strong -fno-plt"
CXXFLAGS="${CFLAGS}"
#CXXFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fno-plt"
LDFLAGS="-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now"
#RUSTFLAGS="-C opt-level=2"
RUSTFLAGS="-C opt-level=2 -C target-cpu=native"
#-- Make Flags: change this for DistCC/SMP systems
#MAKEFLAGS="-j2"
MAKEFLAGS="-j$(nproc)"
#-- Debugging flags
DEBUG_CFLAGS="-g -fvar-tracking-assignments"
DEBUG_CXXFLAGS="-g -fvar-tracking-assignments"
#DEBUG_RUSTFLAGS="-C debuginfo=2"

#########################################################################
# BUILD ENVIRONMENT
#########################################################################
#
# Defaults: BUILDENV=(!distcc !color !ccache check !sign)
#  A negated environment option will do the opposite of the comments below.
#
#-- distcc:   Use the Distributed C/C++/ObjC compiler
#-- color:    Colorize output messages
#-- ccache:   Use ccache to cache compilation
#-- check:    Run the check() function if present in the PKGBUILD
#-- sign:     Generate PGP signature file
#
BUILDENV=(!distcc color !ccache check !sign)
#
#-- If using DistCC, your MAKEFLAGS will also need modification. In addition,
#-- specify a space-delimited list of hosts running in the DistCC cluster.
#DISTCC_HOSTS=""
#
#-- Specify a directory for package building.
BUILDDIR=/tmp/makepkg

#########################################################################
# GLOBAL PACKAGE OPTIONS
#   These are default values for the options=() settings
#########################################################################
#
# Default: OPTIONS=(!strip docs libtool staticlibs emptydirs !zipman !purge !debug)
#  A negated option will do the opposite of the comments below.
#
#-- strip:      Strip symbols from binaries/libraries
#-- docs:       Save doc directories specified by DOC_DIRS
#-- libtool:    Leave libtool (.la) files in packages
#-- staticlibs: Leave static library (.a) files in packages
#-- emptydirs:  Leave empty directories in packages
#-- zipman:     Compress manual (man and info) pages in MAN_DIRS with gzip
#-- purge:      Remove files specified by PURGE_TARGETS
#-- debug:      Add debugging flags as specified in DEBUG_* variables
#
OPTIONS=(strip docs !libtool !staticlibs emptydirs zipman purge !debug)

#-- File integrity checks to use. Valid: md5, sha1, sha224, sha256, sha384, sha512, b2
INTEGRITY_CHECK=(sha256)
#INTEGRITY_CHECK=(md5)
#-- Options to be used when stripping binaries. See `man strip' for details.
STRIP_BINARIES="--strip-all"
#-- Options to be used when stripping shared libraries. See `man strip' for details.
STRIP_SHARED="--strip-unneeded"
#-- Options to be used when stripping static libraries. See `man strip' for details.
STRIP_STATIC="--strip-debug"
#-- Manual (man and info) directories to compress (if zipman is specified)
MAN_DIRS=({usr{,/local}{,/share},opt/*}/{man,info})
#-- Doc directories to remove (if !docs is specified)
DOC_DIRS=(usr/{,local/}{,share/}{doc,gtk-doc} opt/*/{doc,gtk-doc})
#-- Files to be removed from all packages (if purge is specified)
PURGE_TARGETS=(usr/{,share}/info/dir .packlist *.pod)
#-- Directory to store source code in for debug packages
DBGSRCDIR="/usr/src/debug"

#########################################################################
# PACKAGE OUTPUT
#########################################################################
#
# Default: put built package and cached source in build directory
#
#-- Destination: specify a fixed directory where all packages will be placed
PKGDEST=/pkg/packages
#-- Source cache: specify a fixed directory where source files will be cached
SRCDEST=/pkg/sources
#-- Source packages: specify a fixed directory where all src packages will be placed
SRCPKGDEST=/pkg/srcpackages
#-- Log files: specify a fixed directory where all log files will be placed
LOGDEST=/pkg/makepkglogs
#-- Packager: name/email of the person or organization building packages
PACKAGER="cc <carbonchauvinist@protonmail.ch>"
#-- Specify a key to use for package signing
#GPGKEY=""

#########################################################################
# COMPRESSION DEFAULTS
#########################################################################
#
COMPRESSGZ=(gzip -c -f -n)
COMPRESSBZ2=(bzip2 -c -f)
#COMPRESSXZ=(xz -c -z -)
COMPRESSXZ=(xz -c -z --threads=0 -)
#COMPRESSZST=(zstd -c -z -q -)
COMPRESSZST=(zstd -c -T0 -20 --ultra -)
COMPRESSLRZ=(lrzip -q)
COMPRESSLZO=(lzop -q)
COMPRESSZ=(compress -c -f)
COMPRESSLZ4=(lz4 -q)
COMPRESSLZ=(lzip -c -f)

#########################################################################
# EXTENSION DEFAULTS
#########################################################################
#
PKGEXT='.pkg.tar.zst'
SRCEXT='.src.tar.gz'

And another example of the kind of issue I'm running into. Want to build this here fcft, which even has a PKGBUILD already:

~/.git/fcft ⑂master $ cat PKGBUILD
pkgname=fcft
pkgver=2.3.1
pkgrel=1
pkgdesc="Simple font loading and glyph rasterization library"
changelog=CHANGELOG.md
arch=('x86_64' 'aarch64')
url=https://codeberg.org/dnkl/fcft
license=(mit)
makedepends=('meson' 'ninja' 'tllist>=1.0.1' 'scdoc')
depends=('freetype2' 'fontconfig' 'pixman')
checkdepends=('check' 'ttf-dejavu')
source=()

pkgver() {
  cd ../.git &> /dev/null && git describe --tags --long | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g' ||
      head -3 ../meson.build | grep version | cut -d "'" -f 2
}

build() {
  meson --prefix=/usr --buildtype=release --wrap-mode=nofallback ..
  ninja
}

check() {
  ninja test
}

package() {
  DESTDIR="${pkgdir}/" ninja install
}

Great, I git clone it to ~/.git/ and then run makepkg in that dir. I get this error...

~/.git/fcft ⑂master $ makepkg
==> Making package: fcft 2.3.1-1 (Sat 05 Dec 2020 01:49:50 PM EST)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving sources...
==> Extracting sources...
==> Starting pkgver()...
head: cannot open '../meson.build' for reading: No such file or directory
==> ERROR: pkgver is not allowed to be empty.
==> ERROR: pkgver() generated an invalid version:

Again, it's looking like it can't find a file, meson.build, almost like it's in the wrong root directory or the source directories are getting mixed up somehow but I don't understand why.

~/.git/fcft ⑂master $ tree /tmp/makepkg/fcft
/tmp/makepkg/fcft
└── src

1 directory, 0 files

~/.git/fcft ⑂master $ ls -al meson.build
-rw-r--r-- 1 ghost ghost 4.2K Sep 27 11:38 meson.build

"the wind-blown way, wanna win? don't play"

Offline

#4 2020-12-05 19:04:43

loqs
Member
Registered: 2014-03-06
Posts: 17,195

Re: [SOLVED] makepkg $BUILDDIR - building in RAM - $startdir vs $srcdir

The PKGBUILD for fcft you are using is broken

source=()

pkgver() {
  cd ../.git &> /dev/null && git describe --tags --long | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g' ||
      head -3 ../meson.build | grep version | cut -d "'" -f 2
}

No source is declared so nothing will be copied to BUILDDIR. It tries to use $srcdir/.. which is not a defined location you can rely on.  That results in the breakage you see.

Offline

#5 2020-12-06 16:11:19

CarbonChauvinist
Member
Registered: 2012-06-16
Posts: 412
Website

Re: [SOLVED] makepkg $BUILDDIR - building in RAM - $startdir vs $srcdir

@Thanks loqs, so I guess that confirms I've just been having a string of bad luck with PKGBUILDs lately then.

Can you clarify what you mean by the following:

loqs wrote:

It tries to use $srcdir/.. which is not a defined location you can rely on.  That results in the breakage

I don't see them referencing any $srcdir variable, are you saying they are assuming that this will be run in a subdirectory of the source directory? And therefore they only need to go up a level (i.e. ../random_dir) to access their desired files?

I assume that this pkgbuild will build for at least the creator right? Why does it work for them then? How should this be fixed? (Nvm, I'll try and re-write this to see if I can understand what's going on, as you can tell I'm just now trying to wrap my head around understanding how to read/write pkgbuilds).

Anyway, cheers.


"the wind-blown way, wanna win? don't play"

Offline

#6 2020-12-06 16:18:16

Scimmia
Fellow
Registered: 2012-09-01
Posts: 11,463

Re: [SOLVED] makepkg $BUILDDIR - building in RAM - $startdir vs $srcdir

The function starts in $srcdir, they're then using ../ from there. It assumes that $srcdir is a subdir of $startdir, which is valid in the default configuration, but can't be relied upon.

Offline

#7 2020-12-06 23:45:28

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: [SOLVED] makepkg $BUILDDIR - building in RAM - $startdir vs $srcdir

CarbonChauvinist wrote:

However, in reading the man page for makepge, there's this cryptic, at least to me, warning (my emphasis):

makepkg.conf man page wrote:

BUILDDIR="/path/to/directory"

If this value is not set, packages will, by default, be built in subdirectories of the directory that makepkg is called from. This option allows setting the build location to another directory. Incorrect use of $startdir in a PKGBUILD may cause building with this option to fail.

Which is even more confusing to me because man PKGBUILD states the following (again my emphasis):

man PKGBUILD wrote:

startdir

    This contains the absolute path to the directory where the PKGBUILD is located, which is usually the output of $(pwd) when makepkg is started. Use of this variable is deprecated and strongly discouraged.

Clearly, using $startdir "at all" constitutes using it "incorrectly", and risks breaking everything. tongue

It doesn't just break on $BUILDDIR, though... more often, it breaks on $SRCDEST.

CarbonChauvinist wrote:

So I guess my questions are:
1. Will permanently setting my BUILDDIR to /tmp/makepkg cause issues for me?

Yes.

CarbonChauvinist wrote:

2. If so, it sounds like it will be limited to PKGBUILDs that are improperly created? (i.e. improperly using a startdir variable that is strongly discouraged anyway?

Yes. Every issue will be the issue of "this PKGBUILD sucks and prevents me from using it".

CarbonChauvinist wrote:

3. What exactly is the danger with setting this variable that would cause improperly configured PKGBUILDs to fail?

tldr;
I ask because I've recently been having a string of aur packages fail to build, randomly and I'm wondering if it's related to my recent change to makepkg.conf, or if I've just been really unlucky in picking aur packages lately.

As previously mentioned, all functions begin in $srcdir. With no makepkg.conf variables set...

  • trying to access files in ./../ is identical to trying to access them in $startdir, but it is terribly wrong to do so, ever, no matter what, because it will break on $BUILDDIR

  • Trying to access files in $startdir is the "correct" way to access files distributed in the same git clone or tarball unpacking as the PKGBUILD itself... if it is not in source=(). If it is in source=() then it will be symlinked into $srcdir. And there is no reason for the files to not be in source=() if they're used in the PKGBUILD. So in the end, it's actually terribly wrong to access files in $startdir, and for sources that get downloaded, it will break on $SRCDEST.

There is a thing with people and their suckmoreless software, to support copying over config.h files the user supplies in $startdir, but not error if there is none. For this reason, they don't want to use source=().

This technically works as long as they actually use $startdir and not ../ but nevertheless I judge them for it. Admittedly, I mainly judge them because they have the bad taste to use suckmoreless software.


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#8 2020-12-12 14:19:25

CarbonChauvinist
Member
Registered: 2012-06-16
Posts: 412
Website

Re: [SOLVED] makepkg $BUILDDIR - building in RAM - $startdir vs $srcdir

I've had some time to now actually read documentation (mainly man PKGBUILD, as well as wiki on creating packages) and believe I can now wrap my head around what's happening.

Thanks to all who replied, with patience, and really helped me here, @scimmia (boiled down my misunderstanding to a single sentence, extremely clarifying), @eschwartz (who went point by point and was really helpful for me), @gaku999(showed me ways to customize makepkg per user) and @loqs (broke it down in plain english for me which I really appreciated).

Essentially I did not understand this important piece of how packages are built:

man pkgbuild wrote:

srcdir
    This contains the directory where makepkg extracts, or copies, all source files.
    All of the packaging functions defined above are run starting inside $srcdir
pkgdir
    This contains the directory where makepkg bundles the installed package. This directory will become the root directory of your built package. This variable should only be used in the package() function.
startdir
    This contains the absolute path to the directory where the PKGBUILD is located, which is usually the output of $(pwd) when makepkg is started. Use of this variable is deprecated and strongly discouraged.

With a better understanding on this process, here's my "updated/fixed" fcft pkgbuild which now builds for me as expected:

~/.git/fcft ⑂master* $ git --no-pager diff PKGBUILD
diff --git a/PKGBUILD b/PKGBUILD
index cb7caf0..6a3ee43 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -9,15 +9,11 @@ license=(mit)
 makedepends=('meson' 'ninja' 'tllist>=1.0.1' 'scdoc')
 depends=('freetype2' 'fontconfig' 'pixman')
 checkdepends=('check' 'ttf-dejavu')
-source=()
-
-pkgver() {
-  cd ../.git &> /dev/null && git describe --tags --long | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g' ||
-      head -3 ../meson.build | grep version | cut -d "'" -f 2
-}
+source=("https://codeberg.org/dnkl/$pkgname/archive/$pkgver.tar.gz")
+md5sums=('16f716bdc3319af2f3e79ffa4523deb1')

 build() {
-  meson --prefix=/usr --buildtype=release --wrap-mode=nofallback ..
+  meson --prefix=/usr --buildtype=release --wrap-mode=nofallback "$srcdir/$pkgname"
   ninja
 }

I'll now be better able, hopefully, to address any PKGBUILDs that are written "incorrectly" moving forward, marking as solved.


"the wind-blown way, wanna win? don't play"

Offline

Board footer

Powered by FluxBB