LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Gentoo
User Name
Password
Gentoo This forum is for the discussion of Gentoo Linux.

Notices


Reply
  Search this Thread
Old 06-10-2017, 12:45 PM   #1
nobodino
Senior Member
 
Registered: Jul 2010
Location: Near Bordeaux in France
Distribution: slackware, slackware from scratch, LFS, slackware [arm], linux Mint...
Posts: 1,564

Rep: Reputation: 892Reputation: 892Reputation: 892Reputation: 892Reputation: 892Reputation: 892Reputation: 892
help concerning sed command:


Can someone help me undertand what is doing the following command, it's called for building xfsdump:
------------------
sed -i -e "s:enable_curses=[a-z]*:enable_curses=$(usex ncurses):" -e "s:libcurses="[^"]*":libcurses='$(use ncurses && $(tc-getPKG_CONFIG) --libs ncurses)':" configure || die
-------------------
 
Old 06-10-2017, 01:08 PM   #2
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,308
Blog Entries: 3

Rep: Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721
The normal delimiters for search and replace are slashes, as in s/// but they can be any character as long as they are three of a kind. So here you have s::: instead.

Then you have double quotes so that means the shell is interpreting the contents before passing them on to sed. That brings you to the command substitution indicated by $( ... )

Then the logical OR operator || means that if sed fails, then die will be run. Maybe die is a function defined earlier in the script. I'm not sure at all under which conditions sed would fail.

It also looks like a pair of double quotes needed to be escaped:

Code:
sed     -i \
        -e "s:enable_curses=[a-z]*:enable_curses=$(usex ncurses):" \
        -e "s:libcurses=\"[^"]*\":libcurses='$(use ncurses && $(tc-getPKG_CONFIG) --libs ncurses)':" \                                                         
        configure \                                                             
|| die
 
Old 06-10-2017, 01:11 PM   #3
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,848

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
what part is unclear?
Code:
sed    is the command
-i     inline editing, the processed file will be overwritten (see man page)
-e 'expression'  a sed script to execute
-e 'expression'  another one
configure        looks like a filename here
that's all
both expressions are:
s      substitute
:      separator
search string
:      separator
replacement
:
 
Old 06-10-2017, 01:18 PM   #4
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,779

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Quote:
Originally Posted by nobodino View Post
sed -i -e "s:enable_curses=[a-z]*:enable_curses=$(usex ncurses):" -e "s:libcurses="[^"]*":libcurses='$(use ncurses && $(tc-getPKG_CONFIG) --libs ncurses)':" configure || die
In the config file, where it finds "enable_curses=something" it replaces the "something" with the output from the "usex ncurses" command.

Where it finds "libcurses=something" it replaces the "something" with the output from the command string, "use ncurses && $(tc-getPKG_CONFIG) --libs ncurses", which presumably gives the installed version of the ncurses library.
 
Old 06-10-2017, 02:06 PM   #5
nobodino
Senior Member
 
Registered: Jul 2010
Location: Near Bordeaux in France
Distribution: slackware, slackware from scratch, LFS, slackware [arm], linux Mint...
Posts: 1,564

Original Poster
Rep: Reputation: 892Reputation: 892Reputation: 892Reputation: 892Reputation: 892Reputation: 892Reputation: 892
well I tried to use it in a 'slackware' script and it doesn't recognize 'usex ncurses' and 'use ncurses'?
 
Old 06-10-2017, 02:47 PM   #6
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,779

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Are you sure those functions are not defined somewhere above in the configure script, or perhaps in some file sourced by the configure script? If not, then that script was apparently intended for a build environment where those commands exist. Maybe there is a README file that tells what is required.
 
Old 06-10-2017, 06:13 PM   #7
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,057

Rep: Reputation: Disabled
Quote:
Originally Posted by nobodino View Post
well I tried to use it in a 'slackware' script and it doesn't recognize 'usex ncurses' and 'use ncurses'?
This is because you sed command is wrong. If I write it this way it works
Code:
sed -i \
-e 's:enable_curses=[a-z]*:enable_curses=$(usex ncurses):' \
-e 's:libcurses="[^"]*":libcurses=$(use ncurses && $(tc-getPKG_CONFIG) --libs ncurses):' configure || die
This is what it does:
Code:
didier[/storage/slackware64-14.2/source/ap/xfsdump/xfsdump-3.1.6]$ diff -u configure.orig configure
--- configure.orig      2017-06-11 00:57:10.177180799 +0200
+++ configure   2017-06-11 01:03:50.758182005 +0200
@@ -12795,7 +12795,7 @@
 
     { $as_echo "$as_me:${as_lineno-$LINENO}: checking for bad glibc/ncurses header interaction" >&5
 $as_echo_n "checking for bad glibc/ncurses header interaction... " >&6; }
-    libcurses="-lncurses"
+    libcurses=''
     LIBS="$LIBS $libcurses"
     CFLAGS="$CFLAGS -D_GNU_SOURCE"
     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -12812,10 +12812,10 @@
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  enable_curses=yes; { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5
+  enable_curses=$(usex ncurses); { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5
 $as_echo "ok" >&6; }
 else
-  enable_curses=no; libcurses=""; { $as_echo "$as_me:${as_lineno-$LINENO}: result: disabling curses" >&5
+  enable_curses=$(usex ncurses); libcurses=''; { $as_echo "$as_me:${as_lineno-$LINENO}: result: disabling curses" >&5
 $as_echo "disabling curses" >&6; }
 fi
 rm -f core conftest.err conftest.$ac_objext \
didier[/storage/slackware64-14.2/source/ap/xfsdump/xfsdump-3.1.6]$
But I am not sure it is the intended effect, and I don't understand why it is needed as in Slackware the package is built OK without it. Where does that come from? And why post that in the Gentoo forum if you try it on Slackware?
 
Old 06-11-2017, 01:33 AM   #8
nobodino
Senior Member
 
Registered: Jul 2010
Location: Near Bordeaux in France
Distribution: slackware, slackware from scratch, LFS, slackware [arm], linux Mint...
Posts: 1,564

Original Poster
Rep: Reputation: 892Reputation: 892Reputation: 892Reputation: 892Reputation: 892Reputation: 892Reputation: 892
Well, I'm trying to solve the xfdsdump building in slackware-current (for Slackware From Scratch), and for the time being, I've not found a way to solve it.
So I pick ideas and patches in every distribution (gentoo, debian, fedora, archlinux...) to try to solve the problem.

Thanks for you answer, I'll try to see if it solves my problem.
 
Old 06-11-2017, 01:45 AM   #9
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,057

Rep: Reputation: Disabled
Quote:
Originally Posted by nobodino View Post
Well, I'm trying to solve the xfdsdump building in slackware-current (for Slackware From Scratch), and for the time being, I've not found a way to solve it.
xfsdump builds fine on a regular Slackware 14.2 without any patch. That's all I know.

Quote:
So I pick ideas and patches in every distribution (gentoo, debian, fedora, archlinux...) to try to solve the
Applying blindly (not knowing what they do and why they are needed) patches at random out of context is a receipt for failure.

Good luck, though.

Last edited by Didier Spaier; 06-11-2017 at 01:59 AM.
 
Old 06-11-2017, 02:30 AM   #10
nobodino
Senior Member
 
Registered: Jul 2010
Location: Near Bordeaux in France
Distribution: slackware, slackware from scratch, LFS, slackware [arm], linux Mint...
Posts: 1,564

Original Poster
Rep: Reputation: 892Reputation: 892Reputation: 892Reputation: 892Reputation: 892Reputation: 892Reputation: 892
You're right it builds fine in stable (14.2), not in -current.
I didn't say anything else.

ThanXX
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
SED command failing while substituting variable with error unterminated `s' command vnarvankar Linux - Software 2 03-10-2016 09:10 AM
Sed substitution gives error "sed: command garbled" gsai0205 Linux - Newbie 3 09-13-2013 09:01 AM
[SOLVED] sed gives :sed: -e expression #1, char 1: unknown command: `'' samasat Linux - Newbie 10 06-09-2012 05:31 PM
[SOLVED] sed help to run sed command against multiple different file names bkone Programming 2 04-16-2012 12:27 PM
Sed command - command garbled errror gauavmahesh Linux - Newbie 3 03-30-2012 10:04 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Gentoo

All times are GMT -5. The time now is 04:14 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration