You are not logged in.

#1 2021-09-22 03:30:34

highfrequencyhertz
Member
Registered: 2021-05-30
Posts: 34

[SOLVED] Error when automatically applying patch with makepkg.

I have been trying to apply this patch to the PKGBUILD to skip building the documentation during Linux Kernel compilation:

62d62
<   make htmldocs
190c190
< pkgname=("$pkgbase" "$pkgbase-headers" "$pkgbase-docs")
---
> pkgname=("$pkgbase" "$pkgbase-headers")

So I copied the PKGBUILD in my build/linux directory, made the modifications to it, and renamed it new. Then I generated the patch using this command:

diff --unified --recursive --text PKGBUILD new > package.patch

So now, in my build/linux directory, I had a PKGBUILD, the modified PKGBUILD, and a file named package.patch I then deleted new and added package.patch to the sources array. Then I added the following to the prepare array:

cd "$srcdir"
  patch --strip=1 --input=package.patch

Unfortunately this ends up with this error:

==> Starting prepare()...
can't find file to patch at input line 3
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|--- PKGBUILD   2021-09-19 07:17:21.000000000 -0700
|+++ new        2021-09-21 14:34:00.566741835 -0700
--------------------------
File to patch:

Can anyone point out what I am doing wrong please?
Thanks.

Last edited by highfrequencyhertz (2021-09-22 06:05:43)

Offline

#2 2021-09-22 03:53:43

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 29,686
Website

Re: [SOLVED] Error when automatically applying patch with makepkg.

You need to specify the correct path for the patch: eg., ../$patch


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2021-09-22 04:00:59

highfrequencyhertz
Member
Registered: 2021-05-30
Posts: 34

Re: [SOLVED] Error when automatically applying patch with makepkg.

It already changed directories into the where the patch is located, so, no need to specify a path.

Offline

#4 2021-09-22 04:04:26

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 29,686
Website

Re: [SOLVED] Error when automatically applying patch with makepkg.

The patch isn't in the source directory: that's the error message you are getting...

Read the linux PKGBUILD if you don't understand how it works.

Last edited by jasonwryan (2021-09-22 04:05:01)


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#5 2021-09-22 04:05:34

highfrequencyhertz
Member
Registered: 2021-05-30
Posts: 34

Re: [SOLVED] Error when automatically applying patch with makepkg.

I added the patch the the source array, so it was copied to the src directory.

Offline

#6 2021-09-22 04:07:19

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 29,686
Website

Re: [SOLVED] Error when automatically applying patch with makepkg.

Nope.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#7 2021-09-22 04:12:51

highfrequencyhertz
Member
Registered: 2021-05-30
Posts: 34

Re: [SOLVED] Error when automatically applying patch with makepkg.

It definitely copied:

src]$ ls
archlinux-linux  config  PKGBUILD.patch

I don't know if it matters that the PKGBUILD.patch is a link.

I also added this to my prepare array:

prepare() {
  cd "$srcdir"
  patch --strip=1 --input="${srcdir}/PKGBUILD.patch"

I get the same error.

Last edited by highfrequencyhertz (2021-09-22 04:14:28)

Offline

#8 2021-09-22 04:17:54

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 29,686
Website

Re: [SOLVED] Error when automatically applying patch with makepkg.

Ah, so you want `cd $srcdir/archlinux-linux` and then `patch -i ../patch`.

Last edited by jasonwryan (2021-09-22 04:18:17)


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#9 2021-09-22 04:24:41

highfrequencyhertz
Member
Registered: 2021-05-30
Posts: 34

Re: [SOLVED] Error when automatically applying patch with makepkg.

Why patch -i? I am trying to follow the documentation as closely as possible.

Offline

#10 2021-09-22 04:29:55

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 29,686
Website

Re: [SOLVED] Error when automatically applying patch with makepkg.

It's terser than --input= so I had to type less tongue


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#11 2021-09-22 04:32:40

highfrequencyhertz
Member
Registered: 2021-05-30
Posts: 34

Re: [SOLVED] Error when automatically applying patch with makepkg.

Also, what happened to --strip=1?

Offline

#12 2021-09-22 04:36:53

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 29,686
Website

Re: [SOLVED] Error when automatically applying patch with makepkg.

Sure, -p, if the patch requires it. You get the idea, though.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#13 2021-09-22 04:40:59

highfrequencyhertz
Member
Registered: 2021-05-30
Posts: 34

Re: [SOLVED] Error when automatically applying patch with makepkg.

I am actually quite new to diff files. What does -p do. The doc page confused me a bit.

Offline

#14 2021-09-22 04:44:01

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 29,686
Website

Re: [SOLVED] Error when automatically applying patch with makepkg.

It's the same as --strip


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#15 2021-09-22 04:47:11

highfrequencyhertz
Member
Registered: 2021-05-30
Posts: 34

Re: [SOLVED] Error when automatically applying patch with makepkg.

Which means...

Offline

#16 2021-09-22 04:51:24

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 29,686
Website

Re: [SOLVED] Error when automatically applying patch with makepkg.

man patch

Please remember to mark your thread as [Solved] by editing your first post and prepending it to the title.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#17 2021-09-22 04:55:47

highfrequencyhertz
Member
Registered: 2021-05-30
Posts: 34

Re: [SOLVED] Error when automatically applying patch with makepkg.

Unfortunately it is not solved, as when I change the line to `cd $srcdir/archlinux-linux` it tells me that there is no such file or directory. How do I make the patch file transfer into the archlinux-linux directory?

Last edited by highfrequencyhertz (2021-09-22 06:06:54)

Offline

#18 2021-09-22 05:02:28

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 29,686
Website

Re: [SOLVED] Error when automatically applying patch with makepkg.

What is the name of the directory in $srcdir once the tarball is extracted? And paste the PKGBUILD,


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#19 2021-09-22 05:04:16

highfrequencyhertz
Member
Registered: 2021-05-30
Posts: 34

Re: [SOLVED] Error when automatically applying patch with makepkg.

The name is archlinux-linux

PKGBUILD:

# Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>

pkgbase=linux
pkgver=5.14.6.arch1
pkgrel=1
pkgdesc='Linux'
_srctag=v${pkgver%.*}-${pkgver##*.}
url="https://github.com/archlinux/linux/commits/$_srctag"
arch=(x86_64)
license=(GPL2)
makedepends=(
  bc kmod libelf pahole cpio perl tar xz
  xmlto python-sphinx python-sphinx_rtd_theme graphviz imagemagick
  git
)
options=('!strip')
_srcname=archlinux-linux
source=(
  "$_srcname::git+https://github.com/archlinux/linux?signed#tag=$_srctag"
  PKGBUILD.patch
  config         # the main kernel config file
)
validpgpkeys=(
  'ABAF11C65A2970B130ABE3C479BE3E4300411886'  # Linus Torvalds
  '647F28654894E3BD457199BE38DBBDC86092693E'  # Greg Kroah-Hartman
  'A2FF3A36AAA56654109064AB19802F8B0D70FC30'  # Jan Alexander Steffens (heftig)
  'C7E7849466FE2358343588377258734B41C31549'  # David Runge <dvzrv@archlinux.org>
)
sha256sums=('SKIP'
            'f98065a286a6d2dbb0e226867a6417e344aaa44ef6eac967707e1f09671be445')

export KBUILD_BUILD_HOST=archlinux
export KBUILD_BUILD_USER=$pkgbase
export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})"

prepare() {
  cd $srcdir/archlinux-linux
  patch --strip=1 --input="PKGBUILD.patch"
  echo "Setting version..."
  scripts/setlocalversion --save-scmversion
  echo "-$pkgrel" > localversion.10-pkgrel
  echo "${pkgbase#linux}" > localversion.20-pkgname

  local src
  for src in "${source[@]}"; do
    src="${src%%::*}"
    src="${src##*/}"
    [[ $src = *.patch ]] || continue
    echo "Applying patch $src..."
    patch -Np1 < "../$src"
  done

  echo "Setting config..."
  cp ../config .config
  make olddefconfig

  make -s kernelrelease > version
  echo "Prepared $pkgbase version $(<version)"
}

build() {
  cd $_srcname
  make all
  make htmldocs
}

_package() {
  pkgdesc="The $pkgdesc kernel and modules"
  depends=(coreutils kmod initramfs)
  optdepends=('crda: to set the correct wireless channels of your country'
              'linux-firmware: firmware images needed for some devices')
  provides=(VIRTUALBOX-GUEST-MODULES WIREGUARD-MODULE)
  replaces=(virtualbox-guest-modules-arch wireguard-arch)

  cd $_srcname
  local kernver="$(<version)"
  local modulesdir="$pkgdir/usr/lib/modules/$kernver"

  echo "Installing boot image..."
  # systemd expects to find the kernel here to allow hibernation
  # https://github.com/systemd/systemd/commit/edda44605f06a41fb86b7ab8128dcf99161d2344
  install -Dm644 "$(make -s image_name)" "$modulesdir/vmlinuz"

  # Used by mkinitcpio to name the kernel
  echo "$pkgbase" | install -Dm644 /dev/stdin "$modulesdir/pkgbase"

  echo "Installing modules..."
  make INSTALL_MOD_PATH="$pkgdir/usr" INSTALL_MOD_STRIP=1 modules_install

  # remove build and source links
  rm "$modulesdir"/{source,build}
}

_package-headers() {
  pkgdesc="Headers and scripts for building modules for the $pkgdesc kernel"
  depends=(pahole)

  cd $_srcname
  local builddir="$pkgdir/usr/lib/modules/$(<version)/build"

  echo "Installing build files..."
  install -Dt "$builddir" -m644 .config Makefile Module.symvers System.map \
    localversion.* version vmlinux
  install -Dt "$builddir/kernel" -m644 kernel/Makefile
  install -Dt "$builddir/arch/x86" -m644 arch/x86/Makefile
  cp -t "$builddir" -a scripts

  # add objtool for external module building and enabled VALIDATION_STACK option
  install -Dt "$builddir/tools/objtool" tools/objtool/objtool

  # add xfs and shmem for aufs building
  mkdir -p "$builddir"/{fs/xfs,mm}

  echo "Installing headers..."
  cp -t "$builddir" -a include
  cp -t "$builddir/arch/x86" -a arch/x86/include
  install -Dt "$builddir/arch/x86/kernel" -m644 arch/x86/kernel/asm-offsets.s

  install -Dt "$builddir/drivers/md" -m644 drivers/md/*.h
  install -Dt "$builddir/net/mac80211" -m644 net/mac80211/*.h

  # https://bugs.archlinux.org/task/13146
  install -Dt "$builddir/drivers/media/i2c" -m644 drivers/media/i2c/msp3400-driver.h

  # https://bugs.archlinux.org/task/20402
  install -Dt "$builddir/drivers/media/usb/dvb-usb" -m644 drivers/media/usb/dvb-usb/*.h
  install -Dt "$builddir/drivers/media/dvb-frontends" -m644 drivers/media/dvb-frontends/*.h
  install -Dt "$builddir/drivers/media/tuners" -m644 drivers/media/tuners/*.h

  # https://bugs.archlinux.org/task/71392
  install -Dt "$builddir/drivers/iio/common/hid-sensors" -m644 drivers/iio/common/hid-sensors/*.h

  echo "Installing KConfig files..."
  find . -name 'Kconfig*' -exec install -Dm644 {} "$builddir/{}" \;

  echo "Removing unneeded architectures..."
  local arch
  for arch in "$builddir"/arch/*/; do
    [[ $arch = */x86/ ]] && continue
    echo "Removing $(basename "$arch")"
    rm -r "$arch"
  done

  echo "Removing documentation..."
  rm -r "$builddir/Documentation"

  echo "Removing broken symlinks..."
  find -L "$builddir" -type l -printf 'Removing %P\n' -delete

  echo "Removing loose objects..."
  find "$builddir" -type f -name '*.o' -printf 'Removing %P\n' -delete

  echo "Stripping build tools..."
  local file
  while read -rd '' file; do
    case "$(file -bi "$file")" in
      application/x-sharedlib\;*)      # Libraries (.so)
        strip -v $STRIP_SHARED "$file" ;;
      application/x-archive\;*)        # Libraries (.a)
        strip -v $STRIP_STATIC "$file" ;;
      application/x-executable\;*)     # Binaries
        strip -v $STRIP_BINARIES "$file" ;;
      application/x-pie-executable\;*) # Relocatable binaries
        strip -v $STRIP_SHARED "$file" ;;
    esac
  done < <(find "$builddir" -type f -perm -u+x ! -name vmlinux -print0)

  echo "Stripping vmlinux..."
  strip -v $STRIP_STATIC "$builddir/vmlinux"

  echo "Adding symlink..."
  mkdir -p "$pkgdir/usr/src"
  ln -sr "$builddir" "$pkgdir/usr/src/$pkgbase"
}

_package-docs() {
  pkgdesc="Documentation for the $pkgdesc kernel"

  cd $_srcname
  local builddir="$pkgdir/usr/lib/modules/$(<version)/build"

  echo "Installing documentation..."
  local src dst
  while read -rd '' src; do
    dst="${src#Documentation/}"
    dst="$builddir/Documentation/${dst#output/}"
    install -Dm644 "$src" "$dst"
  done < <(find Documentation -name '.*' -prune -o ! -type d -print0)

  echo "Adding symlink..."
  mkdir -p "$pkgdir/usr/share/doc"
  ln -sr "$builddir/Documentation" "$pkgdir/usr/share/doc/$pkgbase"
}

pkgname=("$pkgbase" "$pkgbase-headers" "$pkgbase-docs")
for _p in "${pkgname[@]}"; do
  eval "package_$_p() {
    $(declare -f "_package${_p#$pkgbase}")
    _package${_p#$pkgbase}
  }"
done

# vim:set ts=8 sts=2 sw=2 et:
sha256sums=('SKIP'
            'c63cb17d24ec70e741236e4bd118bcfa32ecf27b698c53e4b26b7915d1af4617'
            'f98065a286a6d2dbb0e226867a6417e344aaa44ef6eac967707e1f09671be445')

Offline

#20 2021-09-22 05:10:49

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 29,686
Website

Re: [SOLVED] Error when automatically applying patch with makepkg.

So, this is just the vanilla arch PKGBUILD? Then you don't need to cd to $srcdir as you are setting srcname. Just use the existing function for local src to apply the *.patch file.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#21 2021-09-22 05:16:24

highfrequencyhertz
Member
Registered: 2021-05-30
Posts: 34

Re: [SOLVED] Error when automatically applying patch with makepkg.

Ok, I replaced 'cd $_srcname' with 'cd $srcdir/archlinux-linux' and received this message:

patch: **** Can't open patch file PKGBUILD.patch : No such file or directory
==> ERROR: A failure occurred in prepare().
    Aborting...

Offline

#22 2021-09-22 05:27:00

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 29,686
Website

Re: [SOLVED] Error when automatically applying patch with makepkg.

You are trying to patch the PKGBUILD that you are running makepkg against?


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#23 2021-09-22 05:30:47

highfrequencyhertz
Member
Registered: 2021-05-30
Posts: 34

Re: [SOLVED] Error when automatically applying patch with makepkg.

Don't really understand this stuff. Could you explain how it should be done?

Offline

#24 2021-09-22 05:34:51

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,060
Website

Re: [SOLVED] Error when automatically applying patch with makepkg.

You can not patch a PKGBUILD form within a PKGBUILD.  You apply the patch manually, then run makepkg.

Offline

#25 2021-09-22 05:36:24

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 29,686
Website

Re: [SOLVED] Error when automatically applying patch with makepkg.

Just manually edit the PKGBUILD and run makepkg. You would only need a patch if you were using a scripted build.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

Board footer

Powered by FluxBB