You are not logged in.

#1 2024-04-29 17:48:58

ryanbarillos
Member
Registered: 2023-11-29
Posts: 27

AUR Help: How to Make a "FILE.ANYTYPE" Inside a PKGBUILD?

I'm currently working on packaging a new package that takes a barebones kernel module and converting it into a DKMS module. But I need to make 2 files to make it happen:

1. dkms.conf
2. a file to put in /etc/modules-load.d

I'm finding a way to embed the creation of these files inside the PKGBUILD, and I'm not sure how. Based on my findings on nvidia-utils's PKGBUILD and in the Arch Wiki I'll have to use the "sed" command to modify pseudo-text files. But the creation of these two files---is there a rule?

This what I currently have in mind (click here to see screenshot), and I'd like to get your thoughts on the correctness of this method (or perhaps another way).

Thanks in advance.

Last edited by ryanbarillos (2024-04-29 17:49:23)

Offline

#2 2024-04-29 17:57:11

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

Re: AUR Help: How to Make a "FILE.ANYTYPE" Inside a PKGBUILD?

You cannot do anything in $pkgdir in the prepare function, abandon that idea completely.

You can use echo and redirect the output into a file if it's simple enough. You can create files and commit them alongside the PKGBUILD, adding them to the source array. You can use sed if that file, or any text file, needs modified. The dkms.conf probably needs this, while the modules-load.d file can probably just be echoed, but it should go in /usr/lib/, not /etc.

Edit: And if we're talking about https://aur.archlinux.org/packages/acer … y-dkms-git at all, please read https://wiki.archlinux.org/title/VCS_package_guidelines

Last edited by Scimmia (2024-04-29 18:01:44)

Online

#3 2024-04-29 18:57:42

ryanbarillos
Member
Registered: 2023-11-29
Posts: 27

Re: AUR Help: How to Make a "FILE.ANYTYPE" Inside a PKGBUILD?

Scimmia wrote:

You cannot do anything in $pkgdir in the prepare function, abandon that idea completely.

Got it. Do that in install() {}

Scimmia wrote:

You can use echo and redirect the output into a file if it's simple enough.

Genius! I'll take note of that.

Scimmia wrote:

You can create files and commit them alongside the PKGBUILD, adding them to the source array.

So, something like this?

Scimmia wrote:

You can use sed if that file, or any text file, needs modified. The dkms.conf probably needs this, while the modules-load.d file can probably just be echoed, but it should go in /usr/lib/, not /etc.

I'll take note of that.

Currently, I'm working on the non-git version of that kernel module. (The -git version relies on a fork; this one I'm working at uses the original source). So it will be "acer-wmi-battery-dkms" that'll be in conflict with its git counterpart.

But thanks for that. I'll keep that in mind in the future update/revision of that package.

Last edited by ryanbarillos (2024-04-29 19:16:24)

Offline

#4 2024-04-29 22:47:20

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

Re: AUR Help: How to Make a "FILE.ANYTYPE" Inside a PKGBUILD?

There is no install function, you would do it in the package function.

Something like that, but please stop posting pictures of text, just post the text, much simpler for everyone involved.

On the -git package, you definitely want to take a look at the linked page, as your current PKGBUILD isn't valid.

Online

#5 2024-04-29 23:43:51

ryanbarillos
Member
Registered: 2023-11-29
Posts: 27

Re: AUR Help: How to Make a "FILE.ANYTYPE" Inside a PKGBUILD?

Scimmia wrote:

There is no install function, you would do it in the package function.

Something like that, but please stop posting pictures of text, just post the text, much simpler for everyone involved.

On the -git package, you definitely want to take a look at the linked page, as your current PKGBUILD isn't valid.

I know we may going a bit off-topic, but here's my revision of that package. Not sure what else to revise besides what I've noticed.

REVISED PKGBUILD of acer-wmi-battery-dkms-git FOR REVIEW

# Custom variables
_name="acer-wmi-battery"
_user="Diman119"
_ver=1.0
_revcnt=13
_commit="da45c71"

# Main info
pkgname="$_name-dkms-git"
pkgver=r13.da45c71
pkgrel=4
pkgdesc="For Acer laptops -- kernel module to set Battery Charge Limit to 80%."
arch=('any')
url="https://github.com/${_user}/${_name}"
license=('GPL-2.0')
groups=('acer-wmi')
depends=("dkms")
makedepends=("git")
provides=("${_name}-dkms")
conflicts=("${_name}-dkms")
install="${_name}.install"
# source=("git+https://github.com/${_user}/${_name}.git")
source=("${_name}::git+https://github.com/${_user}/${_name}.git")
sha256sums=("SKIP")

pkgver() {
  cd "${_name}"
  printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short=7 HEAD)"
}

package() {
    # Create directories
    install -dm755 ${pkgdir}/usr/src/"${_name}-${_ver}"
    install -dm755 ${pkgdir}/etc/modules-load.d

    # Copy everything to the new directory
    cp -r ${srcdir}/${_name}/* ${pkgdir}/usr/src/"${_name}-${_ver}"

    # Copy module config to "modules-load.d"
    cp "${srcdir}/${_name}/acer-wmi-battery.conf" "${pkgdir}/etc/modules-load.d"
}

Last edited by ryanbarillos (2024-04-29 23:44:05)

Offline

#6 2024-04-30 00:00:23

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

Re: AUR Help: How to Make a "FILE.ANYTYPE" Inside a PKGBUILD?

_revcnt=13
_commit="da45c71"

Unused

source=("${_name}::git+https://github.com/${_user}/${_name}.git")

Unpinned git checkout making it  a -git package.

    install -dm755 ${pkgdir}/usr/src/"${_name}-${_ver}"
    install -dm755 ${pkgdir}/etc/modules-load.d

    # Copy everything to the new directory
    cp -r ${srcdir}/${_name}/* ${pkgdir}/usr/src/"${_name}-${_ver}"

Unquoted $srcdir and $pkgdir.

    install -dm755 ${pkgdir}/etc/modules-load.d

/etc/modules-load.d is reserved for the local administrator packages should use /usr/lib/modules-load.d

Last edited by loqs (2024-04-30 00:00:49)

Offline

#7 2024-04-30 00:17:31

ryanbarillos
Member
Registered: 2023-11-29
Posts: 27

Re: AUR Help: How to Make a "FILE.ANYTYPE" Inside a PKGBUILD?

loqs wrote:
source=("${_name}::git+https://github.com/${_user}/${_name}.git")

Unpinned git checkout making it  a -git package.

Got the rest ironed out, but this one I'm confused on what to do on that part.

NOTE: I appreciate all your patience here as I'm learning to make PKGBUILD files.

Offline

#8 2024-04-30 00:47:26

ryanbarillos
Member
Registered: 2023-11-29
Posts: 27

Re: AUR Help: How to Make a "FILE.ANYTYPE" Inside a PKGBUILD?

Scimmia wrote:

You can create files and commit them alongside the PKGBUILD, adding them to the source array. You can use sed if that file, or any text file, needs modified.

This one looks more appealing & manageable, however some steps to achieve this is not readily found in the Arch wiki or elsewhere. So I'm not sure where else to go.


PKGBUILD for "acer-wmi-battery-dkms" (NOT -git version) FOR REVIEW

# Custom variables
_name="acer-wmi-battery"
_user="frederik-h"
_filetype="tar.gz" # Source code is also available in .zip file, so specify it

# Main info
pkgname="$_name-dkms"
pkgver=0.1.0
pkgrel=1
pkgdesc="For Acer laptops -- kernel module to set Battery Charge Limit to 80%."
arch=('any')
url="https://github.com/${_user}/${_name}"
license=('GPL-2.0')
groups=('acer')
depends=("dkms")
provides=("${_name}-dkms")
conflicts=("${_name}-dkms-git")
install="${_name}.install"

# This assumes that dkms.conf and acer-wmi-battery.conf are part of this AUR package
# Not coming from GitHub
source=(
    "${_name}-${pkgver}.${_filetype}::${url}/archive/refs/tags/v${pkgver}.${_filetype}"
    "dkms.conf"
    "acer-wmi-battery.conf"
    )
# I'm not sure if I need to include shasums for 2 of the .conf files too
sha256sums=("eadee2d9daf257b34098d8b1f21b9be08270b89b6249725f701f1f790b6c76ba")

package() {   
    # Create directories
    install -dm755 ${pkgdir}/usr/src/${_name}-${pkgver}/dkms.conf
    install -dm755 ${pkgdir}/usr/lib/modules-load.d    


    # Copy DKMS config to correct directory
    # How?
    # Then edit file with "sed" command
    
    # Copy "acer-wmi-battery.conf" to "modules-load.d" directory
    # How?
    # Then edit file with "sed" command

    # Copy everything to the new directory
    cp -r ${srcdir}/${_name}-${pkgver}/* ${pkgdir}/usr/src/"${_name}-${pkgver}"
}

Offline

#9 2024-04-30 00:54:55

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

Re: AUR Help: How to Make a "FILE.ANYTYPE" Inside a PKGBUILD?

ryanbarillos wrote:
loqs wrote:
source=("${_name}::git+https://github.com/${_user}/${_name}.git")

Unpinned git checkout making it  a -git package.

Got the rest ironed out, but this one I'm confused on what to do on that part.

NOTE: I appreciate all your patience here as I'm learning to make PKGBUILD files.

Don't worry about that one, loqs was confused since we're talking about 2 different PKGBUILDs here.

Online

#10 2024-04-30 02:00:44

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

Re: AUR Help: How to Make a "FILE.ANYTYPE" Inside a PKGBUILD?

dkms.conf

PACKAGE_NAME=acer_wmi_battery
PACKAGE_VERSION="@PKGVER@"
BUILT_MODULE_NAME[0]=acer-wmi-battery
BUILT_MODULE_LOCATION[0]="./"
DEST_MODULE_LOCATION[0]="/kernel/updates/dkms"
AUTOINSTALL="YES"

acer-wmi-battery.conf

# Load Acer battery health driver
acer_wmi_battery

PKGBUILD

# Custom variables
_name="acer-wmi-battery"
_user="frederik-h"
_filetype="tar.gz" # Source code is also available in .zip file, so specify it

# Main info
pkgname="$_name-dkms"
pkgver=0.1.0
pkgrel=1
pkgdesc="For Acer laptops -- kernel module to set Battery Charge Limit to 80%."
arch=('any')
url="https://github.com/${_user}/${_name}"
license=('GPL-2.0-or-later')
groups=('acer')
depends=("dkms")
conflicts=("${_name}-dkms-git")

source=(
    "${url}/archive/v${pkgver}/${_name}-${pkgver}.${_filetype}"
    "dkms.conf"
    "acer-wmi-battery.conf"
    )
sha256sums=('eadee2d9daf257b34098d8b1f21b9be08270b89b6249725f701f1f790b6c76ba'
            'f000c0a4a27a9d86b890f8ecc52fef5e0f9834587f4abd38db1689b2ea32da1e'
            '4f3bd1faa284dbb2139fc352289b3ccbc2155a78d37d395c3642edc2a80e7057')

package() {
  # Copy dkms.conf
  install -Dm644 dkms.conf -t "${pkgdir}"/usr/src/${_name}-${pkgver}/

  # Set version
  sed -e "s/@PKGVER@/${pkgver}/" \
      -i "${pkgdir}"/usr/src/${_name}-${pkgver}/dkms.conf

  # Copy sources (including Makefile)
  cp -r ${_name}-${pkgver}/* "${pkgdir}"/usr/src/"${_name}-${pkgver}"

  # Copy "acer-wmi-battery.conf" to "modules-load.d" directory
  install -Dm644 acer-wmi-battery.conf -t "${pkgdir}"/usr/lib/modules-load.d/
}

Last edited by loqs (2024-04-30 02:52:02)

Offline

#11 2024-05-01 17:18:49

ryanbarillos
Member
Registered: 2023-11-29
Posts: 27

Re: AUR Help: How to Make a "FILE.ANYTYPE" Inside a PKGBUILD?

loqs wrote:
# Main info
source=(
    "${url}/archive/v${pkgver}/${_name}-${pkgver}.${_filetype}"
    "dkms.conf"
    "acer-wmi-battery.conf"
    )
sha256sums=('eadee2d9daf257b34098d8b1f21b9be08270b89b6249725f701f1f790b6c76ba'
            'f000c0a4a27a9d86b890f8ecc52fef5e0f9834587f4abd38db1689b2ea32da1e'
            '4f3bd1faa284dbb2139fc352289b3ccbc2155a78d37d395c3642edc2a80e7057')

package() {
  # Copy dkms.conf
  install -Dm644 dkms.conf -t "${pkgdir}"/usr/src/${_name}-${pkgver}/

  # Set version
  sed -e "s/@PKGVER@/${pkgver}/" \
      -i "${pkgdir}"/usr/src/${_name}-${pkgver}/dkms.conf

  # Copy sources (including Makefile)
  cp -r ${_name}-${pkgver}/* "${pkgdir}"/usr/src/"${_name}-${pkgver}"

  # Copy "acer-wmi-battery.conf" to "modules-load.d" directory
  install -Dm644 acer-wmi-battery.conf -t "${pkgdir}"/usr/lib/modules-load.d/
}

So, this is how it's done to install files included from the cloning of these AUR repos. No fancy aliases like $srcdir or $pkgdir---just current root directory.
And it also confirms that I need to also provide SHASUMS for each file included & needed for the building of package. (whether pulling from external source or locally included).

Many thanks for that!

Last edited by ryanbarillos (2024-05-01 17:20:29)

Offline

#12 2024-05-02 16:25:00

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

Re: AUR Help: How to Make a "FILE.ANYTYPE" Inside a PKGBUILD?

ryanbarillos wrote:

So, this is how it's done to install files included from the cloning of these AUR repos. No fancy aliases like $srcdir or $pkgdir---just current root directory.

The initial working directory for all the standard functions in a PKGBUILD is $srcdir.  All source files will be extracted into $srcdir by makepkg.  All the targets in package() did use $pkgdir.

Offline

Board footer

Powered by FluxBB