Skip to main content
Topic solved
This topic has been marked as solved and requires no further attention.
Topic: [SOLVED] How to PKGBUILD locally? (Read 8177 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

[SOLVED] How to PKGBUILD locally?

I have the GIMP source code, did the changes I want.
I want to build and install via pacman, because otherwise (ninja install) I can't even find how to run it lol

I cd into GIMP source code folder, then make PKGBUILD by copying PKGBUILD.proto, and renaming it to PKGBUILD, and editing it to:
Code: [Select]
# 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: Your Name <[email protected]>
pkgname=GIMPCUSTOM
pkgver=1.0
pkgrel=1
epoch=
pkgdesc="Does not have random gimpressions"
arch=(x86_64 i686)
url=~/gimp
license=('GPL')
groups=()
depends=()
makedepends=()
checkdepends=()
optdepends=()
provides=(gimp)
conflicts=()
replaces=()
backup=()
options=()
install=
changelog=
source=("$pkgname-$pkgver.tar.gz"
        "$pkgname-$pkgver.patch")
noextract=()
md5sums=('SKIP')
validpgpkeys=()

prepare() {
cd "$pkgname-$pkgver"
patch -p1 -i "$srcdir/$pkgname-$pkgver.patch"
}

build() {
#cd "~/gimp"
#make X11INC=/usr/include/X11 X11LIB=/usr/lib/X11

cd "$pkgname-$pkgver"
./configure --prefix=/usr
make
}

check() {
cd "$pkgname-$pkgver"
make -k check
}

package() {
#cd "~/gimp"
#mkdir -p ${pkgdir}/opt/${pkgname}
#cp -rf * ${pkdir}/opt/${pkgname}
#make PREFIX=/usr DESTDIR="${pkgdir}" install

cd "$pkgname-$pkgver"
make DESTDIR="$pkgdir/" install
}

I then write
Code: [Select]
makepkg -si
and get the following error, even if I run the above with comments instead of default

Code: [Select]
===>Retrieving Sources...
===> ERROR: GIMPCUSTOM-1.0.tar.gz was not found in the build directory and is not a URL.

The location of the GIMP source code is: ~/gimp
I don't find any .tar.gz file in ~/gimp
And I run
Code: [Select]
makepkg -si
on the above location

I want this build to run locally, I won't upload it anywhere (e.g. AUR), I would accept even a hacky solution if it works as intended
Any help is appreciated

Re: How to PKGBUILD locally?

Reply #1
Don't change the package name.
The source download is based on it

Re: How to PKGBUILD locally?

Reply #2
name value of PKGBUILD.proto is
Code: [Select]
pkgname=NAME
I reverted name value and version value, and typing
Code: [Select]
makepkg -si
I get
Code: [Select]
===>Retrieving Sources...
===> ERROR: NAME-VERSION.tar.gz was not found in the build directory and is not a URL.

Re: How to PKGBUILD locally?

Reply #3
Get the the gimp PKGBUILD and associated files from here
https://gitea.artixlinux.org/packagesG/gimp/src/branch/master/x86_64/extra
or here
https://github.com/archlinux/svntogit-packages/tree/packages/gimp/trunk

If it's something in the PKGBUILD you want to customise do so and build.

If you need to customise the source do
Code: [Select]
makepkg -os 
Quote
-o, --nobuild    Download and extract files only
Make your changes to the source then
Code: [Select]
makepkg -ei
Quote
  -e, --noextract  Do not extract source files (use existing $srcdir/ dir)





Re: How to PKGBUILD locally?

Reply #4
wow. It built!

I have no idea what I did, or even why it worked. Literally putting these magical commands you wrote on a black box and it started downloading, ending up installing itself

I expected the value-change I did to instantly be visible (tl;dr: no randomization on a plugin) but I may need to change a few more values until I get it right, so I will uninstall and rebuild, gotta keep trying

Thank you, I will update on final results :)

Re: How to PKGBUILD locally?

Reply #5
To confirm the value change worked, I made another build, ofc starting by deleting the previous one
Code: [Select]
sudo pacman -R gimp
then cloned the gimp build from github https://github.com/GNOME/gimp into a folder
Then, I pasted those 4 files you provided, inside that folder
Then, I did my edit (1 line of code change, by just changing an integer value)
Then, I wrote makepkg -os
I checked my edit of the source code, it is the same as I wrote originally
Then, I wrote makepkg -ei
It installed perfectly, even dmenu appeared

Booted it and tested it - I had changed some strings to confirm aside of the value change, the value wasn't in the final build
Any idea why it overrided my change? Did the downloaded files do a checksum or sth and delete my change?

Off-topic: All this is for stopping randomization on a plugin. The value-change I am planning to implement above probably doesn't change it, so I will just pause/kill the random seed lol, I will search tomorrow, hopefully I don't need to change the source and build for this

Re: How to PKGBUILD locally?

Reply #6
You don't need to download the git repo first, you can if you want, but then you don't need the makepkg -o part and you need to drop all the relevant stuff from the PKGBUILD dir in the top level dir you are using, do any config stuff on the source which would normally be done by the PKGBUILD, and also put the repo under src/pkgname. It's easier to run makepkg -o (plus any other flags you might want) and let it download the source and set things up unless you have a reason to do otherwise. That will put the source under src/gimp and that's where you make your edits before building. I'm guessing you had the source elsewhere so the PKGBUILD ignored your modified version and built what it had downloaded instead.
Also if you want to build repeatedly to test changes, use makepkg -ef and don't run -o again because it should just build the changed sections and link them to the rest which is usually much quicker providing the build system allows this.

Re: How to PKGBUILD locally?

Reply #7
I apologize for not replying yesterday, I was trying to find how to disable/fix the random seed in the code, and I found it, so only building remains

Quote
You don't need to download the git repo first, you can if you want, but then you don't need the makepkg -o part and you need to drop all the relevant stuff from the PKGBUILD dir in the top level dir you are using, do any config stuff on the source which would normally be done by the PKGBUILD, and also put the repo under src/pkgname. It's easier to run makepkg -o (plus any other flags you might want) and let it download the source and set things up unless you have a reason to do otherwise. That will put the source under src/gimp and that's where you make your edits before building.

I have ~/gimp-2.10.30 folder (contains the source code), which also contains /src (contains the source code)
I edited both of these source codes with my changes
I did not touch PKGBUILD, its the same as in the links above

I cd into ~/gimp-2.10.30 and type makepkg -ei
Output:
Code: [Select]
==>WARNING: A package has already been built, installing existing package...
==>Installing  package gimp with pacman -U

I build, run it, and it doesn't have my changes, so this is very likely true:

Quote
I'm guessing you had the source elsewhere so the PKGBUILD ignored your modified version and built what it had downloaded instead.

Could you guide me on building and where to place my edited code? Steps from scratch, like what to edit PKGBUILD (you said something about config at the start) or where to place GIMP - I will do anything at this point, as I have already invested so much time for what should be so simple - yet the result I seek is surely worth it, worth even if it takes me a month to build

Re: How to PKGBUILD locally?

Reply #8
Either you add your src modifications as a patch to the PKGBUILD, or you for example fork the gimp and set the PKGBUILD source array to the fork.

Either way, you got some reading to do how to do that, it is beyond the scope of the thread here to read up on git.

Re: How to PKGBUILD locally?

Reply #9
On my src modifications, you suggest adding it as a patch to the PKGBUILD, but how do I do that?
Code: [Select]
source=(https://download.gimp.org/pub/gimp/v${pkgver%.*}/${pkgname}-${pkgver}.tar.bz2
        0001-no-check-update.patch
        linux.gpl)
What should I change and how?
Quote
you for example fork the gimp and set the PKGBUILD source array to the fork.
fork manually I assume, so just downloading the source code and doing a change is a fork. You suggest setting the PKGBUILD source to my own, like you said above, but how I do that?

Quote
Either way, you got some reading to do how to do that, it is beyond the scope of the thread here to read up on git.
How is this related with git? I have no plans to upload the source, or download it. All I want is a local build, I didn't expect it to be this hard

Re: How to PKGBUILD locally?

Reply #10
Step by step guide:
Code: [Select]
$ mkdir mydir
$ cd mydir
$ git clone https://gitea.artixlinux.org/packagesG/gimp.git
$ cd gimp/x86_64/extra/
$ makepkg -so
$ cd src/gimp-2.10.30/
(make your changes to THIS source code, not some other code you already downloaded)
$ cd ../..
$ makepkg -ef
$ sudo pacman -U gimp-2.10.30-1-x86_64.pkg.tar.zst

To make more changes, no need to start again from the beginning:
$ cd src/gimp-2.10.30/
(make your changes)
$ cd ../..
$ makepkg -ef
$ sudo pacman -U gimp-2.10.30-1-x86_64.pkg.tar.zst

(For more details see $ man makepkg, $ man PKGBUILD, also try the Arch wiki)
This will get replaced on updates so you could add "IgnorePkg = gimp" to /etc/pacman.conf, or build a new updated one every time that happens.


Re: How to PKGBUILD locally?

Reply #12
@####### You are a legend.
I couldn't get any better answer. It's so good that I wish something like this would exist in various GIMP building documentation I had read, yet very few will find what you wrote. Step-by-step guide to the point even someone who hasn't ever touched a computer can build GIMP. A human-proof guide... Unreal.

Thank you so much.

Re: [SOLVED] How to PKGBUILD locally?

Reply #13
artoo:
From man makepkg:
Code: [Select]
       -o, --nobuild
           Download and extract files, run the prepare() function, but do not build them. Useful with the --noextract option if you wish to tweak the
           files in $srcdir/ before building.
       -e, --noextract
           Do not extract source files or run the prepare() function (if present); use whatever source already exists in the $srcdir/ directory. This is
           handy if you want to go into $srcdir/ and manually patch or tweak code, then make a package out of the result. Keep in mind that creating a
           patch may be a better solution to allow others to use your PKGBUILD.
What you say is true if you are making a PKGBUILD to build with the modifications in a fresh clean build, like if you are actually making packages for everyone to use. But to build a modified version locally the -e option stops the code in src/pkgname being changed, the PKGBUILD doesn't touch it and uses what's there. It definitely works because I use this work flow regularly myself, then when I've got the modifications correct I can do git diff (assuming it's a git repo) to generate a patch (and also earlier to check what changes I've made) or add the changes and commit and push them and so on. I could create a patch and use that in the PKGBUILD but this is easier when I'm making lots of changes and trying different things. -f allows makepkg to overwrite a previously built binary package if you are building repeatedly and -s installs dependencies, so those two options may not always be required. And it's all done using the package management system so that can run as usual.
(Caveat - this procedure won't work without changes if you need to modify something which affects the operation of the "prepare" function in the PKGBUILD, eg in Gimp autoreconf is run so if you made alterations to that you might need to run it manually before building.)
TheYellowArchitect:
Happy you got this to work, congratulations, your Gimp development work can proceed unchecked now  ;D The reason it isn't in the Gimp docs is because this approach is specific to the Pacman  and makepkg systems, the same principles can be applied to other packages.