You are not logged in.

#1 2023-04-08 10:21:10

D3vil0p3r
Member
Registered: 2022-11-05
Posts: 177

Manipulating dynamic pkgver in PKGBUILD

I'm currently working with a PKGBUILD with the following piece of code:

pkgname=mrkaplan
pkgver=V1.1.1.r1.g6119344
_pkgver=${pkgver//.r1.g6119344}
pkgrel=1
pkgdesc='Help red teamers to stay hidden by clearing evidence of execution.'
arch=('any')
url='https://github.com/Idov31/MrKaplan'
license=('BSD2')
depends=()
makedepends=()
source=("$pkgname::git+https://github.com/Idov31/MrKaplan.git"
  "https://github.com/Idov31/$pkgname/releases/download/$_pkgver/MrKaplan_Standalone.ps1")
sha512sums=('SKIP'
            'a5582e7fbb90e3a1f2f77c7b1cff605a64e9d67b206e95ade106098c2c14932cd31a8b73f77219f704e0e408d1c3505d880bd4c6fe95381b61ae2d6399856bac')

pkgver() {
  cd $pkgname
  
  git describe --long --tags | sed 's/\([^-]*-g\)/r\1/;s/-/./g'
}

package() {
  install -dm 755 "$pkgdir/usr/share/windows/$pkgname"

  cp -a * "$pkgdir/usr/share/windows/$pkgname/"
}

In "source", since the current latest URL for getting the .ps1 file is "https://github.com/Idov31/$pkgname/rele … dalone.ps1", I was trying to find a way that automatically was able to change "_pkgver" variable that removes the latest part of "pkgver" and keep only "Vx.y.z".

Since pkgver() function automatically fills "pkgver" variable, currently I'm defining "_pkgver=${pkgver//.r1.g6119344}" in order to remove the latest part, but at each update of the tool, with this strategy, I need to change manually ".r1.g6119344" string with the new one in the "_pkgver" variable.

There exist a smarter and automated way for manipulating "_pkgver" when new tool updates/commits are released?

Thanks

Offline

#2 2023-04-08 10:39:57

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

Re: Manipulating dynamic pkgver in PKGBUILD

https://wiki.archlinux.org/title/Creating_packages#pkgver() wrote:

pkgver() runs after the sources are fetched, extracted and prepare() executed. So you can update the pkgver variable during a makepkg stage.

The pkgver() function is used for VCS packages when there is no fixed pkgver available .
Please explain in more general terms what you want to achieve.

Last edited by Lone_Wolf (2023-04-08 10:47:29)


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.


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

Offline

#3 2023-04-08 13:42:30

D3vil0p3r
Member
Registered: 2022-11-05
Posts: 177

Re: Manipulating dynamic pkgver in PKGBUILD

Lone_Wolf wrote:
https://wiki.archlinux.org/title/Creating_packages#pkgver() wrote:

pkgver() runs after the sources are fetched, extracted and prepare() executed. So you can update the pkgver variable during a makepkg stage.

The pkgver() function is used for VCS packages when there is no fixed pkgver available .
Please explain in more general terms what you want to achieve.

Hey @Lone_Wolf
I would like to achieve in general the following:

Let's start from the scenario where pkgver=V1.1.1.r1.g6119344 and the source to download the executable tool file is https://github.com/Idov31/$pkgname/rele … dalone.ps1
I would like to use a variable in "source" instead of "v1.1.1" string. At the beginning, I thought to manage it by defining a new variable called _pkgver=${pkgver//.r1.g6119344} in order to extract v1.1.1.

If the MrKaplan tool maintainer submits a new commit, and the main tag will remain 1.1.1, pkgver will be equal, for example, to "V1.1.1.s2.h15438733", and _pkgver definition won't work correctly anymore because it will return "V1.1.1.r1.g6119344".

I would like to implement something dynamic where, because of a new commit, in case the developer replaces the executable file of V1.1.1 without creating a new tag V1.1.2, I'm still able to retrieve the executable without changing manually the value of "_pkgver".

I hope it is clearer.

Offline

#4 2023-04-08 14:25:43

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

Re: Manipulating dynamic pkgver in PKGBUILD

What you're missing is that the entire concept is wrong. Just don't do that in the first place and there is no problem.

You need to either make a VCS package, which clones master and uses it, or you make a release package. You can't do both in the same package.

Last edited by Scimmia (2023-04-08 14:32:03)

Offline

Board footer

Powered by FluxBB