You are not logged in.

#1 2018-10-10 15:05:53

jLuca
Member
From: Italy
Registered: 2016-12-06
Posts: 24

[SOLVED] How to merge sourced files in the prepare process

Hello guys, it's my first time installing a package (the st terminal emulator) from the AUR and I got stuck here:
I created my PKGBUILD file with the intention to maintain it for future upgrades, it contains the source files, the patches files and a config.h header file which contains some settings for my terminal emulator. Currently in the prepare function I apply the patches first and then I copy the auto-generated config.h.def file to config.h as to have the patched configured file. My question is: if I add to the source file a personal (not still patched) config.h already edited with my preferences how can I integrate it with the patched one during the patching process?

Here is my current PKGBUILD file:

pkgname=st
pkgver=0.8.1
pkgrel=1
pkgdesc='A simple virtual terminal emulator for X.'
arch=('i686' 'x86_64')
license=('MIT')
depends=('libxft' 'libxext' 'xorg-fonts-misc')
makedepends=('ncurses')
url="http://st.suckless.org"
source=(http://dl.suckless.org/st/$pkgname-$pkgver.tar.gz
        #config.h
        https://st.suckless.org/patches/hidecursor/st-hidecursor-$pkgver.diff
        #https://st.suckless.org/patches/alpha/st-alpha-$pkgver.diff
        https://st.suckless.org/patches/clipboard/st-clipboard-$pkgver.diff
        https://st.suckless.org/patches/solarized/st-no_bold_colors-$pkgver.diff
        https://st.suckless.org/patches/solarized/st-solarized-both-$pkgver.diff
)

prepare() {
  cd $srcdir/$pkgname-$pkgver

  # skip terminfo which conflicts with nsurses
  sed -i '/tic /d' Makefile

  # Moving source patch files
  #cp $srcdir/st-alpha-0.8.1.diff st-alpha-0.8.1.diff
  cp $srcdir/st-hidecursor-$pkgver.diff st-hidecursor-$pkgver.diff
  cp $srcdir/st-clipboard-$pkgver.diff st-clipboard-$pkgver.diff
  cp $srcdir/st-no_bold_colors-$pkgver.diff st-no_bold_colors-$pkgver.diff
  cp $srcdir/st-solarized-both-$pkgver.diff st-solarized-both-$pkgver.diff

  # Applying patches
  patch -Np1 -i st-no_bold_colors-$pkgver.diff
  patch -Np1 -i st-solarized-both-$pkgver.diff
  patch -Np1 -i st-clipboard-$pkgver.diff
  patch -Np1 -i st-hidecursor-$pkgver.diff
  #patch -Np1 -i st-alpha-0.8.1.diff

  # Creating the config.h file
  cp config.def.h config.h
  # Here I would like to do something like:
  # Mergefiles() $srcdir/config.h config.h (to merge my config.h with the one just copied)
}

build() {
  cd $srcdir/$pkgname-$pkgver
  make X11INC=/usr/include/X11 X11LIB=/usr/lib/X11
}

package() {
  cd $srcdir/$pkgname-$pkgver
  make PREFIX=/usr DESTDIR="$pkgdir" TERMINFO="$pkgdir/usr/share/terminfo" install
  install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
  install -Dm644 README "$pkgdir/usr/share/doc/$pkgname/README"
}

md5sums=('92135aecdba29300bb2e274a55f5b71e'
         '7b6f4a1efe7987b8f5554b4ec16082f9'
         'd7295edae3ff61b93e9f875f6eaaad7a'
         '5f0f925b00b5c71a3ffc03edaf8591ed'
         '5bcc5c2d58bb71d2c7c258b3907ecc6d')

Last edited by jLuca (2019-02-06 16:00:48)

Offline

#2 2018-10-11 06:44:36

a821
Member
Registered: 2012-10-31
Posts: 381

Re: [SOLVED] How to merge sourced files in the prepare process

I guess you can just add your already patched `config.h` to the source array (not the unpatched `config.h`) and forget about `config.def.h`. Or you can create another patch with your settings and apply it after copying the auto-generated config file. Maybe there are other ideas...

Also, make sure to quote $srcdir. And there's no need to copy the patches from $srcdir before calling patch just do

patch -Np1 -i "$srcdir/st-no_bold_colors-$pkgver.diff"
...

Offline

#3 2018-10-11 11:42:15

jLuca
Member
From: Italy
Registered: 2016-12-06
Posts: 24

Re: [SOLVED] How to merge sourced files in the prepare process

a821 wrote:

I guess you can just add your already patched `config.h` to the source array (not the unpatched `config.h`) and forget about `config.def.h`. Or you can create another patch with your settings and apply it after copying the auto-generated config file. Maybe there are other ideas...

The first case would make me do that step everytime I need to update something, I would like to automate it. The second case it's the same, the new patch of my config file wouldn't see the new settings from the patches. Correct me if I'm wrong.

Offline

#4 2018-10-11 12:56:01

a821
Member
Registered: 2012-10-31
Posts: 381

Re: [SOLVED] How to merge sourced files in the prepare process

The first case would make me do that step everytime I need to update something, I would like to automate it.

Why? you just modify the patched `config.h` to your liking and then run `makepkg` to update the package. (you still need to update the md5sum of config.h, but given that you're creating the file (and not sharing it), it is OK to just put SKIP, or just run `makepg -g`)

Or do you mean upstream changes? In that case you still need to do manual work to update the PKGBUILD.

Edit: a word

Last edited by a821 (2018-10-11 13:00:08)

Offline

#5 2018-10-11 13:35:49

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,514
Website

Re: [SOLVED] How to merge sourced files in the prepare process

FWIW I just use a short sed script to modify config.h for st for my preferences.  Unlike a patch, my sed script doesn't care at all about line numbers, so it is more robust with respect to changes in the upstream config.h (or patches applied to config.h).  In the PKGBUILD I just add a line like `sed -if /path/to/my/st.sed config.h` to the prepare or build function.

Last edited by Trilby (2018-10-11 13:36:07)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#6 2018-12-09 19:55:18

jLuca
Member
From: Italy
Registered: 2016-12-06
Posts: 24

Re: [SOLVED] How to merge sourced files in the prepare process

In the end, I applied the patches normally modifying them inline with sed (skipping the first lines which would conflict with my custom config.h). I modified my custom config.h to contain the skipped lines not to lose any patch content.

Last edited by jLuca (2018-12-09 20:00:14)

Offline

Board footer

Powered by FluxBB