Import brltty

This commit is contained in:
Vladimir Serbinenko committed 2013-10-28 16:46:36 +01:00
1 parent 93c120754a
commit 16fba4d65d
982 files changed
+326586

No files matched your search

@@ -0,0 +1,35 @@
Debian Installer feat. BRLTTY
-----------------------------
Debian Installer natively supports BRLTTY since its beta 3 for Debian
Etch, see official announcement at [1]. If your Braille display is
connected by USB, simply press ENTER at syslinux prompt (at the very
beginning of the installation process), your display should be
autodetected. Otherwise, if either your display is connected by
serial port or you want to set a particular Braille table, give the
following line at syslinux prompt before pressing ENTER (you may be
careful as the keyboard layout is qwerty at this step):
install brltty=drv,dev,tbl
"drv" stands for the BRLTTY code of your Braille display, "dev" stands
for the device your Braille display is connected to (e.g. ttyS0, usb:,
...) and "tbl" stands for the code of the Braille table to be set.
For example, this is the line that enables BRLTTY for a BAUM
SuperVario 40 Braille display connected by USB with default Braille
table:
install brltty=bm,usb:
Supported Braille displays and Braille tables are listed along with
corresponding codes in the BRLTTY manual, see [2]. Details about
installing Debian are available at [3]. Please also consider joining
Debian Accessibility mailing list at [4].
Footnotes:
[1] http://www.debian.org/devel/debian-installer/News/2006/20060811
[2] http://mielke.cc/brltty/doc/Manual-BRLTTY/English/BRLTTY.html
[3] http://www.debian.org/releases/stable/installmanual
[4] http://lists.debian.org/debian-accessibility/
-- Boris Daix <Boris.Daix@alysse.org> Sun, 27 Aug 2006 23:10:15 +0200
@@ -0,0 +1,159 @@
Adding BRLTTY to a Red Hat Linux Install CD
===========================================
Written during April, 2004, by Dave Mielke <dave@mielke.cc>.
Quick Start
-----------
The script "rhmkiso" can be used to add BRLTTY to a RedHat or Fedora install
CD. Here's how to use it.
First: Log in as (or su to) root. This is because the script uses a loopback
mount. You'll probably also need to be root in order to write the resultant
image to a CD as well.
Second: Create an empty directory and change to it.
mkdir work
cd work
Third: Copy or download the image of the installer CD ("boot.iso") for the
desired RedHat or Fedora release, or the image for the first CD of the full
installation set ("disc1.iso"), into the current directory.
cp /path/to/boot.iso .
Fourth: Copy or download the tarball for the desired BRLTTY release into the
current directory.
cp /path/to/brltty-3.5.tar.gz .
Fifth: Run the "rhmkiso" script with no options or parameters.
rhmkiso
Sixth: You should now have a new file, "brltty.iso", in the current directory.
Write this modified image to a CD.
cdrecord -v dev=0,0,0 -data brltty.iso
If you're using a rewritable CD then you should erase it first.
cdrecord -v dev=0,0,0 blank=fast
For more information on writing to a CD, please check the CD-Writing HOWTO at:
http://tldp.org/HOWTO/CD-Writing-HOWTO.html
Seventh: Boot from the CD you've just written, and wait a few seconds after it
begins to spin in order to give the boot loader enough time to get started and
to present its initial prompt. Then enter:
text brltty=<driver>,<device>,<table>
e.g.
text brltty=ht,ttyS1,de
You can omit any operand, allowing it to default, simply by not specifying it.
You also needn't specify any trailing commas resulting from omitted operands.
text brltty=ht,ttyS1,
text brltty=ht,ttyS1
text brltty=ht,
text brltty=ht
text brltty=ht,,de
text brltty=ht,,
The <driver> operand is the two-letter identifier of the driver for your
braille display. It's the only required operand. See the -b option (below) for
further details.
The <device> operand is the device to which your braille display is connected.
It's optional, and defaults to the primary serial port ("/dev/ttyS0"). If your
display is connected to a serial port then specify either the name (e.g.
"ttyS1") of or the path (e.g. "/dev/ttyS1") to the corresponding device. If
it's connected to the USB then specify "usb:" (the trailing colon is
important).
The <table> operand is the text translation table you wish to use. It's
optional, and defaults to "nabcc" (North American Braille Computer Code). See
the "text.*.tbl" files in the "BrailleTables" subdirectory of BRLTTY's source
tree for alternatives. See the -t option (below) for further details.
The Details
-----------
The "rhmkiso" script can add BRLTTY to either a RedHat or a Fedora install CD.
It can be applied either to the basic installer CD or to the first CD of the
full installation set, and makes the following modifications to the image:
* BRLTTY is added (all drivers, all tables).
* The timeout for the initial boot loader prompt is disabled.
* The default kernel configuration to be booted is changed to "text".
* The use of frame buffers for the "text" consoles is disabled.
For rescue images, the following additional modifications are made:
* Text consoles are used when "rescue" is selected.
* The use of frame buffers for the "rescue" consoles is disabled.
Although its defaults are what usually needs to be done, the "rhmkiso" script
offers a number of options so that you can customize what it does. It's general
invocation syntax is:
rhmkiso [-option ...]
The following options are provided:
-i file The original (input) image (default: boot.iso).
-o file The modified (output) image (default: brltty.iso).
-a file The BRLTTY archive (default: check current directory).
-b driver,... The braille driver(s) to include (default: all).
-t file The text translation table to build in (default: nabcc).
-s Invoke an interactive shell to inspect the modified image.
-h Display usage information and exit.
The -i option specifies the location of the distribution-supplied original
(input) image which is to be modified. Either a relative or an absolute path
may be supplied. It defaults to "boot.iso" (the usual name for the basic
installer CD image).
The -o option specifies the location of the file which is to contain the
modified (output) image which the script will create. Either a relative or an
absolute path may be supplied. It defaults to "brltty.iso".
The -b option specifies which braille display drivers will be linked into the
brltty executable as opposed to being built as dynamically loadable shared
objects. If more than one driver is specified then their specifiers must be
separated from one another by a comma. Either the two-letter identifier or the
proper name (full or abbreviated) for each driver must be supplied. If a driver
specifier is prefixed by a minus sign (-) then that driver is excluded from the
build. The first non-excluded driver in the list is the default driver. The
word "all", if used instead of a driver specifier as the last item in the list,
causes all the remaining drivers to be implicitly appended to the list in no
specific order (or, if preceded by a minus sign, to be excluded from the
build). The default is "all", i.e. all of the drivers (in no particular order
so the default is unpredictable) are linked in.
The -t option specifies which text translation table is to be built into the
brltty executable. If a relative path is supplied then it's anchored at the
"BrailleTables" subdirectory within BRLTTY's source tree. Since any of BRLTTY's
own tables can also be specified when the image is booted, the primary use of
this option is to specify the absolute path to a user-defined table outside
BRLTTY's source tree. The ".tbl" extension is optional. If a simple file name,
i.e. one of BRLTTY's own tables, is being supplied then the "text." prefix is
also optional. The default is "nabcc" (North American Braille Computer Code).
The -s option causes an interactive shell to be invoked after all of the
modifications to the files within the image have been made but before the CD
image is created. This gives you an opportunity to inspect what the script has
done. Your login shell, i.e. the one pointed to by the $SHELL environment
variable, is used; if it's not set then "/bin/sh" is assumed.
The script uses a lot of temporary file space to do its job, especially if the
first CD of the full installation set is being used. This is because it needs
to work with a complete extracted copy of the files within the image. If
there's not enough space in "/tmp" then you can direct the script to use
another directory via the $TMPDIR environment variable.
The script uses a loopback mount to access the files within the original CD
image. This means that it must be run as root.
@@ -0,0 +1,209 @@
Adding BRLTTY to a Red Hat Linux Install Floppy
===============================================
Written on April 7, 2002
Here is an outline of a procedure for adapting the RedHat (or similar)
installation boot disk so that BRLTTY can be used during the installation
process.
History:
-Initial draft from Stéphane Doyon <s.doyon@videotron.ca>
-Additions from Nicolas Pitre <nico@fluxnic.net>
-April 7, 2002: Mostly rewritten by Stéphane Doyon to take into account
the INIT_PATH hack
-September 26, 2002: Amended by Dave Mielke <dave@mielke.cc> due to change from
make file editing to autoconf in 3.1.
TODO:
-Figure out how to use shared libraries from a statically linked
executable, when the lib references symbols from the main
program. With that we could do generic bootdisk with dynamic selection
of braille driver.
-Give working instructions on how to make higher sized floppies for a
one-floppy solution.
You need an already working Linux station to perform this. A certain
level of Linux/Unix expertise is also required. Please read to the end
before doing anything. You'll probably end up asking for sighted help at
some point (such as to know why it won't boot, or to help install BRLTTY
on the new machine), but if you can get this to work then you'll be free
to spend an hour on your own choosing which packages you want installed.
This was last tried with RedHat 7.2.
First step is compiling BRLTTY. The bootdisk will use one and only one
BRLTTY driver, so you must choose wich. Do:
make distclean
./configure --enable-standalone-programs --with-init-path
--with-braille-driver=<driver> --with-text-table=<table>
make
where <driver> is the driver to build into BRLTTY (one of the possible values
listed under --with-braille-driver in the output from ./configure --help) and
<table> is the text translation table to use (such as text.french.tbl,
text.german.tbl, ...) (see the the BrailleTables/ subdirectory).
This will build BRLTTY with the chosen display driver built-in, and will
link the BRLTTY executable statically so that it doesn't depend on any
shared libraries.
If your display is on the second serial port instead of the first,
you will need to add "--with-braille-device=/dev/ttyS1".
You should get an executable called "brltty" (in the "Programs/" subdirectory)
whose size is around 570K, depending on the driver you chose. If you do:
file Programs/brltty
it should say, among other things, "statically linked".
The Red Hat installation boot disk is a DOS disk that contains a boot
loader (called syslinux), a kernel (called vmlinuz), and an initial ramdisk
(called initrd.img). This initial ramdisk is the initial root filesystem
containing a bootstrap installation program: /sbin/init. We'll just put
brltty on that ramdisk image and make sure it is started before anything
else. However, because the statically linked brltty executable is so
large, we will have to put the ramdisk image on a second floppy, because
it won't fit on the original single boot floppy (with the kernel).
So now we must hack floppies. Make a temporary work directory. We will
call it ".../work", could be "~/work".
mkdir .../work
mkdir .../work/etcbrltty
Now copy relevant files from your BRLTTY build. Copy the executable, the
translation table, the contraction table (if you want it), and the help file(s)
to your work directory.
cp Programs/brltty .../work
cp BrailleTables/*.tbl .../work/etcbrltty
cp ContractionTables/*.ctb .../work/etcbrltty
cp help/* .../work/etcbrltty
(You can also copy alternative translation tables from BrailleTables/
to .../work/etcbrltty. These CAN be loaded dynamically.)
Now change to the work directory:
cd .../work
The executable is way too large for a boot disk because it contains lots of
unneeded symbol table and debugging information. Remove this excess data in
order to make the executable as small as possible.
strip brltty
Next step is to select an installation boot floppy image from your
distribution. This could be images/boot.img or images/bootnet.img from an
RH CDROM. Consider checking the updates site for your distribution in
case they have updated installation disk images. If what you have is an
actual floppy, use "dd if=/dev/fd0 of=boot.img bs=512" to make an image
file from it.
Copy the chosen image to your work directory and if necessary rename it
to boot.img.
So now the current directory should contain boot.img, brltty, and
etcbrltty/.
Now run the rhmkbot script (which is located in the same directory as this
README). It will copy boot.img to myboot.img, and it will modify the
syslinux.cfg: it will add a new boot entry called "brltty". That entry will
have options to cause syslinux to load a ramdisk from a second floppy, instead
of using the initrd.img on the first floppy. The brltty entry has the "text"
keyword parameter to trigger the text-mode install. rhmkbot also makes this new
entry the default boot entry.
Now run the rhmkroot script. It will get initrd.img (the initial ramdisk)
from boot.img and call it myroot.img. It will modify that image:
-Rename /sbin/init to /sbin/init_real,
-Copy brltty to /sbin/brltty,
-Link /sbin/init to /sbin/brltty
-Copy files from etcbrltty to /etc/brltty,
-Try to make sure necessary devices such as vcsa, serial ports, and
console device exist in /dev. (vcsa is usually missing.)
If it turns out that the brltty executable is too large, do "./configure
--help" and check out the various "--disable-..." options. Each removes a
specific feature from BRLTTY, and results in a corresponding decrease in the
size of the executable. Recommended possibilities include:
--disable-table-selection --disable-learn-mode --disable-contracted-braille
--disable-pcm-support --disable-midi-support --disable-fm-support
--disable-api --disable-gpm
--disable-speech-support --without-x
If building the Papenmeier driver, then also consider:
--disable-pm-configfile
Remember to do "make distclean" if you need to reconfigure BRLTTY.
Assuming there are no errors, the next step is to actually write the
floppies.
So get two formatted floppies. One will be the boot floppy, the other the
ramdisk floppy. To write the boot floppy do:
dd if=myboot.img of=/dev/fd0 bs=512
To write the ramdisk floppy do:
dd if=myroot.img of=/dev/fd0 bs=512
That's it!
So now boot the boot floppy on the machine you want to install. At the
prompt you can press ENTER to choose the brltty entry.
If you want to specify boot parameters, remember to use the label
"brltty" instead of "linux".
You can pass options to BRLTTY from the boot prompt by using option names
similar to those in the brltty.conf file: use only uppercase, use underscores
instead of minus signs, and prefix with BRLTTY_. For example:
brltty BRLTTY_BRAILLE_DEVICE=/dev/ttyS1
When you press ENTER, syslinux will load the kernel. When the floppy
stops spinning the kernel will start to run and will prompt you for the
ramdisk floppy. Put the second floppy in and press ENTER. The kernel will
load the ramdisk. When the floppy stops spinning, BRLTTY SHOULD
(hopefullY) come on and the installation program should start.
One of the problems you may have during the installation process is that
some autoconfiguration programs may play around with the serial ports to
try to autodetect hardware, thereby upsetting them and causing BRLTTY to
stop working. This can also occur when the system itself boots. More
recent RedHat versions are less aggressive though. Two tricks if you have
problems:
-If kudzu runs when your system boots and upsets BRLTTY, either disable
that service (using chkconfig or ntsysv) or modify /etc/sysconfig/kudzu
or the script that uses kudzu to make it use the --safe option.
-To get the installation program to leave a serial port alone, you might
try to modify the ramdisk to change /dev/ttyS0 to say /dev/ttySmyown, and
tell BRLTTY to use that as it's serial port. This might have the effect
of hiding the serial port from bad applications.
Note that you must also install BRLTTY on your new machine. When it will boot
Linux after the installation, BRLTTY will not be installed and the machine will
be inaccessible. One way to simplify things is to use the statically linked
brltty you compiled for the installation disk, as it is fairly self-contained.
Once it's running, then you can build yourself a shared version and modify your
boot scripts or inittab to have BRLTTY start automatically. A nice way to get
brltty onto your new machine is this: during the installation process, after
your target partition has been formatted, it is (at least with the current RH
installation program) mounted under /mnt/sysimage. You can temporarily put
aside the installation program and get a shell by going to the second virtual
console (alt-F2). There you can do:
cp /sbin/brltty /mnt/sysimage/bin/
I am not sure if at that point it is possible to edit inittab or startup
scripts. Otherwise on your first boot, you just have to log in as root
(without braille support) and type "/bin/brltty" and if all went well
BRLTTY should come on.
Good luck!
+261
View File
@@ -0,0 +1,261 @@
#!/bin/sh
###############################################################################
# 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-2012 by The BRLTTY Developers.
#
# BRLTTY comes with ABSOLUTELY NO WARRANTY.
#
# This is free software, placed under the terms of the
# GNU General Public License, as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any
# later version. Please see the file LICENSE-GPL for details.
#
# Web Page: http://mielke.cc/brltty/
#
# This software is maintained by Dave Mielke <dave@mielke.cc>.
###############################################################################
# Convert the boot parameter to configuration file directives.
# If /proc is mounted then use the brltty= boot parameter in /proc/cmdline.
# If /proc is not mounted then use the brltty environment variable.
# Invoke with -h for usage information.
programName="${0##*/}"
programMessage()
{
echo 2>&1 "${programName}: ${1}"
}
syntaxError()
{
programMessage "${1}"
exit 2
}
internalError()
{
programMessage "${1}"
exit 3
}
configurationFile=""
requestedAction=create
deviceTranslation=none
requestedParameter=""
OPTIND=1
while getopts ":f:cundop:h" option
do
case "${option}"
in
f) configurationFile="${OPTARG}";;
c) requestedAction=create;;
u) requestedAction=update;;
n) deviceTranslation=none;;
d) deviceTranslation=devfs;;
o) deviceTranslation=old;;
p) requestedParameter="${OPTARG}";;
h)
cat <<EOF
Usage: ${programName} [option ...]
-f file The configuration file to create/update.
-c Create the configuration file (write to stdout if no -f).
-u Update the configuration file (copying from stdin to stdout if no -f).
-n Do not translate device paths.
-d Do old-style to devfs device path translation.
-o Do devfs to old-style device path translation.
-p [driver][,[device][,[table]]]
Explicitly specify the boot parameter.
-h Display this usage summary.
EOF
exit 0
;;
\?) syntaxError "unknown option: -${OPTARG}";;
:) syntaxError "missing value: -${OPTARG}";;
*) internalError "unimplemented option: -${option}";;
esac
done
shift "`expr $OPTIND - 1`"
[ "${#}" -eq 0 ] || syntaxError "too many parameters."
case "${requestedAction}"
in
create)
putConfigurationLine()
{
echo "${1}" || exit 4
}
startConfigurationFile()
{
[ -n "${configurationFile}" ] && exec >"${configurationFile}"
putConfigurationLine "`makeHeaderLine Created`"
putConfigurationLine "`makeParameterLine`"
putConfigurationLine ""
}
putConfigurationDirective()
{
putConfigurationLine "${1} ${2}"
}
finalizeConfigurationFile()
{
:
}
;;
update)
putSedCommand()
{
sedScript="${sedScript}
${1}"
}
startConfigurationFile()
{
if [ -n "${configurationFile}" ]
then
[ -e "${configurationFile}" ] || syntaxError "file not found: ${configurationFile}"
[ -f "${configurationFile}" ] || syntaxError "not a file: ${configurationFile}"
[ -r "${configurationFile}" ] || syntaxError "file not readable: ${configurationFile}"
[ -w "${configurationFile}" ] || syntaxError "file not writable: ${configurationFile}"
outputFile="${configurationFile}.new"
exec <"${configurationFile}" >"${outputFile}"
fi
sedScript=""
putSedCommand "1i\\
`makeHeaderLine Updated`\\
`makeParameterLine`\\
"
}
putConfigurationDirective()
{
value="`echo "${2}" | sed -e 's%\\([/\\]\\)%\\\\\\1%g'`"
putSedCommand "/^ *#\\(${1} .*\\)/s//\\1/"
putSedCommand "/^ *\\(${1}\\) .*/s//\\1 ${value}/"
}
finalizeConfigurationFile()
{
sed -e "${sedScript}"
[ -n "${outputFile}" ] && mv -f "${outputFile}" "${configurationFile}"
}
;;
*) internalError "unimplemented action: ${requestedAction}";;
esac
translateDevice_none()
{
:
}
translateDevice_devfs()
{
minor="${device#ttyS}"
if [ "${minor}" != "${device}" ]
then
device="tts/${minor}"
return 0
fi
minor="${device#lp}"
if [ "${minor}" != "${device}" ]
then
device="printers/${minor}"
return 0
fi
programMessage "unsupported old-style device: ${device}"
}
translateDevice_old()
{
major="${device%%/*}"
if [ "${major}" != "${device}" ]
then
minor="${device#*/}"
case "${major}"
in
tts) devfs="ttyS${minor}";;
printers) devfs="lp${minor}";;
esac
fi
if [ -n "${devfs}" ]
then
device="${devfs}"
else
programMessage "unsupported devfs device: ${device}"
fi
}
makeHeaderLine()
{
echo "# ${1} by brltty-bp2cf`date +' on %Y-%m-%d at %H:%M:%S %Z (UTC%z)'`."
}
makeParameterLine()
{
echo "# Boot Parameter:${bootParameter}"
}
putConfigurationFile()
{
startConfigurationFile
[ -n "${brailleDriver}" ] && putConfigurationDirective "braille-driver" "${brailleDriver}"
[ -n "${brailleDevice}" ] && {
device="`echo "${brailleDevice}" | sed -e 's%//*%/%g' -e 's%^/dev/%%'`"
if [ "${device#/}" = "${device}" ]
then
translateDevice_${deviceTranslation}
fi
putConfigurationDirective "braille-device" "${device}"
}
[ -n "${textTable}" ] && putConfigurationDirective "text-table" "${textTable}"
finalizeConfigurationFile
}
parseBootParameter()
{
bootParameter="${bootParameter} ${1}"
number=1
while [ "${number}" -le 3 ]
do
cut="cut -d, -f${number}"
[ "${number}" -gt 1 ] && cut="${cut} -s"
operand="`echo ${1} | ${cut}`"
if [ -n "${operand}" ]
then
case "${number}"
in
1) brailleDriver="${operand}";;
2) brailleDevice="${operand}";;
3) textTable="${operand}";;
esac
fi
number="`expr ${number} + 1`"
done
}
putBootParameter()
{
parseBootParameter "${1}"
putConfigurationFile
}
parseBootCommand()
{
found=false
while [ "${#}" -gt 0 ]
do
case "${1}"
in
"brltty="*)
found=true
parseBootParameter "${1#*=}"
;;
esac
shift
done
"${found}" && putConfigurationFile
}
brailleDriver=""
brailleDevice=""
textTable=""
bootCommandFile="/proc/cmdline"
if [ -n "${requestedParameter}" ]
then
putBootParameter "${requestedParameter}"
elif [ -f "${bootCommandFile}" ]
then
parseBootCommand `cat "${bootCommandFile}"`
elif [ -n "${brltty}" ]
then
putBootParameter "${brltty}"
fi
exit 0
@@ -0,0 +1,20 @@
#!/bin/sh
set -e
# Make local mount points
mkdir -p mnt1 mnt2
# Work on a copy of bootdisk image
cp -f boot.img myboot.img
mount myboot.img mnt1 -o loop -t msdos
# Modify syslinux.cfg
cat >cfg <<EOF
label brltty
kernel vmlinuz
append root=/dev/fd0 load_ramdisk=1 prompt_ramdisk=1 lang= text devfs=nomount ramdisk_size=9216
EOF
cat mnt1/syslinux.cfg |sed 's/default linux/default brltty/' >>cfg
cp cfg mnt1/syslinux.cfg
umount mnt1
+333
View File
@@ -0,0 +1,333 @@
#!/bin/bash -p
###############################################################################
# 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-2012 by The BRLTTY Developers.
#
# BRLTTY comes with ABSOLUTELY NO WARRANTY.
#
# This is free software, placed under the terms of the
# GNU General Public License, as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any
# later version. Please see the file LICENSE-GPL for details.
#
# Web Page: http://mielke.cc/brltty/
#
# This software is maintained by Dave Mielke <dave@mielke.cc>.
###############################################################################
programName="${0##*/}"
programMessage() {
echo >&2 "${programName}: ${1}"
}
programError() {
[ -n "${1}" ] && programMessage "${1}"
exit "${2:-3}"
}
syntaxError() {
programError "${1}" 2
}
mount_ext2() {
mount -o loop -t ext2 "${2}" "${1}"
}
unmount_ext2() {
umount "${1}"
}
check_ext2() {
set -- $(stat -c '%a %s' -f -- "${initrdRoot}")
initrdAvailableBlocks="${1}"
initrdBlockSize="${2}"
set -- $(du --block-size="${initrdBlockSize}" -s "${brlttyInstallRoot}")
brlttyInstallBlocks="${1}"
set -- $(stat -c '%s' -- "${initrdImage}")
initrdImageBytes="${1}"
initrdImageBlocks=$(( (initrdImageBytes + initrdBlockSize - 1) / initrdBlockSize ))
initrdPadBlocks=$(( brlttyInstallBlocks - initrdAvailableBlocks ))
(( (initrdPadBlocks += 200) > 0 )) && {
initrdMounted=false
"unmount_${initrdType}" "${initrdRoot}" "${initrdImage}"
dd bs="${initrdBlockSize}" count="${initrdPadBlocks}" if="/dev/zero" of="${initrdImage}" seek="${initrdImageBlocks}"
e2fsck -y -f "${initrdImage}" && resize2fs "${initrdImage}" || {
newImage="${temporaryDirectory}/new.${initrdType}"
cp -RpPd -- "${initrdImage}" "${newImage}"
mke2fs -q -b "${initrdBlockSize}" -F "${newImage}"
newRoot="${temporaryDirectory}/new"
mkdir "${newRoot}"
"mount_${initrdType}" "${newRoot}" "${newImage}"
newMounted=true
"mount_${initrdType}" "${initrdRoot}" "${initrdImage}"
initrdMounted=true
cp -RpPd -- "${initrdRoot}/." "${newRoot}"
initrdMounted=false
"unmount_${initrdType}" "${initrdRoot}" "${initrdImage}"
newMounted=false
"unmount_${initrdType}" "${newRoot}" "${newImage}"
cp -- "${newImage}" "${initrdImage}"
}
"mount_${initrdType}" "${initrdRoot}" "${initrdImage}"
initrdMounted=true
}
}
mount_cpio() {
cd "${1}"
cpio --quiet -i -I "${2}"
cd "${workingDirectory}"
}
unmount_cpio() {
cd "${1}"
[ -n "${2}" ] && {
find . -print |
sed -e '/^\.$/d' -e 's/^\.\///' |
cpio --quiet -o -H newc -O "${2}"
}
rm -f -r -- $(ls -1 -A)
cd "${workingDirectory}"
}
check_cpio() {
:
}
originalImage="boot.iso"
modifiedImage="brltty.iso"
brlttyPattern="brltty-*"
brailleDrivers="all"
textTable="en-nabcc"
invokeShell=false
showUsage() {
cat <<EOF
Usage: ${programName} [-option ...]
The following options are supported:
-i file The original (input) image (default: ${originalImage}).
-o file The modified (output) image (default: ${modifiedImage}).
-a file The BRLTTY archive (default: ${brlttyPattern}).
-b driver,... The braille driver(s) to include (default: ${brailleDrivers}).
-t file The text table to build in (default: ${textTable}).
-s Invoke an interactive shell to inspect the modified image.
-h Display usage information and exit.
EOF
exit 0
}
while getopts ":i:o:a:b:t:sh" option
do
case "${option}"
in
i) originalImage="${OPTARG}";;
o) modifiedImage="${OPTARG}";;
a) brlttyPattern="${OPTARG}";;
b) brailleDrivers="${OPTARG}";;
t) textTable="${OPTARG}";;
s) invokeShell=true;;
h) showUsage;;
\?) syntaxError "unknown option: -${OPTARG}";;
:) syntaxError "missing operand: -${OPTARG}";;
*) syntaxError "unimplemented option: -${option}";;
esac
done
shift $((OPTIND - 1))
[ "${#}" -gt 0 ] && syntaxError "too many parameters."
[ -f "${originalImage}" ] || programError "original image not found: ${originalImage}"
shopt -s nullglob extglob
set -- $brlttyPattern
[ "${#}" -eq 0 ] && programError "brltty archive not found: ${brlttyPattern}"
[ "${#}" -gt 1 ] && {
brlttyArchives="$(echo "${*}" | sed -e 's% %,&%g')"
programError "more than one brltty archive: ${brlttyArchives}"
}
brlttyArchive="${1}"
cleanup() {
set +e
cd /
"${newMounted}" && "unmount_${initrdType}" "${newRoot}"
"${initrdMounted}" && "unmount_${initrdType}" "${initrdRoot}"
"${originalMounted}" && umount "${originalRoot}"
[ -n "${temporaryDirectory}" ] && rm -r "${temporaryDirectory}"
}
set -e
originalMounted=false
initrdMounted=false
newMounted=false
trap "cleanup" 0
workingDirectory="${PWD}"
temporaryDirectory="$(mktemp -d "${TMPDIR:-/tmp}/${programName}.XXXXXX")"
originalRoot="${temporaryDirectory}/original"
mkdir "${originalRoot}"
mount -o loop -t iso9660 "${originalImage}" "${originalRoot}"
originalMounted=true
modifiedRoot="${temporaryDirectory}/modified"
mkdir "${modifiedRoot}"
cp -RpPd -- "${originalRoot}/." "${modifiedRoot}"
loaderDirectory=""
for directory in boot/isolinux isolinux
do
[ -d "${originalRoot}/${directory}" ] && {
loaderDirectory="${directory}"
break
}
done
configurationFile="isolinux.cfg"
sed -n -e '
1i\
prompt 1\
timeout 0\
default text\
/^ *prompt /d
/^ *timeout /d
/^ *default /d
/^ *menu *default *$/d
/^ *append.* text/s/$/ nofb/
/^ *append.* rescue/s/$/ text nofb/
p
' <"${originalRoot}/${loaderDirectory}/${configurationFile}" >"${modifiedRoot}/${loaderDirectory}/${configurationFile}"
# bootMessage="boot.msg"
# echo -n -e '\a' >"${modifiedRoot}/${loaderDirectory}/${bootMessage}"
# cat "${originalRoot}/${loaderDirectory}/${bootMessage}" >>"${modifiedRoot}/${loaderDirectory}/${bootMessage}"
initrdImage="${temporaryDirectory}/initrd.img"
initrdPath="${modifiedRoot}/${loaderDirectory}/initrd.img"
gunzip -c "${initrdPath}" >"${initrdImage}"
initrdDescription="`file -b "${initrdImage}"`"
case "${initrdDescription}"
in
*" ext2 "*) initrdType=ext2;;
*" cpio "*) initrdType=cpio;;
*) programError "unsupported initrd image format: ${initrdDescription}"
esac
initrdRoot="${temporaryDirectory}/initrd"
mkdir "${initrdRoot}"
"mount_${initrdType}" "${initrdRoot}" "${initrdImage}"
initrdMounted=true
found=false
for name in linuxrc init
do
linuxrcPath="${initrdRoot}/${name}"
initPath="$(readlink "${linuxrcPath}")" && {
found=true
break
}
done
"${found}" || programError "linuxrc not found."
rm "${linuxrcPath}"
ln -s /bin/brltty "${linuxrcPath}"
deviceDirectory="${initrdRoot}/dev"
ensureDevices() {
typeset type="${1}"
typeset major="${2}"
typeset minor="${3}"
typeset prefix="${4}"
typeset last="${5}"
typeset suffix="${6}"
typeset number=0
while ((number <= last))
do
typeset path="${deviceDirectory}/${prefix}${suffix}"
[ -e "${path}" ] || mknod -m 600 "${path}" "${type}" "${major}" "$((minor++))"
suffix=$((++number))
done
}
ensureDevices c 7 0 vcs 12
ensureDevices c 7 128 vcsa 12
ensureDevices c 5 1 console 0
ensureDevices c 4 0 tty 12 0
ensureDevices c 4 64 ttyS 3 0
ensureDevices c 188 0 ttyUSB 1 0
case "${brlttyArchive}"
in
*.tar.gz|*.tgz)
tar x -z -C "${temporaryDirectory}" -f "${brlttyArchive}"
;;
*.tar)
tar x -C "${temporaryDirectory}" -f "${brlttyArchive}"
;;
*)
programError "unsupported brltty archive name: ${brlttyArchive}"
;;
esac
shopt -s nullglob
set -- ${temporaryDirectory}/brltty*
[ "${#}" -eq 0 ] && programError "brltty build directory not found."
brlttyBuildRoot="${1}"
brlttyInstallRoot="${temporaryDirectory}/install"
(
set -e
trap "" 0
cd "${brlttyBuildRoot}"
shopt -s nullglob
set -- ./autogen*
for autogen
do
[ -f "${autogen}" -a -r "${autogen}" -a -x "${autogen}" ] && "${autogen}"
done
./configure --quiet --with-install-root="${brlttyInstallRoot}" \
--with-init-path="${initPath}" --with-stderr-path="/dev/tty5" \
--with-writable-directory="/tmp" \
--with-screen-driver="lx,-all" \
--with-braille-driver="-tt,-vr,${brailleDrivers}" \
--with-text-table="${textTable}" \
--disable-speech-support --without-libbraille --without-curses --disable-x \
--disable-pcm-support --disable-fm-support --disable-midi-support \
--enable-standalone-programs --disable-api --disable-gpm --disable-icu
make -s -C Programs all
strip Programs/brltty
make -s -C Programs install-programs install-data-files install-tables
) || exit "${?}"
"check_${initrdType}"
(
set -e
cd "${brlttyInstallRoot}"
cp --parents -- $(find . -type f -printf '%P ') "${initrdRoot}"
) || exit 1
"${invokeShell}" && (
set +e
trap "" 0
cd "${temporaryDirectory}"
"${SHELL:-/bin/sh}"
exit 0
)
initrdMounted=false
"unmount_${initrdType}" "${initrdRoot}" "${initrdImage}"
gzip -c -9 "${initrdImage}" >"${initrdPath}"
isoVolumeIdentifier="$(isoinfo -d -i "${originalImage}" | grep '^Volume id:' | cut -d' ' -f3-)"
isoApplicationIdentifier="$(isoinfo -d -i "${originalImage}" | grep '^Application id:' | cut -d' ' -f3-)"
mkisofs -quiet -J -R -T -boot-load-size 4 -boot-info-table -no-emul-boot \
-A "${isoApplicationIdentifier}" -V "${isoVolumeIdentifier}" \
-b "${loaderDirectory}/isolinux.bin" -c "${loaderDirectory}/boot.cat" \
-o "${modifiedImage}" "${modifiedRoot}"
exit 0
@@ -0,0 +1,69 @@
#!/bin/sh
set -e
# Make local mount points
mkdir -p mnt1 mnt2
# Mount bootdisk image read-only
mount boot.img mnt1 -o loop,ro -t msdos
# Get the initial ramdisk it contains
cp mnt1/initrd.img .
# Finished with boot image for now.
umount mnt1
# Unzip and mount it
mv initrd.img initrd.gz
gunzip initrd.gz
# Prevent warning about having to check the filesystem
tune2fs -c 0 -i 0 initrd >/dev/null
mount initrd mnt2 -o loop
# Work in initial ramdisk
# Rename it's init
mv mnt2/sbin/init mnt2/sbin/init_real
# Put BRLTTY on it
cp brltty mnt2/sbin
# New init is a link to BRLTTY
ln -s brltty mnt2/sbin/init
# Help files and tables (if the person isn't familiar...)
if [ -d etcbrltty ]; then
mkdir -p mnt2/etc/brltty
install etcbrltty/* mnt2/etc/brltty
fi
# Make sure some needed device files are present
# ttyS0 ttyS1 tty0
for i in ttyS0 ttyS1 tty0; do
if [ ! -e mnt2/dev/$i ]; then
cp -a /dev/$i mnt2/dev/$i
chown root:root mnt2/dev/$i
fi
done
# vcsa or vcsa0
# NB this doesn't handle devfs...
if [ ! -e mnt2/dev/vcsa -a ! -e mnt2/dev/vcsa0 ]; then
for i in vcsa vcsa0; do
if [ -c /dev/$i ]; then
if [ -h /dev/$i ]; then
tgt="`readlink /dev/$i`"
# This assumes the link is relative...
if [ -c /dev/$tgt ]; then
cp -a /dev/$tgt mnt2/dev
else
echo "Failed to get link target of /dev/$i"
echo "Failed!!"
exit 1
fi
fi
cp -a /dev/$i mnt2/dev
fi
done
fi
if [ ! -e mnt2/dev/vcsa -a ! -e mnt2/dev/vcsa0 ]; then
echo "Failed to create mnt2/dev/vcsa"
echo "Failed!"
exit 1
fi
# Done with initial ramdisk. wrap it up.
umount mnt2
gzip -9 initrd
mv initrd.gz myroot.img