Skip to content

Instantly share code, notes, and snippets.

@marri5317
Created June 4, 2018 12:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marri5317/986e41039debf27c3a6dd995ffff1596 to your computer and use it in GitHub Desktop.
Save marri5317/986e41039debf27c3a6dd995ffff1596 to your computer and use it in GitHub Desktop.
Script to generate flashcontents file from listfile.sig, required for building amino firmware.
#!/bin/bash
display_usage() {
echo -e "\nUsage: $0 listfile.sig\n"
}
create_flashcontents_file() {
# check if flashcontents already exist
if [ -f flashcontents ]; then
echo "File flashcontents already exists!"
exit 1
fi
touch flashcontents
# check whether file creation was succesful
if [ ! -f flashcontents ]; then
echo "File flashcontents could not be created!"
exit 1
fi
}
write_flashcontents_file() {
while IFS=' ' read -ra entry
do
# if no mode/hash is supplied mark file as writeable
if [[ ${entry[1]} == '' ]]; then
entry[1]='W'
fi
echo "${entry[1]} ${entry[0]}" >> flashcontents
done < "$file"
}
# if less than two arguments supplied, display usage
if [ $# -le 0 ]
then
display_usage
exit 1
fi
# rewrite to absolute path if necessary
if [[ ! ${1:0:1} == "/" ]]; then
file=$PWD/$1
fi
# check whether the given file actually exists
if [ ! -f "$file" ]; then
echo "Supplied file does not exist!"
exit 1
fi
# check whether user had supplied -h or --help . If yes display usage
if [[ ( $# == "--help") || $# == "-h" ]]
then
display_usage
exit 0
fi
# create flashcontents file in current working directory
create_flashcontents_file
# write file entries to flashcontents file
write_flashcontents_file
# all done!
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment