Permalink
Browse files

[scripts] various scripts

For making SD card images and compressed packages etc.

Signed-off-by: Christopher Hall <hsw@openmoko.com>
  • Loading branch information...
1 parent 4f6d931 commit a55954f582b94512a8afbe1f6b53c9a1f06d3366 @hxw hxw committed Jun 18, 2010
Showing with 961 additions and 0 deletions.
  1. +118 −0 scripts/MakeSD
  2. +89 −0 scripts/PushFiles
  3. +366 −0 scripts/nls-print
  4. +388 −0 scripts/pack
View
@@ -0,0 +1,118 @@
+#!/bin/sh
+# create an SD card image
+
+USAGE()
+{
+ [ -z "$1" ] || echo error: $*
+ echo usage: $(basename "$0") '<options> <languages>'
+ echo ' --help -h this message'
+ echo ' --verbose -v more messages'
+ echo ' --image=<dir> -i <dir> image source directory [image]'
+ echo ' --card=<dir> -c <dir> image destination directory (no-default)'
+ exit 1
+}
+
+
+verbose=no
+image=image
+card=
+suffix=pedia
+
+debug=no
+
+getopt=/usr/local/bin/getopt
+[ -x "${getopt}" ] || getopt=getopt
+args=$(${getopt} -o hvi:c: --long=help,verbose,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
+ ;;
+
+ -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
+[ -f "${card}/kernel.elf" ] && USAGE already copied
+
+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}
+ cp -pr "${dir}" "${card}"
+ break
+ fi
+ dir="${i}/${d}"
+ if [ -d "${dir}" ]
+ then
+ echo copying directory: ${d}
+ cp -pr "${dir}" "${card}"
+ break
+ fi
+ done
+done
+
+echo copying base files
+for f in "${image}/"*
+do
+ [ ! -d "${f}" ] && cp -p "${f}" "${card}"
+done
+
+echo completed
View
@@ -0,0 +1,89 @@
+#!/bin/sh
+# push files to remotes
+
+ERROR()
+{
+ echo error: $*
+ exit 1
+}
+
+USAGE()
+{
+ [ -z "$1" ] || echo error: $*
+ echo usage: $(basename "$0") '<options>'
+ echo ' --help -h this message'
+ echo ' --list=<n-m> -l <n-m> restrict to certain machines [1-9]'
+ echo ' --dir=<dir> -d <dir> set destination directory'
+ echo ' --simul -2 switch to the other farm'
+ exit 1
+}
+
+# main program
+# ------------
+
+verbose=no
+dir=.
+list=''
+render_host=''
+
+getopt=/usr/local/bin/getopt
+[ -x "${getopt}" ] || getopt=getopt
+args=$(${getopt} -o hvl:d:2 --long=help,verbose,list:,dir:,simul -- "$@") || exit 1
+# replace the arguments with the parsed values
+eval set -- "${args}"
+
+while :
+do
+ case "$1" in
+ -v|--verbose)
+ verbose=yes
+ shift
+ ;;
+
+ -l|--list)
+ list="--list=$2"
+ shift 2
+ ;;
+
+ -d|--dir)
+ dir="$2"
+ shift 2
+ ;;
+
+ -2|--simul)
+ render_host='--host=simul3'
+ shift
+ ;;
+
+ --)
+ shift
+ break
+ ;;
+
+ -h|--help)
+ USAGE
+ ;;
+
+ *)
+ USAGE invalid option: $1
+ ;;
+ esac
+done
+
+for host in $(RenderDo ${render_host} ${list} --print-list)
+do
+ for sf in "$@"
+ do
+ df="wr@${host}:${dir}/${sf}"
+ case "${verbose}" in
+ [yY]|[yY][eE][sS])
+ echo Copy: ${sf} To: ${df}
+ ;;
+ *)
+ ;;
+ esac
+ scp -p "${sf}" "${df}"
+ done
+done
+
+echo completed
Oops, something went wrong.

0 comments on commit a55954f

Please sign in to comment.