Debian Codegraph @

getrevid

raw symbols SCIP
1 #!/bin/shscip-shell filesystem . . `/bin/sh`.
2 ###############################################################################
3 # BRLTTY - A background process providing access to the console screen (when in
4 # text mode) for a blind person using a refreshable braille display.
5 #
6 # Copyright (C) 1995-2026 by The BRLTTY Developers.
7 #
8 # BRLTTY comes with ABSOLUTELY NO WARRANTY.
9 #
10 # This is free software, placed under the terms of the
11 # GNU Lesser General Public License, as published by the Free Software
12 # Foundation; either version 2.1 of the License, or (at your option) any
13 # later version. Please see the file LICENSE-LGPL for details.
14 #
15 # Web Page: http://brltty.app/
16 #
17 # This software is maintained by Dave Mielke <[email protected]>.
18 ###############################################################################
19
20 defaultModifiedIndicator="+"
21
22 . "`dirnamescip-shell system . . dirname. "${0}"`/brltty-prologue.sh"
23 addProgramOption a string.anything appendText "text to append to the revision identifier"
24 addProgramOption d string.anything defaultIdentifier "the default revision identifier"
25 addProgramOption f string.file outputFile "the file in which to write the revision identifier" "standard output"
26 addProgramOption i flag asInteger "render the revision identifier as a 32-bit integer"
27 addProgramOption m string.anything modifiedIndicator "the modified indicator" "${defaultModifiedIndicator}"
28 addProgramOption p string.anything prependText "text to prepend to the revision identifier"
29 addProgramOption r string.anything revisionIdentifier "the revision identifier"
30 addProgramOption s flag asString "render the revision identifier as a quoted string"
31 optionalProgramParameters
32 addProgramParameter source sourceRoot "the top-level directory of the source tree"
33 parseProgramArguments "${@}"
34
35 [scip-shell system . . `[`. -n "${sourceRoot}" ] || sourceRoot="${programDirectory}"
36 [scip-shell system . . `[`. -e "${sourceRoot}" ] || semanticError "directory not found: ${sourceRoot}"
37 [scip-shell system . . `[`. -d "${sourceRoot}" ] || semanticError "not a directory: ${sourceRoot}"
38
39 [scip-shell system . . `[`. -n "${modifiedIndicator}" ] || modifiedIndicator="${defaultModifiedIndicator}"
40
41 [scip-shell system . . `[`. -n "${revisionIdentifier}" ] || {
42 if [scip-shell system . . `[`. -e "${sourceRoot}/.git" ]
43 then
44 revisionIdentifier="`gitscip-shell system . . git. -C "${sourceRoot}" describe --tags --abbrev=8 --dirty="${modifiedIndicator}" --match="BRLTTY-*" 2>/dev/nullscip-shell filesystem . . `/dev/null`.`"
45 elif [scip-shell system . . `[`. -d "${sourceRoot}/.svn" ]
46 then
47 revisionIdentifier="`svnversion -n "${sourceRoot}" 2>/dev/nullscip-shell filesystem . . `/dev/null`.`"
48 [scip-shell system . . `[`. "${revisionIdentifier}" != "exported" ] || revisionIdentifier=""
49 else
50 revisionFile="${sourceRoot}/REVISION"
51 [scip-shell system . . `[`. -f "${revisionFile}" ] && read <"${revisionFile}" revisionIdentifier
52 fi
53
54 [scip-shell system . . `[`. -n "${revisionIdentifier}" ] || logWarning "unrecognized source repository type: ${sourceRoot}"
55 }
56
57 [scip-shell system . . `[`. -n "${revisionIdentifier}" ] || {
58 [scip-shell system . . `[`. -n "${defaultIdentifier}" ] || semanticError "revision identifier not known"
59 revisionIdentifier="${defaultIdentifier}"
60 }
61
62 "${asInteger}" && {
63 makeIntegerscip-shell shell brltty 6.9.1-1 makeInteger().() {
64 set -- `echoscip-shell system . . echo. "${revisionIdentifier}" | sedscip-shell system . . sed. -e 's/-/ /g'`
65 local commitCount="${3:-0}"
66
67 revisionIdentifier=0
68 local width=6
69 local shift=30
70 local number
71
72 for number in `echoscip-shell system . . echo. "${2}" | sedscip-shell system . . sed. -e 's/\./ /g'`
73 do
74 shift=$((shift - width))
75 revisionIdentifier=$((revisionIdentifier | (number << shift)))
76 done
77
78 revisionIdentifier=$((revisionIdentifier | commitCount))
79 }
80
81 makeIntegerscip-shell shell brltty 6.9.1-1 makeInteger().
82 }
83
84 [scip-shell system . . `[`. -n "${prependText}" ] && revisionIdentifier="${prependText}${revisionIdentifier}"
85 [scip-shell system . . `[`. -n "${appendText}" ] && revisionIdentifier="${revisionIdentifier}${appendText}"
86 "${asString}" && revisionIdentifier='"'"${revisionIdentifier}"'"'
87
88 if [scip-shell system . . `[`. -z "${outputFile}" ]
89 then
90 echoscip-shell system . . echo. "${revisionIdentifier}"
91 else
92 if [scip-shell system . . `[`. -e "${outputFile}" ]
93 then
94 [scip-shell system . . `[`. -f "${outputFile}" ] || semanticError "not a file: ${outputFile}"
95 [scip-shell system . . `[`. -r "${outputFile}" ] || semanticError "file not readable: ${outputFile}"
96
97 exec 3<"${outputFile}"
98 read <&3 -r firstLine && {
99 [scip-shell system . . `[`. "${firstLine}" != "${revisionIdentifier}" ] || read <&3 -r secondLine || exit 0
100 }
101 exec 3<&-
102
103 [scip-shell system . . `[`. -w "${outputFile}" ] || semanticError "file not writable: ${outputFile}"
104 else
105 outputDirectory="$(dirnamescip-shell system . . dirname. "${outputFile}")"
106 [scip-shell system . . `[`. -d "${outputDirectory}" ] || semanticError "not a directory: ${outputDirectory}"
107 [scip-shell system . . `[`. -w "${outputDirectory}" ] || semanticError "directory not writable: ${outputDirectory}"
108 fi
109
110 echoscip-shell system . . echo. "${revisionIdentifier}" >"${outputFile}"
111 fi
112
113 exit 0