Page MenuHomeFreeBSD

bump-revision.sh: Make adding PORTREVISION to a file work.
AbandonedPublic

Authored by rakuco on Mar 11 2016, 2:08 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Feb 8, 2:13 AM
Unknown Object (File)
Nov 24 2025, 2:20 PM
Unknown Object (File)
Nov 17 2025, 12:34 AM
Unknown Object (File)
Nov 7 2025, 5:49 AM
Unknown Object (File)
Nov 2 2025, 2:24 AM
Unknown Object (File)
Oct 23 2025, 6:21 PM
Unknown Object (File)
Sep 17 2025, 3:48 PM
Unknown Object (File)
Aug 15 2025, 3:36 PM
Subscribers

Details

Reviewers
robak
Summary

Adding PORTREVISION to a port that has none is currently broken: the check for $? currently retrieves the return value of the echo + awk call, which is not what we want. Instead, check for the return value of the grep call and set revision_num only if a PORTREVISION value has been found.

Test Plan

./Tools/scripts/bump-revision.sh x11/libkonq works instead of throwing an error saying _ERROR: x11/libkonq PORTREVISION value is not a number, unable to solve!_.

Diff Detail

Repository
rP FreeBSD ports repository
Lint
No Lint Coverage
Unit
No Test Coverage
Build Status
Buildable 2855
Build 2879: arc lint + arc unit

Event Timeline

rakuco retitled this revision from to bump-revision.sh: Make adding PORTREVISION to a file work..
rakuco updated this object.
rakuco edited the test plan for this revision. (Show Details)
rakuco added a reviewer: robak.

Checking $? in a shell script is an anti-pattern, it should be more something like:

if grep -q "^PORTREVISION?\?=" "$1/Makefile
then
  # do something if it is there
else
  # do something else if not
fi

And then, you can use set -e to fail on real errors and all.

What if you're also interested in grep's output? Can you do that without repeating the grep call? Also, would it be OK for you if this was done separately to keep the changes separate?

Let me review it, and I'll leave my comments - I was quite busy at the time when this revision was created, and afterwards I forgot about it.

Hey, your example works just fine for me, as it is:

[root@pd]❯❯❯ ./Tools/scripts/bump-revision.sh x11/libkonq                                                                                                                                                                                                                                            
INFO: x11/libkonq PORTREVISION= 1 found, bumping it by 1.
[root@pd]❯❯❯

Can you reproduce it? Can you provide another example that you have failing?

For a reference, here's set of 'problematic' ports we've used in past to debug and test the code with:

[root@pd]❯❯❯ sh Tools/scripts/bump-revision.sh net/vmware-vsphere-cli security/p5-Net-SinFP accessibility/atk converters/ruby-iconv comms/concordance mail/opendkim                                                                                                                                  
INFO: net/vmware-vsphere-cli PORTREVISION= 3 found, bumping it by 1.
ERROR: security/p5-Net-SinFP PORTREVISION found more than once, unable to bump it reliably!
INFO: accessibility/atk PORTREVISION= 0 found, bumping it by 1.
ERROR: converters/ruby-iconv might not be a port directory because converters/ruby-iconv/Makefile is missing!
INFO: comms/concordance PORTREVISION= 1 found, bumping it by 1.
INFO: mail/opendkim PORTREVISION= 5 found, bumping it by 1.
[root@pd]❯❯❯
In D5609#125842, @robak wrote:

Hey, your example works just fine for me, as it is:

That's because x11/libkonq has had its PORTREVISION bumped since I posted this patch.

Try any port that has no PORTREVISION line, such as devel/zeal which I added today to the tree, and the bug still occurs.

/s/freebsd/ports-svn % /usr/ports/Tools/scripts/bump-revision.sh devel/zeal
ERROR: devel/zeal PORTREVISION value is not a number, unable to solve!

The bug ended up being fixed independently in rP419519.