#!/bin/sh
# command that checks opk version number
#set -e
VERSION=3
version ()
{
echo
echo "'basename $1' version $VERSION"
echo "command that checks opk version number"
echo
exit 0
}
usage ()
{
echo "
Usage: 'basename $1' <options> [ files for install partition ]
Mandatory options:
--opk_file file name (e.g ./my_package.opk)
Optional options:
--version Print version.
"
exit 1
}
# Process command line...
while [ $# -gt 0 ]; do
case $1 in
--help | -h)
usage $0
;;
--opk_file) shift; opk_file=$1; shift; ;;
--version) version $0;;
*) copy="$copy $1"; shift; ;;
esac
done
test -z $opk_file && usage $0
###########################
end parsing command line
###########################
ar -x $opk_file control.tar.gz #extract control.tar.gz from .opk
tar -zxvf control.tar.gz ./control > /dev/null 2>&1
# extract control file from control.tar.gz, silent stderr/stdout
cat control |grep Version | sed -e "s/Version:\s*\(\d*\)\D*//"
# grep Version keyword and remove it
rm control
rm control.tar.gz
# clean up
Uso:
opkversion.sh --opk_file ./mypackage.opk
Exemplo de saída:
9999
Ajuste o comando sed
para alterar a política de filtragem do comando (o número da versão de um pacote opk pode ser muito complicado).