public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] repoman and checking for correct quoting
@ 2007-11-10 10:51 Krzysiek Pawlik
  2007-11-10 17:10 ` Zac Medico
  2007-11-10 17:36 ` Bo Ørsted Andresen
  0 siblings, 2 replies; 7+ messages in thread
From: Krzysiek Pawlik @ 2007-11-10 10:51 UTC (permalink / raw
  To: Gentoo Dev

[-- Attachment #1: Type: text/plain, Size: 761 bytes --]


Consider following part of scite-1.74.ebuild:

	sed -i makefile \
		-e 's#usr/local#usr#g' \
		-e 's#/gnome/apps/Applications#/applications#' \
		-e "s#^CXXFLAGS=#CXXFLAGS=${CXXFLAGS} #" \
		-e "s#^\(CXXFLAGS=.*\)-Os#\1#" \
		-e "s#^CC =\(.*\)#CC = $(tc-getCXX)#" \
		-e 's#${D}##' \
		-e 's#-g root#-g 0#' \
		|| die "error patching makefile"

`repoman full' catches line "-e 's#${D}##' \":

   app-editors/scite/scite-1.74.ebuild: Unquoted Variable on line: 41

It's purpose is to remove the ${D} from makefile, additionally ${D} is in single
quotes, so it will not be expanded - is it a bug in repoman check?

-- 
Krzysiek Pawlik   <nelchael at gentoo.org>   key id: 0xBC555551
desktop-misc, desktop-dock, x86, java, apache, ppc...


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 252 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [gentoo-dev] repoman and checking for correct quoting
  2007-11-10 10:51 [gentoo-dev] repoman and checking for correct quoting Krzysiek Pawlik
@ 2007-11-10 17:10 ` Zac Medico
  2007-11-10 17:36 ` Bo Ørsted Andresen
  1 sibling, 0 replies; 7+ messages in thread
From: Zac Medico @ 2007-11-10 17:10 UTC (permalink / raw
  To: gentoo-dev

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Krzysiek Pawlik wrote:
> Consider following part of scite-1.74.ebuild:
> 
> 	sed -i makefile \
> 		-e 's#usr/local#usr#g' \
> 		-e 's#/gnome/apps/Applications#/applications#' \
> 		-e "s#^CXXFLAGS=#CXXFLAGS=${CXXFLAGS} #" \
> 		-e "s#^\(CXXFLAGS=.*\)-Os#\1#" \
> 		-e "s#^CC =\(.*\)#CC = $(tc-getCXX)#" \
> 		-e 's#${D}##' \
> 		-e 's#-g root#-g 0#' \
> 		|| die "error patching makefile"
> 
> `repoman full' catches line "-e 's#${D}##' \":
> 
>    app-editors/scite/scite-1.74.ebuild: Unquoted Variable on line: 41
> 
> It's purpose is to remove the ${D} from makefile, additionally ${D} is in single
> quotes, so it will not be expanded - is it a bug in repoman check?

Yes, it seems like we need to add an exemption for variables inside
single quotes like that.

Zac
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)

iD8DBQFHNeYL/ejvha5XGaMRAkpqAJ4tQzDDhcRbfFFqbYhGM3jm+iO6ZACfdovW
+1DwScsWViapX7BJnD10lAM=
=BBQu
-----END PGP SIGNATURE-----
-- 
gentoo-dev@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [gentoo-dev] repoman and checking for correct quoting
  2007-11-10 10:51 [gentoo-dev] repoman and checking for correct quoting Krzysiek Pawlik
  2007-11-10 17:10 ` Zac Medico
@ 2007-11-10 17:36 ` Bo Ørsted Andresen
  2007-11-10 17:50   ` [gentoo-dev] to patch or sed was -> " William L. Thomson Jr.
  1 sibling, 1 reply; 7+ messages in thread
From: Bo Ørsted Andresen @ 2007-11-10 17:36 UTC (permalink / raw
  To: gentoo-dev

On Sat, Nov 10, 2007 at 11:51:37AM +0100, Krzysiek Pawlik wrote:
> It's purpose is to remove the ${D} from makefile, additionally ${D} is in single
> quotes, so it will not be expanded - is it a bug in repoman check?

What ${D} ? I see none in that makefile. Which is why I think a patch would be 
better in this case. A patch would actually tell you when half of the
substitutions don't match anything... I think this is a point worth making even
if it doesn't change your point.

-- 
Bo Andresen
-- 
gentoo-dev@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [gentoo-dev] to patch or sed was -> repoman and checking for correct quoting
  2007-11-10 17:36 ` Bo Ørsted Andresen
@ 2007-11-10 17:50   ` William L. Thomson Jr.
  2007-11-10 19:45     ` [gentoo-dev] " Ryan Hill
  2007-11-11 10:47     ` Steve Long
  0 siblings, 2 replies; 7+ messages in thread
From: William L. Thomson Jr. @ 2007-11-10 17:50 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 2156 bytes --]


On Sat, 2007-11-10 at 18:36 +0100, Bo Ørsted Andresen wrote:
> On Sat, Nov 10, 2007 at 11:51:37AM +0100, Krzysiek Pawlik wrote:
> > It's purpose is to remove the ${D} from makefile, additionally ${D} is in single
> > quotes, so it will not be expanded - is it a bug in repoman check?
> 
> What ${D} ? I see none in that makefile. Which is why I think a patch would be 
> better in this case. A patch would actually tell you when half of the
> substitutions don't match anything... I think this is a point worth making even
> if it doesn't change your point.

I have kinda gone back and forth between patches and sed. While I agree
patches are better since they fail to apply at times. Sed stuff can be
more portable amongst revisions, as I have found with maintaining assp.
Where the patch grew to the point it had to be mirrored :(.

Now I know some will scream, puke, throw up in their mouth, and so on.
But seems like sed should have an OPTIONAL argument or etc to tell sed
to either fail if it can't make the change anywhere. And/or keep/output
a count of how many things were modified.

Wrt to assp, how I am presently using it, is on a rev bump or etc. I
will have to ebuild run it's sed. Then I will diff the installed version
that was sed during merge with the original. Then review that diff/patch
to make sure all was modified per the sed. If not address the sed. Once
the resulting diff/patch is what it would be if I were using a patch.
Then I commit the ebuild.

Where I had to make a patch per assp version. The above technique
allowed me to rip through testing 3 different versions with the same sed
for each. Verses having to make 3 different patches for each. It seems
much faster and way more ideal.

There is still the possibility of sed failing. But since I rule that out
before commit. Once committed chance of it failing is pretty nill. Not
to mention no external files. Less to maintain. less for users to sync,
download, etc.

It's a really hard call, but for most single line modifications. These
days I am really leaning toward sed vs patches.

-- 
William L. Thomson Jr.
Gentoo/Java

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [gentoo-dev]  Re: to patch or sed was -> repoman and checking for   correct quoting
  2007-11-10 17:50   ` [gentoo-dev] to patch or sed was -> " William L. Thomson Jr.
@ 2007-11-10 19:45     ` Ryan Hill
  2007-11-10 22:17       ` William L. Thomson Jr.
  2007-11-11 10:47     ` Steve Long
  1 sibling, 1 reply; 7+ messages in thread
From: Ryan Hill @ 2007-11-10 19:45 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 1420 bytes --]

William L. Thomson Jr. wrote:

> Now I know some will scream, puke, throw up in their mouth, and so on.
> But seems like sed should have an OPTIONAL argument or etc to tell sed
> to either fail if it can't make the change anywhere. And/or keep/output
> a count of how many things were modified.

you could use the w flag to the s command.

 `w FILE-NAME'
      If the substitution was made, then write out the result to the
      named file.  As a GNU `sed' extension, two special values of
      FILE-NAME are supported: `/dev/stderr', which writes the result to
      the standard error, and `/dev/stdout', which writes to the standard
      output.(1)

dirtyepic@tycho ~/tmp $ cat test
this is a test: 12345
line 2
line 3
line 4: 12345
dirtyepic@tycho ~/tmp $ sed -i -e 's:12345:54321:w sed.log' test
dirtyepic@tycho ~/tmp $ cat test
this is a test: 54321
line 2
line 3
line 4: 54321
dirtyepic@tycho ~/tmp $ cat sed.log
this is a test: 54321
line 4: 54321
dirtyepic@tycho ~/tmp $ sed -i -e 's:12345:54321:w sed.log' test
dirtyepic@tycho ~/tmp $ cat sed.log
dirtyepic@tycho ~/tmp $

or

dirtyepic@tycho ~/tmp $ sed -i -e 's:12345:54321:w /dev/stdout' test | wc -l
2

-- 
                        looks like christmas at fifty-five degrees
                                    this latitude weakens my knees
    EFFD 380E 047A 4B51 D2BD  C64F 8AA8 8346 F9A4 0662 (0xF9A40662)


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [gentoo-dev]  Re: to patch or sed was -> repoman and checking for  correct quoting
  2007-11-10 19:45     ` [gentoo-dev] " Ryan Hill
@ 2007-11-10 22:17       ` William L. Thomson Jr.
  0 siblings, 0 replies; 7+ messages in thread
From: William L. Thomson Jr. @ 2007-11-10 22:17 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 620 bytes --]


On Sat, 2007-11-10 at 13:45 -0600, Ryan Hill wrote:
> William L. Thomson Jr. wrote:
> 
> > Now I know some will scream, puke, throw up in their mouth, and so on.
> > But seems like sed should have an OPTIONAL argument or etc to tell sed
> > to either fail if it can't make the change anywhere. And/or keep/output
> > a count of how many things were modified.
> 
> you could use the w flag to the s command.

Nice I will have to play around with that, but surely could make a test
that would work to confirm sed did it's job.

Down with patches, up with sed :)

-- 
William L. Thomson Jr.
Gentoo/Java

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [gentoo-dev]  Re: to patch or sed was -> repoman and checking for correct quoting
  2007-11-10 17:50   ` [gentoo-dev] to patch or sed was -> " William L. Thomson Jr.
  2007-11-10 19:45     ` [gentoo-dev] " Ryan Hill
@ 2007-11-11 10:47     ` Steve Long
  1 sibling, 0 replies; 7+ messages in thread
From: Steve Long @ 2007-11-11 10:47 UTC (permalink / raw
  To: gentoo-dev

William L. Thomson Jr. wrote:
> On Sat, 2007-11-10 at 18:36 +0100, Bo Ørsted Andresen wrote:
>> On Sat, Nov 10, 2007 at 11:51:37AM +0100, Krzysiek Pawlik wrote:
>> > It's purpose is to remove the ${D} from makefile, additionally ${D} is
>> > in single quotes, so it will not be expanded - is it a bug in repoman
>> > check?
>> 
>> What ${D} ? I see none in that makefile. Which is why I think a patch
>> would be better in this case. A patch would actually tell you when half
>> of the substitutions don't match anything... I think this is a point
>> worth making even if it doesn't change your point.
> 
> I have kinda gone back and forth between patches and sed. While I agree
> patches are better since they fail to apply at times. Sed stuff can be
> more portable amongst revisions, as I have found with maintaining assp.
> Where the patch grew to the point it had to be mirrored :(.
> 
> Now I know some will scream, puke, throw up in their mouth, and so on.
> But seems like sed should have an OPTIONAL argument or etc to tell sed
> to either fail if it can't make the change anywhere. And/or keep/output
> a count of how many things were modified.
> 
ed does this by default (which can make it trickier) -- if a standard search
and replace doesn't match, it's considered an error. I appreciate ed isn't
currently part of system set, but imo it should be, since it's specified in
posix. A workaround is grep -q, eg:

if grep -qF '${D}' file; then
        sed -i '#\${D}##' file
fi

(You need to escape $ in a regex or it'll be treated as end marker.) This is
more useful in cases where you need to know what is in the file for
whatever reason (eg grep -q '^FEATURES="[^"]*-blah' /etc/make.conf [1]),
since the sed will not affect the file if there is no match.

Of course, repoman still needs to ignore stuff in single quotes.

[1] if ! grep -qF sandbox < <(portageq envvar FEATURES); then .. (for
example) is safer for general case.


-- 
gentoo-dev@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2007-11-11 10:46 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-10 10:51 [gentoo-dev] repoman and checking for correct quoting Krzysiek Pawlik
2007-11-10 17:10 ` Zac Medico
2007-11-10 17:36 ` Bo Ørsted Andresen
2007-11-10 17:50   ` [gentoo-dev] to patch or sed was -> " William L. Thomson Jr.
2007-11-10 19:45     ` [gentoo-dev] " Ryan Hill
2007-11-10 22:17       ` William L. Thomson Jr.
2007-11-11 10:47     ` Steve Long

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox