You are not logged in.

#1 2004-08-13 23:06:08

gs
Member
From: UK
Registered: 2004-03-06
Posts: 147

Making and Applying Patches.

I am having quality fun. (Is there any other sort?)

The question concerns the directory origins.

I can't find a way of linking in $startdir, so I quote /var/abs/local/mydirName/pkg/usr, or some some such, in makefile patches. And then I put a cautionary note in the PKGBUILD that if run on another installation the patch file will need to be edited.

Can the higher (exquisite) level of automation be acheived?


What the beep was that?

Offline

#2 2004-08-13 23:20:59

sarah31
Member
From: Middle of Canada
Registered: 2002-08-20
Posts: 2,975
Website

Re: Making and Applying Patches.

can you givre an example of what you mean. I am not clear on what exactly you are asking


AKA uknowme

I am not your friend

Offline

#3 2004-08-13 23:31:30

gs
Member
From: UK
Registered: 2004-03-06
Posts: 147

Re: Making and Applying Patches.

This patch is used in WorNet-2.0 configured for use with kthesaurus. You see WN_ROOT and the entire directory.

37c37
< PLATFORM = solaris
---
> #PLATFORM = solaris
39c39
< #PLATFORM = linux
---
> PLATFORM = linux
65c65
< WN_ROOT = /usr/local/WordNet-2.0/pkg
---
> WN_ROOT = /var/abs/local/WordNet/pkg/usr/local/WordNet-2.0
72c72
< WN_BINDIR = $(WN_ROOT)/bin
---
> WN_BINDIR = /var/abs/local/WordNet/pkg/usr/bin
121c121
< LOCAL_LDFLAGS = -R/usr/openwin/lib:/usr/lib:/usr/local/lib
---
> #LOCAL_LDFLAGS = -R/usr/openwin/lib:/usr/lib:/usr/local/lib
124c124
< #LOCAL_LDFLAGS =
---
> LOCAL_LDFLAGS =
145,150c145,150
< TCL_INCDIR = /usr/local/include
< TCL_LIBDIR = /usr/local/lib
< TK_INCDIR = /usr/local/include
< TK_LIBDIR = /usr/local/lib
< X11_INCDIR = /usr/openwin/include
< X11_LIBDIR = /usr/openwin/lib
---
> #TCL_INCDIR = /usr/local/include
> #TCL_LIBDIR = /usr/local/lib
> #TK_INCDIR = /usr/local/include
> #TK_LIBDIR = /usr/local/lib
> #X11_INCDIR = /usr/openwin/include
> #X11_LIBDIR = /usr/openwin/lib
163,168c163,168
< #TCL_INCDIR = /usr/include
< #TCL_LIBDIR = /usr/lib
< #TK_INCDIR = /usr/include
< #TK_LIBDIR = /usr/lib
< #X11_INCDIR = /usr/X11R6/include
< #X11_LIBDIR = /usr/X11R6/lib
---
> TCL_INCDIR = /usr/include
> TCL_LIBDIR = /usr/lib
> TK_INCDIR = /usr/include
> TK_LIBDIR = /usr/lib
> X11_INCDIR = /usr/X11R6/include
> X11_LIBDIR = /usr/X11R6/lib
181c181
< #WNB_LIBS = -ltk -ltcl -lX11 -lm -lnsl -ldl -lpthread
---
> WNB_LIBS = -ltk -ltcl -lX11 -lm -lnsl -ldl -lpthread


Thanks for responding, Sarah31.


What the beep was that?

Offline

#4 2004-08-13 23:49:21

gs
Member
From: UK
Registered: 2004-03-06
Posts: 147

Re: Making and Applying Patches.

A slight red herring, above, in line 12

< WN_ROOT = /usr/local/WordNet-2.0/pkg
should be without '/pkg'.

You may be wondering about the /usr/local and the answer is that kthesaurus requires it to be there. Similarly, it has to be /usr/bin/wn.


What the beep was that?

Offline

#5 2004-08-13 23:49:57

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Re: Making and Applying Patches.

are you looking for something like patch -p0 to remove all slashes? (check the man page for patch)

I'm not sure I follow the question either.

Dusty

Offline

#6 2004-08-14 00:06:54

gs
Member
From: UK
Registered: 2004-03-06
Posts: 147

Re: Making and Applying Patches.

Now I 'm confused...

Certainly, patch -p0 works as did patch -p1.

No, my /var/abs/local/WordNet/ becomes symbolised in PKGBUILD as $startdir. I am therefore wondering whether it is inevitable that the patch file must contain the 'hard' reference. I have, of course tried to incorporate '$startdir' in the patchfile and PKGBUILD then ends up making and writing to a directory called 'tartdir'.

So my question is about whther '$startdir' can be embedded in the patchfile so that it becomes properly decoded.

Thanks. I am not really confused, even if I sound it!


What the beep was that?

Offline

#7 2004-08-14 00:35:58

gs
Member
From: UK
Registered: 2004-03-06
Posts: 147

Re: Making and Applying Patches.

The more I think about it the answer to my own question is no. I reason that the patch only does what manually altering the Makefile would achieve, and $startdir is quite external to what goes on inside the /src directory.


What the beep was that?

Offline

#8 2004-08-14 18:12:13

Xentac
Forum Fellow
From: Victoria, BC
Registered: 2003-01-17
Posts: 1,797
Website

Re: Making and Applying Patches.

Patch it with something that can be substituted out with sed in the PKGBUILD file.

Check out the host package's PKGBUILD or the mozilla PKGBUILD.


I have discovered that all of mans unhappiness derives from only one source, not being able to sit quietly in a room
- Blaise Pascal

Offline

#9 2004-08-14 21:21:34

gs
Member
From: UK
Registered: 2004-03-06
Posts: 147

Re: Making and Applying Patches.

Thanks Xentac.

I have aquired the technique you describe, and have tested this command to satisfaction on a sample data file "testfile" writing the transformed result into "testfile_2"

sed 's/$symbol/actual_stuff/' /home/gs2/Key_Documents/test/testfile >/home/gs2/Key_Documents/test/testfile_2

Sed looks forbidding in the man page, doesn't it? I can see that $symbol could be $startdir and actual_stuff could be the 'hard' path. I notice also that you can't write back to the same file, unless you copy the second file back to the first with a subsequent cp command.

When I have practised the technique on some 'real' examples, would a HowTo on 'Using Sed with Patch Files' be of any use? Or would that tend to make the wiki pages choked with more and more forbidding looking stuff?


What the beep was that?

Offline

#10 2004-08-15 01:05:57

Xentac
Forum Fellow
From: Victoria, BC
Registered: 2003-01-17
Posts: 1,797
Website

Re: Making and Applying Patches.

Close... but no cigar.

'sed -i "s/original_text/other_text" filename' is really the format.

This modifies the file in place and substitutes other_text for original_text.

If you look at the patch that was created for the host package, called Build.patch, part of it looks like this:
-PREFIX = /usr/local
-SHARE = /share
+PREFIX = #PREFIX#

Then, in the PKGBUILD, the sed line is thus:
sed -i "s%#PREFIX#%$startdir/pkg/usr%g" Makefile

Notice how #PREFIX# is going to be replaced with $startdir/pkg/usr?  It's pretty simple and there are lots of examples.

Feel free to write a wiki about it, but I don't know if anyone will read it.  Also, it's a topic that will be mentioned in my packaging articles (once I can force myself to work on them some more).


I have discovered that all of mans unhappiness derives from only one source, not being able to sit quietly in a room
- Blaise Pascal

Offline

#11 2004-08-15 13:10:28

gs
Member
From: UK
Registered: 2004-03-06
Posts: 147

Re: Making and Applying Patches.

I have been working my way into incorporating your comments... and had success. My present queries are about sound working practice.

I have created a working sub-directory '/diff_stuff' in which I place copies of Makefile and the edited version. I run 'diff Makefile Mfile_symbolic' -- I am having problems using the -aur option because  makepkg cannot read the end-result 3rd header line.

I create patch_symbolic and copy it as WordNet-2.0.patch_symbolic into $startdir.

I use the following sed and patch lines in PKGBUILD. The sed line generates WordNet-2.0.patch_actual, also sitting in $startdir.

  sed 's #pkgdir# /var/abs/local/WordNet/pkg g' $startdir/WordNet-2.0.patch_symbolic >$startdir/WordNet-2.0.patch_actual
  patch -p1 Makefile $startdir/$pkgname-$pkgver.patch_actual

# Note. This sed command relaces #pkgdir# with '/var/abs/local/WordNet/pkg/', 
# writing the results to WordNet-2.0.patch_actual. You will need to edit the
# sed command as appropriate; the patch_symbolic, itself, should normally
#  be left alone.

---------------------
The -aur problem is probably because I transform the patch before applying it. But I will experiment and hopefully learn some more.

Can you see a crisper method and notation (more clean cut (possibly?) -- I am not quite sure about  UK usage, such as 'crisp', being consistent with North American... I could check out in a dictionary, I s'pose.)


What the beep was that?

Offline

#12 2004-08-15 15:35:44

gs
Member
From: UK
Registered: 2004-03-06
Posts: 147

Re: Making and Applying Patches.

Here is a slightly different approach.

sed 's #pkgdir# /var/abs/local/WordNet/pkg g' $startdir/Mfile_symbolic >$startdir/src/$pkgname-$pkgver/Makefile

This just re-codes the edited Makefile into the src directory. No pfaffing with diff; no twiddly sub-directories; less clutter in the PKGBUILD.

It's true that there is  a bulkier file sitting in the $startdir.


What the beep was that?

Offline

#13 2004-08-15 17:01:43

Xentac
Forum Fellow
From: Victoria, BC
Registered: 2003-01-17
Posts: 1,797
Website

Re: Making and Applying Patches.

You could do it like that too (which is also not how I described it), but you have a chance of invalidating the patch (which is probably why the -u argument doesn't work for diff).

Also, DO NOT modify or access files outside of $startdir/pkg or $startdir/src.  You should never access them because, if you are, you don't get the benefit of source md5sums.

If you read the host PKGBUILD again you'll see that the patch is applied to the file first, then the sed line is applied to the same file (not the patch!):
        patch < $startdir/src/Build.patch || return 1
        sed -i "s%#PREFIX#%$startdir/pkg/usr%g" Makefile

Inside the patch file, one of the variables is set to #PREFIX#.  Then the sed line modifies that same file, only replaces #PREFIX# with $startdir/pkg/usr.


I have discovered that all of mans unhappiness derives from only one source, not being able to sit quietly in a room
- Blaise Pascal

Offline

#14 2004-08-15 22:34:18

gs
Member
From: UK
Registered: 2004-03-06
Posts: 147

Re: Making and Applying Patches.

cd $startdir/src/$pkgname-$pkgver
  patch Makefile $startdir/$pkgname-$pkgver.patch
  sed -i "s%#PREFIX#%$startdir/pkg%g" Makefile
--------------------------------------------------
Addressing my earlier misunderstandings: --

I have now looked at host. Believe it or not, I couldn't quite see that you were referring to a package literallly called that. In my blissful newbie ignorance I had puzzled over what 'the host package' could describe, and what could be that package's name!

The above method is simpler (Not at all a***e about face!).

My patch is homemade and created from copying and editing the pristine Makefile, and this time I did the patch creation with files in the $startdir. And I think I have broken some of the MD5SUM rules you describe, but applying the patch is a measured intervention as compared with overwriting with an entire altered Makefile. Did you mean that I should copy the created patch into /src and apply it from there?

I still can't get -aur to work for me (leading to patch-rejected hunks!), but this is a lot of progress considering how much there is yet to learn. I was also having a lot of perverted fun with what I thought were pristine makefiles, but which had been earlier altered with sed processes.... there are certainly a heck of a lot of pitfalls with sed.


What the beep was that?

Offline

#15 2004-08-16 06:28:30

gs
Member
From: UK
Registered: 2004-03-06
Posts: 147

Re: Making and Applying Patches.

build() {
  cd $startdir/src/$pkgname-$pkgver
  diff -aur Makefile $startdir/Makefile_new >$startdir/$pkgname-$pkgver.patch
# This can be commented out, once patch is made. 
  patch Makefile $startdir/$pkgname-$pkgver.patch
  sed -i "s%#PREFIX#%$startdir/pkg%g" Makefile
  make prefix=$startdir/pkg/usr SourceWorld
  make prefix=$startdir/pkg/usr BinWorld
}
----------------------------------------
-aur issue now solved, since I have started redirecting output to a file, rather copying and pasting from terminal.


What the beep was that?

Offline

Board footer

Powered by FluxBB