Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

executable file 172 lines (146 sloc) 2.927 kB
#!/bin/sh
# create an SD card image
USAGE()
{
[ -z "$1" ] || echo error: $*
echo usage: $(basename "$0") '<options> <languages|ROOT>'
echo ' --help -h this message'
echo ' --verbose -v more messages'
echo ' --force -f ignore already copied check'
echo ' --image=<dir> -i <dir> image source directory [image]'
echo ' --card=<dir> -c <dir> image destination directory (no-default)'
exit 1
}
verbose=no
force=no
image=image
card=
suffix=pedia
debug=no
getopt=/usr/local/bin/getopt
[ -x "${getopt}" ] || getopt=getopt
args=$(${getopt} -o hvfi:c: --long=help,verbose,force,image:,card:,debug -- "$@") ||exit 1
# replace the arguments with the parsed values
eval set -- "${args}"
while :
do
case "$1" in
-v|--verbose)
verbose=yes
shift
;;
-f|--force)
force=yes
shift
;;
-i|--image)
image="$2"
shift 2
;;
-c|--card)
card="$2"
shift 2
;;
--debug)
debug=yes
shift
;;
--)
shift
break
;;
-h|--help)
USAGE
;;
*)
USAGE invalid option: $1
;;
esac
done
# verify arguments
[ -z "${card}" ] && USAGE card is not set
[ -z "${image}" ] && USAGE image is not set
[ $# -eq 0 ] && USAGE at least one language must be specified
[ -d "${card}" ] || USAGE card: ${card} is not a directory
case "${force}" in
[yY]|[yY][eE][sS])
;;
*)
[ -f "${card}/kernel.elf" ] && USAGE already copied
;;
esac
COPY()
{
local file dest name
file="$1"; shift
dest="$1"; shift
name="$(basename "${file}" | tr a-z A-Z)"
dest="${dest}/${name}"
printf "copying: ${name}\033[0K\r"
cp -p "${file}" "${dest}"
}
COPY_DIR()
{
local dir dest name file
dir="$1"; shift
dest="$1"; shift
name="$(basename "${dir}" | tr a-z A-Z)"
dest="${dest}/${name}"
mkdir -p "${dest}"
for file in "${dir}/"*
do
if [ ! -d "${file}" ]
then
COPY "${file}" "${dest}"
fi
done
echo
}
[ X"ROOT" = X"$1" ] && shift
for d in $@
do
flag=NO
for i in ${image}
do
dir="${i}/${d}${suffix}"
if [ -d "${dir}" -o -d "${i}/${d}" ]
then
flag=YES
break
fi
done
[ X"YES" = X"${flag}" ] || USAGE language ${d} not found
done
for d in $@
do
for i in ${image}
do
dir="${i}/${d}${suffix}"
if [ -d "${dir}" ]
then
echo copying language: ${d}
echo cp -pr "${dir}" "${card}"
COPY_DIR "${dir}" "${card}"
break
fi
dir="${i}/${d}"
if [ -d "${dir}" ]
then
echo copying directory: ${d}
echo cp -pr "${dir}" "${card}"
COPY_DIR "${dir}" "${card}"
break
fi
done
done
echo copying base files
for f in "${image}/"*
do
if [ ! -d "${f}" ]
then
COPY "${f}" "${card}"
touch "${card}/.metadata_never_index"
fi
done
echo
echo completed
Jump to Line
Something went wrong with that request. Please try again.