1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288
|
#!/bin/bash
###############################################################################
# BRLTTY - A background process providing access to the console screen (when in
# text mode) for a blind person using a refreshable braille display.
#
# Copyright (C) 1995-2025 by The BRLTTY Developers.
#
# BRLTTY comes with ABSOLUTELY NO WARRANTY.
#
# This is free software, placed under the terms of the
# GNU Lesser General Public License, as published by the Free Software
# Foundation; either version 2.1 of the License, or (at your option) any
# later version. Please see the file LICENSE-LGPL for details.
#
# Web Page: http://brltty.app/
#
# This software is maintained by Dave Mielke <dave@mielke.cc>.
###############################################################################
set -e
shopt -s nullglob
defaultArchiveName="brltty-dos"
defaultInstallDirectory="BRLTTY"
. "`dirname "${0}"`/../prologue.sh"
addProgramOption a string.name archiveName "specify archive name" "${defaultArchiveName}"
addProgramOption i string.directory installDirectory "specify installation directory on target system" "${defaultInstallDirectory}"
addProgramOption o flag overwriteArchive "overwrite existing archive"
addProgramOption s flag invokeShell "invoke interactive shell to inspect/modify result"
addProgramOption T string.directory toolsRoot "specify tool chain root directory"
addProgramParameter source sourceDirectory "top-level directory of source tree"
parseProgramArguments "${@}"
[ -n "${archiveName}" ] || archiveName="${defaultArchiveName}"
[ -n "${installDirectory}" ] || installDirectory="${defaultInstallDirectory}"
[ -n "${toolsRoot}" ] && export DOS_TOOLS_ROOT="${toolsRoot}"
[ -n "${sourceDirectory}" ] || sourceDirectory="."
verifyInputDirectory "${sourceDirectory}" || semanticError
sourceDirectory="$(resolveDirectory "${sourceDirectory}")"
archivePath="${initialDirectory}/${archiveName}.zip"
[ ! -e "${archivePath}" ] || {
"${overwriteArchive}" ] || semanticError "archive already exists: ${archivePath}"
rm -f -r "${archivePath}"
}
function convertTextFile {
local file="${1}"
unix2dos -q -o "${file}"
}
function installFile {
local sourceFile="${1}"
local targetFile="${2}"
targetFile="${installDirectory}/${targetFile}"
local targetDirectory="${targetFile%/*}"
mkdir -p "${targetDirectory}"
cp "${sourceFile}" "${targetFile}"
}
function installCSV {
local oldName="${1}"
local newName="${2}"
local extension="csv"
installFile "${sourceDirectory}/${documentsSubdirectory}/${oldName}.${extension}" "${documentSubdirectory}/${newName}.${extension}"
}
function installManualFiles {
local directory="${1}"
cd "${directory}/Documents/Manual-BRLTTY"
local oldFile
for oldFile in $(find . -type f)
do
local newFile="${oldFile}"
local subdirectory="${oldFile%/*}"
local name="${oldFile##*/}"
local extension="${name##*.}"
name="${name%.*}"
case "${extension}"
in
html)
sed -r -e 's/"([[:alpha:]]+)(-([[:digit:]]+))?\.html(["#])/"\1\3.htm\4/g' -i "${oldFile}"
newFile="${subdirectory}/${name/-/}.${extension:0:3}"
;;
txt | htm | doc | pdf);;
*) continue;;
esac
installFile "${oldFile}" "${manualSubdirectory}/${newFile}"
done
}
needTemporaryDirectory
buildDirectory="${temporaryDirectory}/build"
mkdir -p "${buildDirectory}"
installDirectory="${temporaryDirectory}/intall/${installDirectory}"
mkdir -p "${installDirectory}"
documentSubdirectory="doc"
manualSubdirectory="${documentSubdirectory}/Manual"
cd "${buildDirectory}"
logMessage task "configuring build"
"${sourceDirectory}/cfg-dos" --prefix="${installDirectory}"
logMessage task "building programs"
make -s -C Programs all-commands
logMessage task "building documentation"
make -s -C Documents all
logMessage task "installing files"
make -s -C Programs install-commands install-tables
logMessage task "updating files"
cd "${installDirectory}/bin"
mv brltty-lscmds.exe brllscmd.exe
mv brltty-trtxt.exe brltrtxt.exe
mv brltty-ttb.exe brlttb.exe
mv brltty-ctb.exe brlctb.exe
mv brltty-atb.exe brlatb.exe
mv brltty-ktb.exe brlktb.exe
mv brltty-tune.exe brltune.exe
mv brltty-morse.exe brlmorse.exe
cd "${sourceDirectory}/DOS"
installFile cwsdpmi.exe "bin/cwsdpmi.exe"
cd "${sourceDirectory}/Drivers"
name=README
for driverType in Braille Speech
do
cd "${driverType}"
for driverName in *
do
cd "${driverName}"
typeset -u driverCode="$(sed -n -e '/^ *DRIVER_CODE *= */s/^.*= *//p' "Makefile.in")"
for file in "${name}"*
do
document="${file/#${name}/${driverCode}}"
document="${document//./-}"
installFile "${file}" "${documentSubdirectory}/Drivers/${driverType}/${document}.txt"
done
cd ..
done
cd ..
done
cd "${sourceDirectory}"
installFile "LICENSE-LGPL" "LIC-LGPL.txt"
installFile "README" "README.txt"
cd "${documentsSubdirectory}"
installFile "ChangeLog" "${documentSubdirectory}/CHG-LOG.txt"
for file in DOS
do
installFile "README.${file}" "${documentSubdirectory}/${file}.txt"
done
for file in BUGS CONTRIBUTORS HISTORY TODO
do
installFile "${file}" "${documentSubdirectory}/${file}.txt"
done
installCSV braille-driver BRL-DRV
installCSV speech-driver SPK-DRV
installCSV screen-driver SCR-DRV
installCSV text-table TEXT-TBL
installCSV contraction-table CONT-TBL
installCSV attributes-table ATTR-TBL
installCSV keyboard-table KBD-TBL
installManualFiles "${sourceDirectory}"
installManualFiles "${buildDirectory}"
cd "${buildDirectory}"
installFile "Documents/brltty.conf" "etc/brltty.cfg"
installFile "Programs/revision_identifier.auto.h" "REVISION.txt"
sed -e 's/"//g' -i "${installDirectory}/REVISION.txt"
logMessage task "converting text files"
cd "${installDirectory}"
find . -print |
while read path
do
handle="${path#.}"
[ -n "${handle}" ] || continue
name="${path##*/}"
extension="${name##*.}"
if [ "${name#*.*.}" != "${name}" ]
then
logWarning "name contains more than one dot: ${handle}"
elif [ "${name#.}" != "${name}" ]
then
logWarning "null name: ${handle}"
elif [ "${name%.}" != "${name}" ]
then
logWarning "null extension: ${handle}"
elif [ -f "${path}" ]
then
if [ "${extension}" = "${name}" ]
then
logWarning "file without an extension: ${handle}"
else
case "${extension}"
in
txt | html | htm | csv | cfg | [tcak]t[bi] | h) convertTextFile "${path}";;
exe | pdf | doc);;
*) logWarning "unexpected file extension: ${handle}";;
esac
fi
elif [ -d "${path}" ]
then
if [ "${extension}" != "${name}" ]
then
logWarning "directory with an extension: ${handle}"
fi
else
logWarning "unsupported special file: ${handle}"
fi
done
logMessage task "checking for name collisions"
cd "${installDirectory}"
find . -type d -print |
while read directory
do
declare -A shortNames=()
for longName in $(ls -1 --quote-name --quoting-style=shell "${directory}")
do
delimiter="."
prefix="${longName%${delimiter}*}"
if [ "${prefix}" = "${longName}" ]
then
suffix=""
delimiter=""
else
suffix="${longName:${#prefix}+${#delimiter}}"
fi
prefix="${prefix:0:8}"
suffix="${suffix:0:3}"
declare -u shortName="${prefix}${delimiter}${suffix}"
if [ "${#shortNames["${shortName}"]}" -eq 0 ]
then
shortNames["${shortName}"]="${longName}"
else
logWarning "name collision: ${directory#.}: ${shortNames["${shortName}"]} & ${longName}"
fi
done
done
! "${invokeShell}" || {
logMessage task "invoking shell"
cd "${installDirectory}"
"${SHELL:-/bin/sh}" || :
}
logMessage task "creating archive"
cd "${installDirectory}/.."
zip -q -r "${archivePath}" "${installDirectory##*/}"
logMessage task "done"
exit 0
|