declaring local variables procedures do not interfere with calling code
diff -Naur initrd-110-7-orig.txt/scripts/live initrd.txt/scripts/live
--- initrd-110-7-orig.txt/scripts/live 2007-11-19 10:58:26.000000000 +0100
+++ initrd.txt/scripts/live 2007-11-19 12:32:24.000000000 +0100
@@ -33,11 +30,13 @@
Arguments ()
{
- PRESEEDS=""
+ local PRESEEDS=""
+ local ARGUMENT arg
for ARGUMENT in $(cat /proc/cmdline)
do
- case "${ARGUMENT}" in
+ arg="$(echo "${ARGUMENT}" | tr '[A-Z]' '[a-z]' )"
+ case "${arg}" in
access=*)
ACCESS="${ARGUMENT#access=}"
export ACCESS
@@ -432,7 +523,8 @@
is_live_path ()
{
- DIRECTORY="${1}"
+ local DIRECTORY="${1}"
+ local FILESYSTEM
if [ -d "${DIRECTORY}"/"${LIVE_MEDIA_PATH}" ]
then
@@ -450,6 +542,8 @@
matches_uuid ()
{
+ local path uuid try_uuid try_uuid_file
+
if [ "${IGNORE_UUID}" ] || [ ! -e /conf/uuid.conf ]
then
return 0
@@ -505,9 +599,8 @@
mount_images_in_directory ()
{
- directory="${1}"
- rootmnt="${2}"
- mac="${3}"
+ local directory="${1}"
+ local rootmnt="${2}"
if match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.squashfs" ||
@@ -870,9 +962,13 @@
setup_unionfs ()
{
- image_directory="${1}"
- rootmnt="${2}"
- addimage_directory="${3}"
+ local image_directory="${1}"
+ local rootmnt="${2}"
+ local mac=$(get_mac)
+ local addresses=$(get_ipaddresses)
+ local ropt image imagename image_string IMAGE FILESYSTEM address addimage_directory
+ local rofsstring cowprobe d
+
modprobe -q -b ${UNIONTYPE}
# run-init can't deal with images in a subdir, but we're going to
@@ -1100,9 +1214,10 @@
check_dev ()
{
- sysdev="${1}"
- devname="${2}"
- skip_uuid_check="${3}"
+ local sysdev="${1}"
+ local devname="${2}"
+ local skip_uuid_check="${3}"
+ local loopdevname fstype
if [ -z "${devname}" ]
then
@@ -1141,7 +1256,8 @@
find_livefs ()
{
- timeout="${1}"
+ local timeout="${1}"
+ local sysblock dev
# first look at the one specified in the command line
if [ ! -z "${LIVE_MEDIA}" ]
@@ -1208,14 +1324,19 @@
set_usplash_timeout ()
{
+ local timeout="${1}"
+
+ [ -z "${timeout}" ] && timeout=120
if [ -x /sbin/usplash_write ]
then
- /sbin/usplash_write "TIMEOUT 120"
+ /sbin/usplash_write "TIMEOUT ${timeout}"
fi
}
mountroot ()
{
+ local slumber livefs_root
+
exec 6>&1
exec 7>&2
exec > live.log
diff -Naur initrd-110-7-orig.txt/scripts/live-helpers initrd.txt/scripts/live-helpers
--- initrd-110-7-orig.txt/scripts/live-helpers 2007-11-19 10:58:26.000000000 +0100
+++ initrd.txt/scripts/live-helpers 2007-11-19 12:34:54.000000000 +0100
@@ -9,14 +9,15 @@
sys2dev ()
{
- sysdev=${1#/sys}
+ local sysdev=${1#/sys}
echo "/dev/$(udevinfo -q name -p ${sysdev} 2>/dev/null|| echo ${sysdev##*/})"
}
subdevices ()
{
- sysblock=${1}
- r=""
+ local sysblock=${1}
+ local r=""
+ local dev
for dev in "${sysblock}" "${sysblock}"/*
do
@@ -47,7 +48,8 @@
where_is_mounted ()
{
- device=${1}
+ local device=${1}
+ local d mountpoint rest
if grep -q "^${device} " /proc/mounts
then
@@ -61,6 +63,8 @@
lastline ()
{
+ local lines line
+
while read lines
do
line=${lines}
@@ -71,8 +75,9 @@
base_path ()
{
- testpath="${1}"
- mounts="$(awk '{print $2}' /proc/mounts)"
+ local testpath="${1}"
+ local mounts="$(awk '{print $2}' /proc/mounts)"
+
testpath="$(busybox realpath ${testpath})"
while true
@@ -93,9 +98,10 @@
# Returns used/free fs kbytes + 5% more
# You could pass a block device as ${1} or the mount point as ${2}
- dev="${1}"
- mountp="${2}"
- used="${3}"
+ local dev="${1}"
+ local mountp="${2}"
+ local used="${3}"
+ local doumount size
if [ -z "${mountp}" ]
then
@@ -146,6 +152,7 @@
local pattern=${3}
local offset=${4}
local encryption=${5}
+ local dev options passphrase error answer
modprobe -q -b "${module}"
udevsettle
@@ -207,9 +214,9 @@
try_mount ()
{
- dev="${1}"
- mountp="${2}"
- opts="${3}"
+ local dev="${1}"
+ local mountp="${2}"
+ local opts="${3}"
if where_is_mounted ${dev} > /dev/null
then
@@ -222,10 +229,11 @@
find_cow_device ()
{
- pers_label="${1}"
- cow_backing="/${pers_label}-backing"
+ local pers_label="${1}"
+ local cow_backing="/${pers_label}-backing"
+ local sysblock dev devname
for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -v loop)
do
for dev in $(subdevices "${sysblock}")
@@ -258,10 +267,11 @@
# return the first of ${filenames} found on vfat and ext2/ext3 devices
# FIXME: merge with above function
- filenames="${1}"
- snap_backing="/snap-backing"
+ local filenames="${1}"
+ local snap_backing="/snap-backing"
+ local sysblock dev devname devfstype filename
for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -v loop)
do
for dev in $(subdevices "${sysblock}")
do
_______________________________________________
debian-live-devel mailing list
[email protected]
http://lists.alioth.debian.org/mailman/listinfo/debian-live-devel