Home / Alt manpages / svn2revisioninc-3.0(1)

  • svn2revisioninc-3.0(1)
  • User command
  • linux

Create a Lazarus revision.inc from an SVN checkout

You will use the Lazarus 3.0 svn2revisioninc utility to derive a revision include file from an SVN working copy, or print the revision value without creating that file. Allow about ten minutes if the checkout already exists. The examples use the installed lcl-utils-3.0 package, version 3.0+dfsg1-8build3.

1. Check the installed utility

Run these commands as your normal user. No service restart or elevated privilege is needed: the tool reads repository metadata and writes the output where you tell it.

$ command -v svn2revisioninc
/usr/bin/svn2revisioninc
$ dpkg-query -W -f='${Package} ${Version}\n' lcl-utils-3.0
lcl-utils-3.0 3.0+dfsg1-8build3
$ svn2revisioninc -h

The installed program prints its help text and exits with status 1 for the help request on this machine. That is a quirk of this build, not evidence that the executable is missing. The manual documents -h; the help text labels the same help switch --h. Both forms produce the help screen here.

Checkpoint: if command -v prints nothing, stop and install the package through your normal package-management process. Do not copy a different Lazarus tool into /usr/bin just to make this command available.

2. Choose the checkout and output path

The first switchless argument is the repository path. The second is the output file. If you omit the repository path, the utility uses the current directory. If you omit the output file, it uses revision.inc. Make those defaults explicit in build scripts so that a changed working directory cannot send the include file somewhere surprising.

$ repo=/path/to/lazarus-checkout
$ output=/path/to/build/revision.inc
$ test -d "$repo/.svn" && echo 'SVN metadata directory found'
$ test -d "$(dirname "$output")" && echo 'output directory exists'

Replace both placeholders with real paths. The installed manpage describes an SVN repository, so this guide does not assume that a Git checkout, an exported source archive or a remote URL is accepted. The input must be a local repository path that the utility can inspect.

Do not point the output at a tracked source file or an existing include file until you have checked it. The normal form creates or replaces the named output. Shell redirection is not involved in this form, so the output path is controlled by the utility.

3. Generate the include file

Run the utility with both paths:

$ svn2revisioninc "$repo" "$output"
$ printf 'exit=%s\n' "$?"
exit=0

On success, revision.inc is the file Lazarus build rules can include. The default constant name is RevisionStr. Verify the result without opening it in an editor that might add formatting:

$ test -s "$output" && echo 'revision include is non-empty'
revision include is non-empty
$ sed -n '1,12p' "$output"

The final command is an inspection step. Its exact Pascal declaration depends on the revision information found in the checkout, so do not hard-code an expected revision string into a test. A non-zero status from the generator means the file should not be treated as refreshed.

Checkpoint: confirm the file is in the build directory you intended and that it is readable by the account running the Lazarus build. If you generated it in the wrong place, move it back only after identifying whether a build script also refers to the old path.

4. Change the constant name when required

Pass --c= with the name expected by your Pascal source. The value is a name, not a quoted Pascal declaration:

$ svn2revisioninc "$repo" --c=SourceRevision "$output"
$ grep -n 'SourceRevision' "$output"
1:SourceRevision = ...

The ellipsis in that displayed result represents the generated revision text, not literal output to copy. Use a valid identifier that matches the code which includes the file. If you omit --c=, the utility uses RevisionStr.

The command accepts its options before or between the two positional arguments. For repeatable automation, keep options together and use the explicit repository and output paths. This avoids confusing the output file with a switchless argument when a path contains a leading hyphen.

5. Inspect the revision without writing a file

Use --s when a script needs the revision on standard output and must not create an include file:

$ svn2revisioninc --s "$repo"
$ status=$?
$ printf 'svn2revisioninc status: %s\n' "$status"
svn2revisioninc status: 0

Do not combine --s with a pipeline that hides the generator's status. Capture the status immediately if it controls a build decision. On a directory with no usable revision metadata, this installed build can return success with no output, so also check that the captured value is non-empty before consuming it.

$ revision=$(svn2revisioninc --s "$repo")
$ test -n "$revision" || { printf '%s\n' 'no revision was printed' >&2; exit 1; }
$ printf 'revision=%s\n' "$revision"

This mode leaves the output path untouched because it does not create the include file. It is the safer choice for a diagnostic or a build step that has its own generated-file handling.

6. Diagnose failures without guessing

Use --v to print the source directory, output file and constant name selected by the program:

$ svn2revisioninc --v "$repo" "$output"
$ printf 'exit=%s\n' "$?"
exit=0

If the utility reports that the source directory does not exist, inspect the path rather than retrying with sudo:

$ ls -ld -- "$repo"
$ test -r "$repo" && echo 'repository path is readable'

If the path exists but the result is empty or stale, check that it is an SVN working copy rather than an exported tree. The command is not a repository repair tool. Restore the missing metadata by obtaining a proper working copy through your normal version-control process, then rerun the generator.

Before regenerating an existing include, make a reviewable backup if its current value matters:

$ cp --preserve=all -- "$output" "$output.bak"
$ svn2revisioninc "$repo" "$output"
$ diff -u "$output.bak" "$output" || true

The backup is a recovery point. Remove it only after the build has used the new file and you have checked the diff; deleting it is irreversible. If the new output is wrong, restore it with mv -- "$output.bak" "$output", then investigate the checkout before trying again.

Done means

  • The command resolves to the installed Lazarus 3.0 utility from lcl-utils-3.0.
  • The repository path is a readable local SVN working copy.
  • The generated include is non-empty and is located where the build expects it.
  • The default RevisionStr name was retained, or --c= matches the Pascal source.
  • Diagnostic scripts check both printed output and the generator's exit status.
  • An existing include was backed up before any deliberate replacement.