cross-posted from: https://lemmy.ml/post/53225512

I want to create and upload an AUR package. For context, I did that years ago for specific releases, but now I want to create a new package that focuses on upstream Git without specific releases.

What do I write to the pkgver= value? Do I just take the latest version there? Because it is downloading with git clone the version number will not change and the PKGBUILD script will compare pkgver() instead. So what is the purpose of pkgver= for when downloading and building from Git directly? Looking at examples from other existing packages, they all have a number there. But its mostly outdated, so I don’t get it.

pkgname=thename-git
_pkgname="$(pkgname%-git}"
pkgver=???

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

I am reading and researching, but need some assistance for this question. Currently reading the Archwiki:

  • Lucy :3@feddit.org
    link
    fedilink
    arrow-up
    3
    ·
    15 days ago

    Put in ‘69420’, run makepkg -o. It will replace the value with the result of pkgver(). Generate SRCINFO etc., then push to AUR. When changing the PKGBUILD itself, either upstream will have changed, resulting in a higher pkgver and therefore triggering updates for AUR clients, or you need to increase the pkgrel.

    • thingsiplay@lemmy.mlOP
      link
      fedilink
      arrow-up
      2
      ·
      15 days ago

      So in short, it doesn’t matter what I have as pkgver= variable then? I was just curious to why there is an outdated version number by other package builds. I will then probably use the latest version number as of uploading the script and leave it out of sync in the PKGBUILD script if there is no need to change the script itself.

      Is that how the -git versions operate?

    • thingsiplay@lemmy.mlOP
      link
      fedilink
      arrow-up
      2
      ·
      15 days ago

      The thing is, when installing a -git package, then the function pkgver() is used to extract a version number to compare if its newer than what you have installed. And this is normally as you saw semver+githash. My question is, what do I write to pkgver= variable, that seemingly get ignored. But for whatever reason there is a version number listed on all -git packages. I’m just confused what I have to write there in an initial upload. It’s important to distinguish between the variable and the function. This is a specific AUR thing and I could not get the information from the documentation.

      • Lucy :3@feddit.org
        link
        fedilink
        arrow-up
        2
        ·
        15 days ago

        The pkgver is replaced by makepkg with the value of pkgver(). Similar to how updpkgsums updates the hashes.

        • thingsiplay@lemmy.mlOP
          link
          fedilink
          arrow-up
          1
          ·
          15 days ago

          I understand that. But I don’t understand why everyone else has an outdated version number. I felt like I’m missing something here. Maybe its just a placeholder that is completely ignored with -git packages then.

          • BB_C@programming.dev
            link
            fedilink
            arrow-up
            4
            ·
            15 days ago

            But I don’t understand why everyone else has an outdated version number.

            Who are you talking about? If it’s AUR uploaders, the version you see is the version in the last uploaded PKGBUILD. AUR itself doesn’t build anything. And PKGBUILD uploaders don’t need to keep uploading to bump the version because it auto-updates when a user builds it. They only need to upload to fix builds if they get broken, or update meta info, …etc.

            git (vcs in general) packages always update unless you pass --holdver with makepkg.

            And just to be clear, that relates to git sources not the package name. The -git naming is just a convention that has no bearing on functionality.

            Maybe its just a placeholder

            Mostly yes. You can just put “0” or “1” initially. Build once, and it will be populated anyway.

  • Azzu@leminal.space
    link
    fedilink
    arrow-up
    3
    ·
    15 days ago

    Huh, but it does say in VCS package guidelines?

    If the resulting package is different after changing e.g. the dependencies, URL or sources — update pkgver to the latest version.

    It is recommended to have following version format: RELEASE.rREVISION

    And regarding the function:

    The pkgver autobump is now achieved via a dedicated pkgver() function. This allows for better control over the pkgver, and maintainers should favor a pkgver that makes sense. To use pkgver(), you still need to declare the pkgver variable with the most recent value. makepkg will invoke function pkgver(), and update variable pkgver accordingly.

    So yeah, you just put the output of pkgver() into the pkgver variable initially, and then each repo update automatically updates the pkgver variable, as far as I understand it.

    • thingsiplay@lemmy.mlOP
      link
      fedilink
      arrow-up
      1
      ·
      15 days ago

      pkgver= is the variable to manually update and use that matches the version of the program you want to install. However, if you are downloading and building from source, then instead the variable pkgver= the function pkgver() is used to determine the version at build time with the AUR.

      I understand that part. But my question is, what do I do with pkgver= variable then? It sounds like it is completely ignored when building from -git. But looking at all the other -git based AUR package build scripts, they have a version number in the variable. I don’t know why and what I’m supposed to write there at an initial upload.

      • Azzu@leminal.space
        link
        fedilink
        arrow-up
        1
        ·
        15 days ago

        Because it shows when doing a diff. Don’t need to rebuild if pkver variable (i.e. the last version that was built) is equal to the output of the pkgver() function (i.e. the new version that would now be built).

        • thingsiplay@lemmy.mlOP
          link
          fedilink
          arrow-up
          1
          ·
          15 days ago

          With -git, its practically always different. But besides that, when pkgver() function is used, then it compares to the version in my system, not the variable to determine if its newer. But what I’m supposed to write into the variable pkgver= into?

  • bitfucker@programming.dev
    link
    fedilink
    arrow-up
    1
    ·
    15 days ago

    My two cent is put the PKGBUILD version itself. That is, if the build script is version 1, then just put that. If the PKGBUILD are updated in the future, bump it up as usual

    • thingsiplay@lemmy.mlOP
      link
      fedilink
      arrow-up
      5
      ·
      15 days ago

      No, that would be wrong. The PKGBUILD version itself is tracked by pkgrel=, which is bumped up whenever the build script is needed to change and the actual downloaded program is not. pkgver= is strictly the version for the program to install.