Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[solved] pacth -p0 <$patch_file work in console, epatch fail
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
Dominique_71
Veteran
Veteran


Joined: 17 Aug 2005
Posts: 1691
Location: Switzerland (Romandie)

PostPosted: Thu Jul 27, 2017 4:19 pm    Post subject: [solved] pacth -p0 <$patch_file work in console, epatch f Reply with quote

Hi,

I try to make an ebuild for goattracker-2.74:
Code:
# Copyright 1999-2017 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2


EAPI=6
inherit eutils toolchain-funcs

MY_P=GoatTracker_${PV}_Stereo

DESCRIPTION="A tracker-like editor for creating C64 MOS 6581/8580 SID music"
HOMEPAGE="http://covertbitops.c64.org/"
SRC_URI="mirror://sourceforge/goattracker2/GoatTracker%202%20Stereo/${PV}/${MY_P}.zip"
RESTRICT="mirror"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="examples"

RDEPEND=">=media-libs/libsdl-1.2.14[sound,video]"
DEPEND="${RDEPEND}
   app-arch/unzip
   virtual/pkgconfig"
# modified resid is bundled in the source tree

S=${WORKDIR}

PATCHES=(
   "${FILESDIR}/${PN}-2.74_makefile.patch"
   "${FILESDIR}/${PN}-2.74_makefile.common.patch"
   "${FILESDIR}/${PN}-2.74_bme_makefile.patch"
)

src_prepare() {
   cd ${S}/src

   default
#   EPATCH_OPTS="-p0"
#   cd ${S}
#   cp "${FILESDIR}/${PN}-2.74_makefile.common.patch" .
#   epatch "${FILESDIR}/${PN}-2.74_makefile.patch"
   #epatch "${PN}-2.74_makefile.common.patch"
#   patch -p0 -f <"${PN}-2.74_makefile.common.patch"
#   epatch "${FILESDIR}/${PN}-2.74_bme_makefile.patch"
#   eapply_user
   # don't strip binaries
   sed -i -e "s/strip/#strip/g" src/bme/makefile src/makefile.common || die
   # sed the arguments in the examples info, this is not windows
#   sed -i -e "s|/|-|g" examples/goatcompo.txt || die
}

src_compile() {
   tc-export CC CXX
   cd src/bme
   emake || die "compile src/bme failed"
   cd ..
   emake || die "compile src failed"
}

src_install() {
   dobin linux/{gt2stereo,ins2snd2,mod2sng2,ss2stereo} || die

   dodoc authors readme.txt readme_resid.txt goat_tracker_commands.pdf

   doicon "${FILESDIR}/goattrk2.xpm"
   make_desktop_entry gt2stereo GoatTracker gt2stereo "AudioVideo;Audio;"

   if use examples; then
      insinto "/usr/share/doc/${PF}/examples"
      doins examples/*.{ins,sng,prg}
   fi
}


${PN}-2.74_makefile.common.patch work fine when I apply it at the console with 'patch -p0 <${PN}-2.74_makefile.common.patch', but fail both with epatch and eapply_user. It also fail when I put the console working command in the ebuild:
Code:
 * Applying goattracker-2.74_makefile.common.patch ...
1 out of 2 hunks FAILED -- saving rejects to file makefile.common.rej
...
# cat src/makefile.common.rej
--- makefile.common.orig   2017-07-27 02:34:24.534539719 +0200
+++ makefile.common   2017-07-27 02:42:11.469522682 +0200
@@ -24,20 +26,20 @@
 asm/asmtab.o asm/chnkpool.o asm/expr.o asm/lexyy.o asm/log.o asm/membuf.o asm/membufio.o asm/namedbuf.o asm/parse.o \
 asm/pc.o asm/vec.o \
 bme/bme_gfx.o bme/bme_snd.o bme/bme_win.o bme/bme_mou.o bme/bme_kbd.o bme/bme_io.o bme/bme_end.o bme/bme.o
-   $(CXX) -o $@ $^ $(LIBS)
+   $(CXX) $(LDFLAGS) $(EXTFLAGS) -o $@ $^ $(LIBS)
    #strip $@
 
 $(PREFIX)mod2sng2$(SUFFIX): mod2sng2.o bme/bme_end.o
-   gcc -o $@ $^
+   $(CC) $(LDFLAGS) $(EXTFLAGS) -o $@ $^
    #strip $@
 
 $(PREFIX)ins2snd2$(SUFFIX): ins2snd2.o bme/bme_end.o
-   gcc -o $@ $^
+   $(CC) $(LDFLAGS) $(EXTFLAGS) -o $@ $^
    #strip $@
 
 $(PREFIX)ss2stereo$(SUFFIX): ss2stereo.o bme/bme_end.o
-   gcc -o $@ $^
+   $(CC) $(LDFLAGS) $(EXTFLAGS) -o $@ $^
    #strip $@
 
 gt2stereo.dat: player.s altplayer.s chargen.bin palette.bin cursor.bin goattrk2.bmp gt2stereo.seq
    datafile $@ gt2stereo.seq

The patch is as follow:
Code:
--- src/makefile.common.orig   2017-07-27 02:34:24.534539719 +0200
+++ src/makefile.common   2017-07-27 02:42:11.469522682 +0200
@@ -1,9 +1,11 @@
 # common makefile directives for linux and win32 build
 
-CC=gcc
-CXX=g++
-CFLAGS+=-O3 -Wall -Ibme -Iasm
-CXXFLAGS=$(CFLAGS)
+CC ?= gcc
+CXX ?= g++
+CPPFLAGS += -Ibme -Iasm
+EXTFLAGS += -Wall
+CFLAGS ?= -O3
+CXXFLAGS ?= -O3
 
 EXE=   $(PREFIX)gt2stereo$(SUFFIX) \
    $(PREFIX)ins2snd2$(SUFFIX) \
@@ -22,20 +24,20 @@
 asm/asmtab.o asm/chnkpool.o asm/expr.o asm/lexyy.o asm/log.o asm/membuf.o asm/membufio.o asm/namedbuf.o asm/parse.o \
 asm/pc.o asm/vec.o \
 bme/bme_gfx.o bme/bme_snd.o bme/bme_win.o bme/bme_mou.o bme/bme_kbd.o bme/bme_io.o bme/bme_end.o bme/bme.o
-   $(CXX) -o $@ $^ $(LIBS)
+   $(CXX) $(LDFLAGS) $(EXTFLAGS) -o $@ $^ $(LIBS)
   #strip $@
 
 $(PREFIX)mod2sng2$(SUFFIX): mod2sng2.o bme/bme_end.o
-   gcc -o $@ $^
+   $(CC) $(LDFLAGS) $(EXTFLAGS) -o $@ $^
   #strip $@
 
 $(PREFIX)ins2snd2$(SUFFIX): ins2snd2.o bme/bme_end.o
-   gcc -o $@ $^
+   $(CC) $(LDFLAGS) $(EXTFLAGS) -o $@ $^
   #strip $@
 
 $(PREFIX)ss2stereo$(SUFFIX): ss2stereo.o bme/bme_end.o
-   gcc -o $@ $^
+   $(CC) $(LDFLAGS) $(EXTFLAGS) -o $@ $^
   #strip $@
 
 gt2stereo.dat: player.s altplayer.s chargen.bin palette.bin cursor.bin goattrk2.bmp gt2stereo.seq
    datafile $@ gt2stereo.seq


We don't see the end of lines here. The original file is coming from windows, which imply it is '^M' at the end of each line both in the file and in the patch.

Have someone a clue on how to make this f. patch to work with portage?


Last edited by Dominique_71 on Thu Jul 27, 2017 5:26 pm; edited 1 time in total
Back to top
View user's profile Send private message
Dominique_71
Veteran
Veteran


Joined: 17 Aug 2005
Posts: 1691
Location: Switzerland (Romandie)

PostPosted: Thu Jul 27, 2017 5:25 pm    Post subject: Reply with quote

It's maybe a charset issue. I used a workaround by removing from the patch the non working chunk and put some sed statements in the ebuild. When doing this, it appear it fail to understand the $ sign of $(CXX).

Code:
sed -i -e "s/(CXX)/(CXX) \$(LDFLAGS) \$(EXTFLAGS)/" src/makefile.common || die
   sed -i -e "s/gcc/\$\(CC\) \$\(LDFLAGS\) \$\(EXTFLAGS\)/g" src/makefile.common || die
Back to top
View user's profile Send private message
steveL
Watchman
Watchman


Joined: 13 Sep 2006
Posts: 5153
Location: The Peanut Gallery

PostPosted: Thu Jul 27, 2017 7:28 pm    Post subject: Reply with quote

Dominique_71 wrote:
It's maybe a charset issue. I used a workaround by removing from the patch the non working chunk and put some sed statements in the ebuild. When doing this, it appear it fail to understand the $ sign of $(CXX).
Code:
sed -i -e "s/(CXX)/(CXX) \$(LDFLAGS) \$(EXTFLAGS)/" src/makefile.common || die
   sed -i -e "s/gcc/\$\(CC\) \$\(LDFLAGS\) \$\(EXTFLAGS\)/g" src/makefile.common || die
Use single-quotes here, not double-quotes. Save those for when you have shell expansions going on (or you need to wrap a single-quoted literal.)

It's far too confusing to work out what's happening when you have to deal with two levels of backslash (bash and sed, or awk, ed, etc) unless you're using a custom function that does the escaping for you. (Unneeded here.)

That initial 's/(CXX)/' really should use \$ imo, so: 's/\$(CXX)/$(CXX) $(LDFLAGS) $(EXTFLAGS)/'
Not sure it's such a great idea (seems too broad) but you know the files.

If that's what you're complaining about, I don't understand, as that looks like bash taken straight from an ebuild.

You know sed uses BRE by default, right? So what's with all the "\(" in the second statement? (they're just simple '(' to sed.) That's replacement text as well, so you can't match subexpressions.
Quote:
We don't see the end of lines here. The original file is coming from windows, which imply it is '^M' at the end of each line both in the file and in the patch.
Check your assumptions; pastebins mangle pastes, etc.
Does patch on linux work happily with \r\n terminated lines? It's common to have to strip \r before using UNIX tools.
##workingset
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum