<div dir="ltr">[Update]: I have built a workable python cli package known as 'pycli' <br><div>which works as an alternative for 'sed'. </div><div><br></div><div>I made the following changes in the config file: </div><div><br></div><div>diff --git a/source-builder/config/epics-7-1.cfg b/source-builder/config/epics-7-1.cfg<br>index f51c658..6408534 100644<br>--- a/source-builder/config/epics-7-1.cfg<br>+++ b/source-builder/config/epics-7-1.cfg<br>@@ -34,12 +34,11 @@ URL: <a href="https://epics.mpg.de/">https://epics.mpg.de/</a><br> #<br> # Changing the RTEMS Version in epics-base/configure/os/CONFIG_SITE.Common.RTEMS<br> #<br>-sed -i 's/RTEMS_VERSION = .*/RTEMS_VERSION = 5/g' configure/os/CONFIG_SITE.Common.RTEMS<br>+pycli 'RTEMS_VERSION = .*' 'RTEMS_VERSION = 5' configure/os/CONFIG_SITE.Common.RTEMS<br> <br> #<br> # Changing the RTEMS Base in epics-base/configure/os/CONFIG_SITE.Common.RTEMS<br>-#<br>-sed -i "s/^RTEMS_BASE .*/RTEMS_BASE = \/home\/mritunjay\/development\/rtems\/\$\(RTEMS_VERSION\)\-arm/g" configure/os/CONFIG_SITE.Common.RTEMS<br>+pycli '^RTEMS_BASE .*' 'RTEMS_BASE = /home/mritunjay/development/rtems/$(RTEMS_VERSION)-arm/' configure/os/CONFIG_SITE.Common.RTEMS<br> <br> cd ${build_top}<br> <br>diff --git a/source-builder/config/spike-1-1.cfg b/source-builder/config/spike-1-1.cfg<br>index e731348..aff3f35 100644<br>--- a/source-builder/config/spike-1-1.cfg<br>+++ b/source-builder/config/spike-1-1.cfg<br>@@ -3,7 +3,7 @@<br> #<br> # This configuration file configure's, make's and install's RISC-V's spike simulator.<br> #<br>-<br>+%define spike_version 01252686902fa30665fbecfc1476d169ad1333d1<br> %if %{release} == %{nil}<br> %define release 1<br> %endif<br></div><div><br></div><div>This worked successfully and the build ran fine. I am going to upload the entire python pycli project on the github in a couple of hours. </div><div><br></div><div>The main part of the python script that did the work is here: </div><div><br></div><div>'''import re<br><br>def replace(oldstring, newstring, infile, dryrun=False):<br> '''<br> Sed-like Replace<br> Usage: pycli <Old string> <Replacement String> <Text File><br> Example: pycli 'xyz' 'XYZ' '/path/to/file.txt'<br> '''<br> linelist = []<br> with open(infile) as f:<br> for item in f:<br> newitem = re.sub(oldstring, newstring, item)<br> linelist.append(newitem)<br> if dryrun == False:<br> with open(infile, "w") as f:<br> f.truncate()<br> for line in linelist: f.writelines(line)<br> elif dryrun == True:<br> for line in linelist: print(line, end='')<br> else:<br> exit("Unknown option specified to 'dryrun' argument, Usage: dryrun=<True|False>.")'''<br></div><div><br></div><div>Please do give the feedback if this has been done in the right way?</div><div><br></div><div>Thanks</div><div>Mritunjay Sharma</div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Aug 14, 2020 at 3:13 AM Mritunjay Sharma <<a href="mailto:mritunjaysharma394@gmail.com">mritunjaysharma394@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hello everyone,<br><div><br></div><div>Based on the input received by Gedare, I have started working </div><div>on finding a 'sed' alternative to be used in the RSB recipes to </div><div>do streamline text replacements. </div><div><br></div><div>I have gone through the Python Development Guidelines (<a href="https://docs.rtems.org/branches/master/eng/python-devel.html" target="_blank">https://docs.rtems.org/branches/master/eng/python-devel.html</a>)</div><div>and have installed the things suggested in this for the development</div><div>environment. </div><div><br></div><div>To start with the research work, I found this interesting</div><div>the discussion here <a href="https://unix.stackexchange.com/questions/13711/differences-between-sed-on-mac-osx-and-other-standard-sed" target="_blank">https://unix.stackexchange.com/questions/13711/differences-between-sed-on-mac-osx-and-other-standard-sed</a> that gave me an idea</div><div>on how sed differs in BSD and UNIX platforms.</div><div><br></div><div>I learnt about differences like: </div><div>`OS X's sed uses -E for ERE and GNU sed uses -r. -E is an alias for -r in GNU sed (added in 4.2, not documented until 4.3). Newer versions of FreeBSD and NetBSD sed support both -E and -r. OpenBSD sed only supports -E.</div><div>`</div><div><br></div><div>I also found a similar project <a href="https://github.com/chmln/sd" target="_blank">https://github.com/chmln/sd</a> which can help us in</div><div>developing the Python code needed in our case. </div><div><br></div><div>I would request the mentors to guide me on how and where to begin from </div><div>in writing this alternative?</div><div>Where do I have to write it? Is it the rtems-tools project (<a href="https://github.com/RTEMS/rtems-tools" target="_blank">https://github.com/RTEMS/rtems-tools</a>) where I have to contribute to for building this alternative?</div><div><br></div><div>Thanks</div><div>Mritunjay Sharma </div></div>
</blockquote></div>