How to repackage a package?

I would like to make a PKGBUILD to install the files from a package to a location of my choice.

Since this needs to continually work, the file to download will change. So what I need is a way to download the package by package name, not including the version. Like how pacman works, for example… pacman -Sw linux-rc linux-rc-headers. And of course, I would like to use whichever mirrors are currently selected.

In essence, how do I get pacman-functionality to work from inside a PKGBUILD?
How can get something like wget {$MIRRORS}/linux-rc to work from inside a PKGBUILD?

I can not be the first to want to do such a thing, but I have not been able to find how to do it.

Edit: The packages I am interested in are kernel packages, I prefer to use binaries rather than rebuild from source, which is probably the correct way. How can I cheat? :slight_smile:

Sorry, given your edit I am a bit confused.
You want to package things (build them and put them in a package) but you want to cheat (not build them)?

I guess I will skip that for now and point you at the Archwiki PKGBUILD docs:
https://wiki.archlinux.org/title/PKGBUILD

… which is really just a basic install script with certain (convenient) conventions. Not that dissimilar from a makefile.

I will also suggest you can just look at the AUR and inspect or even copy PKGBUILDs from there to get the hang of it.

Once you can do that … then yes you can ‘make packages’ … or rather you have a recipe for making them. So you can - you (or anyone else) can build them using the PKGBUILD, and you (or anyone else) can install the resulting package.

How do you automate this? How do you host this? How do you manage a mirror? Remotely or locally?
Again, sorry, but these are lots of questions. I hope I have been somewhat helpful … but I suggest you take some time studying, formulating what exactly you want to do within the capabilities of the frameworks available, and then ask for clarification when necessary.

in aur exists “-bin” packages make with .deb and .rpm, you can make same with “arch” kernel.pkg.xx is only an archive

I guess if thats the thing … yes a PKGBUILD could literally be wget and mv I suppose.
They generally are not, for varying reasons, but they could be.

You could use any script or program inside your own PKGBUILD. However, it is strongly discouraged to make “random” requests and download files that are not directly listed.
All you need to download files is already implemented.

Thank for the response, I will try to more clear.

Kernels are big and take a long time to build. I do not wish to have a different kernel than what is provided by Manjaro. However, I have a need to have the kernel binary itself and firmware files, installed to a different location and possibly with a different name.

So I thought maybe I could make a pkgbuild that could download the most recent kernel package from a Manjaro mirror, extract it, and then install the files to the desired location. Like a sort of pkgbuild wrapper.

But it occurs to me that surely others have wished a package installed elsewhere, and they had found a nice way to do it. I can probably script up something that will accomplish it in a brute force kind of way.

sudo pacman -U /path/to/thing.pkg.tar.zst
will install made package (you have them in /var/cache/pacman/pkg)
You can also rename things, etc…
But …

This sounds like just using the manjaro package.
If its manjaro package ‘and some other stuff’ then the ‘other stuff’ can be in the PKGBUILD, while the manjaro kernel is a dependency.

as PKGBUILD - aur.git - AUR Package Repositories

Do you actually need that kernel installed, as in usable by the system?
Or do you only need that kernel somewhere you can work on, without needing the system to use it?
:face_with_raised_eyebrow:

I could use the existing PKGBUILD and edit it. But then it will build from source. On a raspberry pi, that takes a long time. I wish to use the binary package built by Manjaro but have some of the files (kernel and firmware) installed to a different location.

Edit the PKGBUILD, build it using your preferred resource, install.

I don’t understand your motivations and needs but maybe writing a pacman hook on a manjaro kernel package is enough?

A little more context…

On my rpi4, it can take several hours to build a kernel from source. I wish to have three different kernels installed, at the same time. But all three kernel packages install the kernel as /boot/kernel8.img, so there is a file conflict.

Therefore, I need to change the location where the kernel and firmware files are installed, like to /boot/lts/ and /boot/mainline/ and /boot/rc/

I tried using a hook… even manipulating the pacman database so pacman was aware of the new file locations. And it actually works… but there is a fatal flaw. A mulitple kernel update. If two or more kernels update at the same time, the hook is no good, it runs after the entire transaction… the subsequent kernel updates overwrites the previous kernel file.

Have you considered just modifying directory structure in actual .zst package and editing .MTREE file?

1 Like

No, I had not. Thanks for the thought! I will look at this.

Doesn’t Manjaro-ARM provide multiple kernel support, like in x64?..

Unfortunately not at this time. And it may be some SBC can not support it, but a raspberry pi can.

pkgbuild test from kernel binary (i not have arm, kernel name false)

_pkgname=('linux-lts')  # original manjaro name
pkgname=( "MY-${_pkgname}")     # custom name installed
 
pkgver="5.10.00"   
# if _pkgname installed before, we can use bash command for get version
#pkgver= $(LANG=C pacman -Qi ${_pkgname} | awk '/^Version/ {print $3}')
# if not, we can use curl -s ${_urlbase} | grep ${_pkgname}.*pkg.tar  ...
pkgrel=1
arch=($(pacman-conf|awk '/^Architecture/ {print $3}'))
_urlbase=$(pacman-conf -r core | awk '/^Server/ {print $3;exit}')
  
source=(
    "${_urlbase}/${_pkgname}-${pkgver}-${pkgrel}-${arch}.pkg.tar.zst"
    )
sha256sums=("SKIP")

prepare() {
echo "sed, rename , change in ./src ..."
}

package() {
echo " copy files ./src in ./pkg directory"
}

no notification update with custom kernel …

1 Like

Brilliance!