-#----------------------------------------------------------------------
-# Useful functions.
-
-# erase_line filename regex
-#
-# Erase line(s) in a file that match the given regex.
-erase_line ()
-{
- $gf download "$1" "$tmpdir/file"
- sed "/$2/d" < "$tmpdir/file" > "$tmpdir/file.1"
- $gf upload "$tmpdir/file.1" "$1"
-}
-
-# prepend_line filename line
-#
-# Prepend a line to a file (this is better than appending, because it
-# works even when the original file isn't terminated with a newline).
-prepend_line ()
-{
- $gf download "$1" "$tmpdir/file"
- echo "$2" > "$tmpdir/file.1"
- cat "$tmpdir/file.1" "$tmpdir/file" >> "$tmpdir/file.2"
- $gf upload "$tmpdir/file.2" "$1"
-}
-
-# rm_files wildcard
-#
-# Remove files. Doesn't fail if no files exist. Note the wildcard
-# parameter cannot contain spaces or characters that need special
-# quoting.
-rm_files ()
-{
- files=$($gf glob-expand "$1")
- for f in $files; do
- $gf rm "$f"
- done
-}
-
-# rm_file filename
-#
-# Remove a single file. No error if the file doesn't exist or is not
-# a file.
-rm_file ()
-{
- t=$($gf is-file "$1")
- if [ "$t" = "true" ]; then
- $gf rm "$1"
- fi
-}
-
-#----------------------------------------------------------------------
-# The sysprep operations.
-