DaemonForums  

Go Back   DaemonForums > OpenBSD > OpenBSD General

OpenBSD General Other questions regarding OpenBSD which do not fit in any of the categories below.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 18th August 2017
shep shep is offline
Real Name: Scott
Arp Constable
 
Join Date: May 2008
Location: Dry and Dusty
Posts: 1,507
Default Wading through sed and re_format

I'm trying to update x11/tint2 and have the basic port almost ready to go.
Where I am hung up is that upstream has provided multiple rc configuration files that contain multiple Launcher paths; ie /usr/share/applications/tint2conf.desktop and /usr/share/applications/firefox.desktop. The 12.2 source had these in a "sample" directory which in the interim has been renamed "themes". In 12.2, @sthen added a post-intall sed command to edit all the examples

Code:
 post-install:
        cp -R ${WRKSRC}/sample/ ${PREFIX}/share/examples/tint2/
        sed -i -e '/\/usr\/local\/share\/applications/d' -e \
            's,/usr/share/applications,${LOCALBASE}/share/applications,g' \
            ${PREFIX}/share/examples/tint2/*tint2rc
        rm ${PREFIX}/share/tint2/*.tint2rc
I'm trying to wade through this
In the above code does the cp -R command stream into the sed command on the next line?
I understand -i is "inplace" and -e appends /\/usr\/local\/share\/applications/d' to the next command. I'm guessing that .../applications/d' "deletes the pattern space and starts the next cycle which then replaces /usr/share/applications with ${LOCALEBASE}/share/applications,g
Code:
 [2addr]g
             Replace the contents of the pattern space with the contents of
             the hold space.
I'm not sure why "-e" is used twice on the sed line.
So I modified the post-install command to
Code:
post-install:
       sed -i -e '/\/usr\/local\/share\/applications/d' -e \
            's,/usr/share/applications,${LOCALBASE}/share/applications,g' \
            ${PREFIX}/share/examples/tint2/*tint2rc
When I try to make fake, I get an error
***Parse Error in /usr/ports/x11/tint2: Need operator in '/share/examples/tint2/*tint2rc.

sed(1) and re_format(7) are not easy reading. Both the FreeBSD(v0.14.5) and NetBSD(v0.14.6) did not address this.

Any guidance appreciated.
Reply With Quote
  #2   (View Single Post)  
Old 19th August 2017
TronDD TronDD is offline
Spam Deminer
 
Join Date: Sep 2014
Posts: 305
Default

Quote:
Originally Posted by shep View Post
Code:
 post-install:
        cp -R ${WRKSRC}/sample/ ${PREFIX}/share/examples/tint2/
        sed -i -e '/\/usr\/local\/share\/applications/d' -e \
            's,/usr/share/applications,${LOCALBASE}/share/applications,g' \
            ${PREFIX}/share/examples/tint2/*tint2rc
        rm ${PREFIX}/share/tint2/*.tint2rc
In the above code does the cp -R command stream into the sed command on the next line?
No. Newline terminates a command unless you end the line with a \ an no trialing white space.

Quote:
I understand -i is "inplace" and -e appends /\/usr\/local\/share\/applications/d' to the next command.
-e appends the command to the list of commands to execute. Just think of it as telling to sed to "do this thing". You can use multiple -e parameters to tell sed to do multiple things in one invocation of sed.

Quote:
I'm guessing that .../applications/d' "deletes the pattern space and starts the next cycle which then replaces /usr/share/applications with ${LOCALEBASE}/share/applications,g
Code:
 [2addr]g
             Replace the contents of the pattern space with the contents of
             the hold space.
The commands are:
(d)elete the matched pattern
(S)ubstitute the matched pattern with the following string (g)lobally (everywhere it's found, otherwise sed stops at the first match)
And the last part is the input files.

Quote:
I'm not sure why "-e" is used twice on the sed line.
To do multple commands in one invocation

Quote:
So I modified the post-install command to
Code:
post-install:
       sed -i -e '/\/usr\/local\/share\/applications/d' -e \
            's,/usr/share/applications,${LOCALBASE}/share/applications,g' \
            ${PREFIX}/share/examples/tint2/*tint2rc
When I try to make fake, I get an error
***Parse Error in /usr/ports/x11/tint2: Need operator in '/share/examples/tint2/*tint2rc.
Since you took out the cp command, there might not be any matching files in share/examples/tint2. You can go look at the files from 'make fake' in ports/pobj/tint2/fake-$(uname -m)

Although "needs operator" looks like something else. Make sure you don't have whitespace after a \ at the end of a line.
Reply With Quote
  #3   (View Single Post)  
Old 19th August 2017
shep shep is offline
Real Name: Scott
Arp Constable
 
Join Date: May 2008
Location: Dry and Dusty
Posts: 1,507
Default

Code:
make fake
generates the Parse error, If I comment out the post-install entry, it proceeds fine. Highlighting the code did not show any trailing white spaces.

x11/tint2 uses CMake and the install directories are listed in a CMakeLists.txt file. The default is to install all the example rc files in /etc/xdg/tint2 which is an OpenBSD no-no. I patched the CMakeLists.txt file to install all the rc files in /usr/local/share/examples/tint2/ and then used @sample in PLIST to generate /etc/xdg/tint2/tint2rc.

It looks like the port is error checked prior to the patch that puts tint2rc + examples in /usr/local/share/examples/tint2.

Is it possible to run sed on the original source code themes directory? Looking at the porters handbook, there is a post-extract stage. Would a post-extract entry allow me to run the sed on WRKDIST?

Thanks

Last edited by shep; 19th August 2017 at 02:23 AM.
Reply With Quote
  #4   (View Single Post)  
Old 20th August 2017
ibara ibara is offline
OpenBSD language porter
 
Join Date: Jan 2014
Posts: 783
Default

I'm guessing this is where we left off on ports@...

Quote:
Originally Posted by shep View Post
I'm trying to update x11/tint2 and have the basic port almost ready to go.
If this is the original post-install:
Quote:
Originally Posted by shep View Post
Code:
post-install:
        cp -R ${WRKSRC}/sample/ ${PREFIX}/share/examples/tint2/
        sed -i -e '/\/usr\/local\/share\/applications/d' -e \
            's,/usr/share/applications,${LOCALBASE}/share/applications,g' \
            ${PREFIX}/share/examples/tint2/*tint2rc
        rm ${PREFIX}/share/tint2/*.tint2rc
Then, assuming the only significant change is the name of the directory from sample to themes, all you have to do is change the first line:
Code:
post-install:
        cp -R ${WRKSRC}/themes/ ${PREFIX}/share/examples/tint2/
        sed -i -e '/\/usr\/local\/share\/applications/d' -e \
            's,/usr/share/applications,${LOCALBASE}/share/applications,g' \
            ${PREFIX}/share/examples/tint2/*tint2rc
        rm ${PREFIX}/share/tint2/*.tint2rc
Reply With Quote
  #5   (View Single Post)  
Old 20th August 2017
shep shep is offline
Real Name: Scott
Arp Constable
 
Join Date: May 2008
Location: Dry and Dusty
Posts: 1,507
Default

I understood that samples needed to be renamed themes. Initially I had edited the CMakeLists.txt file to directly install the themes into /usr/local/share/examples/tint2. Thought the 1st post-install line was redundant at that point and removed it. I still don't understand it but trying to execute any command like
Quote:
make clean
would generate the error about the lack of an operator
when the 1st line was missing.

I did end up modifying the CMakeLists.txt patch and reverting the post-install message but it did seem a little messy to copy ${WRKSRC}/themes to /usr/local/share/examples/tint2/ followed by deleting /usr/local/share/tint2/*.tint2rc. The CMakeList.txt patch just installed them directly.
Reply With Quote
  #6   (View Single Post)  
Old 21st August 2017
TronDD TronDD is offline
Spam Deminer
 
Join Date: Sep 2014
Posts: 305
Default

Quote:
Originally Posted by shep View Post
It looks like the port is error checked prior to the patch that puts tint2rc + examples in /usr/local/share/examples/tint2.
Patching happens right after extracting the source. And you can run up to any point in the process you need. bsd.port.mk(5) is the man page to look at.

Quote:
I did end up modifying the CMakeLists.txt patch and reverting the post-install message but it did seem a little messy to copy ${WRKSRC}/themes to /usr/local/share/examples/tint2/ followed by deleting /usr/local/share/tint2/*.tint2rc. The CMakeList.txt patch just installed them directly.
It's usually easier to maintain the Makefile and a cp command than to maintain a patch. Any time they change CMakeLists.txt file, the patch may need to be updated. The Makefile will need to change only if they change the path again.
Reply With Quote
  #7   (View Single Post)  
Old 21st August 2017
shep shep is offline
Real Name: Scott
Arp Constable
 
Join Date: May 2008
Location: Dry and Dusty
Posts: 1,507
Default

With the 1st post-install line removed, any make * command died with the warning about sed not having an operator. With the 1st post-install line intact, make * commands executed.

By default, /usr/local/share/tint2/ contains a default configuration: tint2rc, multiple example configurations: *.tint2rc and an svg icon. The themes directory in the source contains tint2rc + *.tint2rc + a second CMakeLists.txt file. The goal is to get tint2rc in /etc/xdg/tint2/ and ${PREFIX}/share/examples/tint2, the *.tint2rc in ${PREFIX}/share/examples/tint2, leave the *svg icon in /usr/local/share/tint2/ and lose the CMakeLists.txt file

A simple edit to 1st (Upper) CMakeLists.txt + PLIST @sample + no post-install resulted in everything in the right place, The problem with that approach is I could not get the sed command to run.
Reply With Quote
Reply

Thread Tools
Display Modes

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 On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:14 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick