Opened 6 years ago

Closed 5 years ago

#2860 closed bug (fixed)

script doesn't recognize svn revision

Reported by: Adek336 Owned by: bonefish
Priority: normal Milestone: R1
Component: Build System Version: R1/pre-alpha1
Keywords: Cc: planche2k@…
Blocked By: Blocking:
Has a Patch: no Platform: All

Description

Because of the fact the svn hangs in Haiku (#2840), I used Debian to svn checkout the sources and Haiku to copy them to a BFS partition and to jam them.
Unfortunately

AddSymlinkToContainerCopyFilesScript <HaikuImage>beos/system/add-ons/kernel/drivers/dev/net/syskonnect 
AddSymlinkToContainerCopyFilesScript <HaikuImage>beos/system/add-ons/kernel/drivers/dev/net/usb_ecm 
CopySetHaikuRevision1 generated/objects/haiku/x86/release/system/kernel/revisioned/kernel_x86 
Usage: set_haiku_revision  <file> <revision>

Finds the haiku revision section in ELF object file <file> and replaces the
writes the number given by <revision> into the first 32 bits of the
section.


revision=`(LC_ALL=C LANG=C svn info . 2> /dev/null ||
(cd . && LC_ALL=C LANG=C git svn info) 2> /dev/null ||
(git log --max-count=1 --grep="git-svn-id:" 2> /dev/null |
grep git-svn-id: | cut -d '@' -f 2 |
awk '{printf "Revision: " $1}') 2> /dev/null ||
echo Revision: 0) |
grep Revision | awk '{printf $2}'`
generated/objects/haiku_host/x86/release/tools/copyattr --data generated/objects/haiku/x86/release/system/kernel/kernel_x86 generated/objects/haiku/x86/release/system/kernel/revisioned/kernel_x86 &&
generated/objects/haiku_host/x86/release/tools/set_haiku_revision generated/objects/haiku/x86/release/system/kernel/revisioned/kernel_x86 ${revision}

...failed CopySetHaikuRevision1 generated/objects/haiku/x86/release/system/kernel/revisioned/kernel_x86 ...
...removing generated/objects/haiku/x86/release/system/kernel/revisioned/kernel_x86
...skipped <HaikuImage>haiku.image-copy-files-dummy-beos/system for lack of <revisioned>kernel_x86...

I believe it is a problem with build/jam/FileRules

        revision=`(LC_ALL=C LANG=C svn info $(HAIKU_TOP) 2> /dev/null ||
                (cd $(HAIKU_TOP) && LC_ALL=C LANG=C git svn info) 2> /dev/null ||
                (git log --max-count=1 --grep="git-svn-id:" 2> /dev/null |
                        grep git-svn-id: | cut -d '@' -f 2 |
                        awk '{printf "Revision: " $1}') 2> /dev/null ||
                echo Revision: 0) |
                grep Revision | awk '{printf $2}'`

This is related to the fact that svn cannot find out the revision number

/haiku-dane/haiku> svn info 
svn: This client is too old to work with working copy '.'; please get a newer Subversion client

the script then tries to ask git for the revision number. And git fails as I don't use nor have it

/haiku-dane/haiku> git
sh: git: command not found

but the script doesn't then fall back to revision=0; scenario:

/haiku-dane/haiku> no_such_command
sh: no_such_command: command not found
/haiku-dane/haiku> ((no_such_command) 2> /dev/null )
/haiku-dane/haiku> echo $?
127
/haiku-dane/haiku> ((no_such_command | awk '{printf "Revision: " $1}') 2> /dev/null )
/haiku-dane/haiku> echo $?
0

Expected behaviour: it should fail on getting the revision from both svn and git and fall back to revision=0.

As a note, I was able to do so (check out on Debian, build on Haiku, with svn versions incompatible) just about 2 weeks ago.

Attachments (1)

0001-Fix-extracting-revision-number-with-git-svn.patch (1.8 KB) - added by andreasf 5 years ago.
Proposed patch

Download all attachments as: .zip

Change History (10)

comment:1 Changed 6 years ago by andreasf

  • Cc andreas.faerber@… added

comment:2 Changed 6 years ago by andreasf

My git patch was a quick addition to get the revision number displayed. A better solution might be to split up the command, e.g. (pseudocode)

revision=`(svn info || git svn info || other-svn-info-compatible-VCS || echo "Revision: 0") | grep Revision | awk ...`
if (revision == "0")
    revision=`git log ... | echo 0` # try git without git-svn
if (revision == "0")
    revision=... # try Mercurial/Bazaar/your-favorite-VCS

That would avoid that use of awk to put it into the Revision: nnnnn format to later extract it again.

comment:3 follow-ups: Changed 6 years ago by bonefish

  • Resolution set to fixed
  • Status changed from new to closed

Fixed in hrev28226.

comment:4 in reply to: ↑ 3 Changed 5 years ago by andreasf

  • Resolution fixed deleted
  • Status changed from closed to reopened

Unfortunately this fix broke the original git svn info code path by not extracting the correct piece of information like from svn info. Patch coming up shortly.

Changed 5 years ago by andreasf

Proposed patch

comment:5 in reply to: ↑ 3 Changed 5 years ago by andreasf

When git-svn was in fact usable, the whole svn info-like output was stored in $revision. The final if doesn't check for a sane numeric value, and no revision information was displayed in AboutSystem.

The attached patch reunifies svn and git-svn to share the postprocessing (grep, awk).

If both fail, $revision should be empty, triggering Ingo's if and my pure git fallback. Failing that as well, $revision should be empty once again and thus set to 0, still fixing #2860.

comment:6 Changed 5 years ago by andreasf

  • Cc planche2k@… added

Ping: Could someone please review the attached patch? Thanks!

comment:7 follow-up: Changed 5 years ago by axeld

Rene or Ryan, aren't you both using git? Can either of you please have a look?

comment:8 in reply to: ↑ 7 Changed 5 years ago by andreasf

  • Cc andreas.faerber@… removed

@Axel: Since the original hrev26977 patch was mine, you could trust me that the Git part is okay! ;) What I do not have a setup for, is a build without git.

The ticket reporter or anyone else with a non-svn, non-git setup should have a look.

Or commit it after reviewing that it doesn't affect regular svn users, and let people reopen later if necessary - the current svn state is a regression.

comment:9 Changed 5 years ago by axeld

  • Resolution set to fixed
  • Status changed from reopened to closed

Applied in hrev31333, thanks!

Note: See TracTickets for help on using tickets.