2012-01-27 01:04:47 +01:00
|
|
|
#############################################
|
|
|
|
# void retrieve_file (src, dst)
|
|
|
|
#
|
|
|
|
# Description: retrieve file from an URL
|
2013-03-07 21:38:36 +01:00
|
|
|
#
|
2012-01-27 01:04:47 +01:00
|
|
|
# Parameter
|
2012-01-30 23:07:08 +01:00
|
|
|
# downloader: program to download the files
|
2012-01-27 01:04:47 +01:00
|
|
|
# src: source url to get file from
|
|
|
|
# dst: path to store file to
|
|
|
|
#
|
|
|
|
#############################################
|
|
|
|
function retrieve_file() {
|
2013-03-07 21:38:36 +01:00
|
|
|
local downloader=$1
|
|
|
|
local src=$2
|
|
|
|
local dst=$3
|
|
|
|
|
|
|
|
# Check, if the URL is a file URL starting with file://
|
|
|
|
if [ -f $dst ] && [ -z ${DIST_FORCE_DOWNLOAD} ]; then
|
|
|
|
echo " Info: File still cached/downloaded. To force a download, set DIST_FORCE_DOWNLOAD=1"
|
2012-01-27 01:04:47 +01:00
|
|
|
elif [[ $src == file://* ]]; then
|
2013-03-07 21:38:36 +01:00
|
|
|
fileurl=`echo $src | sed "s/^file:\/\///"`
|
|
|
|
cp $fileurl $dst 2>/dev/null
|
|
|
|
else
|
|
|
|
rm -f $dst
|
|
|
|
if [ "$downloader" = "wget" ]; then
|
2013-06-24 19:47:07 +02:00
|
|
|
wget --no-check-certificate --tries=1 -O $dst --timeout=5 -q --no-verbose "$src"
|
2013-03-07 21:38:36 +01:00
|
|
|
if [ "$?" == "1" ] ; then
|
|
|
|
rm $dst
|
|
|
|
fi
|
|
|
|
elif [ "$downloader" = "plowdown" ]; then
|
|
|
|
plowdown --max-retries=1 -o ${dst%/*} "$src"
|
|
|
|
elif [ "$downloader" = "aria2c" ]; then
|
|
|
|
#aria2c --seed-time=0 -d ${dst%/*} -o ${dst##*/} "$src"
|
|
|
|
aria2c --seed-time=0 --allow-overwrite=true -o ${dst##*/} "$src"
|
|
|
|
mv -f ${dst##*/} ${dst%/*}
|
2012-01-27 01:04:47 +01:00
|
|
|
else
|
2013-03-07 21:38:36 +01:00
|
|
|
fatal_error "Downloader not implemented: $downloader"
|
|
|
|
fi
|
|
|
|
fi
|
2012-01-27 01:04:47 +01:00
|
|
|
}
|
|
|
|
|
2012-01-29 09:11:01 +01:00
|
|
|
#############################################
|
2012-01-30 23:07:08 +01:00
|
|
|
# void extract_file (format, src, dst)
|
2012-01-29 09:11:01 +01:00
|
|
|
#
|
|
|
|
# Description: Extract a file
|
2013-03-07 21:38:36 +01:00
|
|
|
#
|
2012-01-29 09:11:01 +01:00
|
|
|
# Parameter
|
2012-01-30 23:07:08 +01:00
|
|
|
# format: compression format
|
2012-01-29 09:11:01 +01:00
|
|
|
# src: source file to be used
|
|
|
|
# dst: path to extract the file
|
|
|
|
#
|
|
|
|
#############################################
|
2012-01-30 23:07:08 +01:00
|
|
|
function process_file() {
|
2013-03-07 21:38:36 +01:00
|
|
|
|
|
|
|
local format=$1
|
|
|
|
local src=$2
|
|
|
|
local dst=$3
|
2013-03-28 14:38:45 +01:00
|
|
|
local option=$4
|
2013-03-07 21:38:36 +01:00
|
|
|
|
|
|
|
log_debug "Compression format: $format"
|
|
|
|
|
|
|
|
if [ "$format" = "cp" ]; then
|
|
|
|
cp $src $dst
|
2012-01-30 23:07:08 +01:00
|
|
|
elif [ "$format" = "7zip" ]; then
|
2013-03-28 14:38:45 +01:00
|
|
|
$CMD_7z x -y $option -o$dst $src
|
2012-01-31 20:53:55 +01:00
|
|
|
elif [ "$format" = "unzip" ]; then
|
2013-03-28 14:38:45 +01:00
|
|
|
$CMD_unzip $option -o $src -d $dst
|
2012-02-18 15:18:46 +01:00
|
|
|
elif [ "$format" = "unrar" ]; then
|
2013-03-28 14:38:45 +01:00
|
|
|
$CMD_unrar x -y $option $src $dst
|
2012-04-20 03:30:46 +02:00
|
|
|
elif [ "$format" = "lha" ]; then
|
2013-03-28 14:38:45 +01:00
|
|
|
$CMD_lha x $option -w=$dst $src
|
2012-05-16 06:32:07 +02:00
|
|
|
elif [ "$format" = "targz" ]; then
|
2013-03-28 14:38:45 +01:00
|
|
|
$CMD_tar xzvf $option $src -C $dst
|
2012-05-16 06:32:07 +02:00
|
|
|
elif [ "$format" = "tarbz2" ]; then
|
2013-03-28 14:38:45 +01:00
|
|
|
$CMD_tar xjvf $option $src -C $dst
|
2012-10-30 16:22:30 +01:00
|
|
|
elif [ "$format" = "cab" ]; then
|
2013-03-28 14:38:45 +01:00
|
|
|
$CMD_cabextract $option -d $dst $src
|
2013-03-07 21:38:36 +01:00
|
|
|
else
|
|
|
|
fatal_error "Unknown compression format: $format"
|
|
|
|
fi
|
2012-01-29 09:11:01 +01:00
|
|
|
}
|
|
|
|
|
2012-01-27 01:04:47 +01:00
|
|
|
|
|
|
|
#############################################
|
|
|
|
# check if method is available and call it
|
|
|
|
#############################################
|
|
|
|
function call_entry_point() {
|
2013-03-07 21:38:36 +01:00
|
|
|
local _resultvar=$1
|
|
|
|
local func=$2
|
|
|
|
|
|
|
|
# Entry point
|
|
|
|
type $func &>/dev/null
|
|
|
|
if [ $? == 0 ] ; then
|
|
|
|
$func
|
|
|
|
eval $_resultvar="0"
|
|
|
|
else
|
|
|
|
eval $_resultvar="1"
|
|
|
|
fi
|
|
|
|
|
2012-01-27 01:04:47 +01:00
|
|
|
}
|
|
|
|
|
2012-01-30 23:07:08 +01:00
|
|
|
###################
|
|
|
|
# Fata Error
|
|
|
|
###################
|
|
|
|
fatal_error() {
|
2013-03-07 21:38:36 +01:00
|
|
|
echo "FATAL: $1"
|
|
|
|
exit 1
|
2012-01-30 23:07:08 +01:00
|
|
|
}
|
2012-01-27 01:04:47 +01:00
|
|
|
|
|
|
|
###################
|
|
|
|
# Check error
|
|
|
|
###################
|
|
|
|
builder_check_error() {
|
2013-03-07 21:38:36 +01:00
|
|
|
if [ "$?" == "1" ] ; then
|
|
|
|
fatal_error "$1"
|
|
|
|
fi
|
2012-01-27 01:04:47 +01:00
|
|
|
}
|
|
|
|
|
2012-01-30 23:07:08 +01:00
|
|
|
###################
|
|
|
|
# Logging Debug
|
|
|
|
###################
|
2012-01-29 16:58:12 +01:00
|
|
|
log_debug() {
|
2013-03-07 21:38:36 +01:00
|
|
|
local str=$1
|
|
|
|
|
|
|
|
if [ "$DEBUG_LEVEL" = "debug" ] || [ "$DEBUG_LEVEL" = "info" ] ; then
|
|
|
|
echo $str
|
|
|
|
fi
|
2012-01-29 16:58:12 +01:00
|
|
|
}
|
|
|
|
|
2012-01-30 23:07:08 +01:00
|
|
|
###################
|
|
|
|
# Logging Info
|
|
|
|
###################
|
|
|
|
log_info() {
|
2013-03-07 21:38:36 +01:00
|
|
|
local str=$1
|
|
|
|
|
|
|
|
if [ "$DEBUG_LEVEL" = "info" ] ; then
|
|
|
|
echo $str
|
|
|
|
fi
|
2012-01-30 23:07:08 +01:00
|
|
|
}
|
|
|
|
|
2012-02-06 14:20:56 +01:00
|
|
|
#####################
|
2013-03-07 21:38:36 +01:00
|
|
|
# void calc_release()
|
2012-02-06 14:20:56 +01:00
|
|
|
#
|
|
|
|
# Description:
|
|
|
|
# Calculate new release based on
|
|
|
|
# the latest one found in the repository.
|
2013-03-07 21:38:36 +01:00
|
|
|
#
|
2012-02-06 14:20:56 +01:00
|
|
|
# $RELEASE is set to the calculated release.
|
2013-03-07 21:38:36 +01:00
|
|
|
#
|
2012-02-06 14:20:56 +01:00
|
|
|
####################
|
|
|
|
function calc_release() {
|
2013-03-07 21:38:36 +01:00
|
|
|
|
|
|
|
# Find all revision files and sort them
|
2013-09-09 05:06:01 +02:00
|
|
|
local file_list=`mktemp /tmp/aio-builder.calc_release.XXXXXXXXXXX`
|
|
|
|
for cfg_file in `find ${AIO_REPOS_BASE_DIR} -name "${PN}-${VERSION}-${CREATOR_TAG}*.cfg" -print ` ; do
|
2013-03-07 21:38:36 +01:00
|
|
|
. ${cfg_file}
|
|
|
|
printf "%08d;$cfg_file\n" $REV_RELEASE >> ${file_list}
|
|
|
|
done
|
|
|
|
local oldest_cfg=`sort -n ${file_list} | cut -f 2 -d ";" | tail -1`
|
|
|
|
rm -f ${file_list}
|
|
|
|
|
|
|
|
if [ ! -f "${oldest_cfg}" ] ; then
|
|
|
|
echo "Warning: no cfg-file found for this product. RELEASE will be set to 1"
|
|
|
|
RELEASE=1
|
|
|
|
else
|
|
|
|
log_debug "calc_release() oldest_cfg: ${oldest_cfg}"
|
|
|
|
. ${oldest_cfg}
|
|
|
|
log_debug " latest release: $REV_RELEASE"
|
|
|
|
RELEASE=`expr ${REV_RELEASE} + 1 2> /dev/null`
|
|
|
|
builder_check_error "Cannot incrememnt REV_RELEASE from file ${oldest_cfg}"
|
|
|
|
fi
|
|
|
|
}
|
2012-02-06 14:20:56 +01:00
|
|
|
|
2013-03-07 21:38:36 +01:00
|
|
|
###################
|
|
|
|
# Write Package Ini file
|
|
|
|
#
|
|
|
|
# Create a ini file containing needed information for package uninstall
|
|
|
|
#
|
|
|
|
# Parameter
|
|
|
|
# file: file to create / modify
|
|
|
|
#
|
|
|
|
###################
|
|
|
|
write_ini_file() {
|
|
|
|
local ini_file=$1
|
2013-09-09 05:06:01 +02:00
|
|
|
local ini_section=$2
|
|
|
|
local ini_option=$3
|
|
|
|
local ini_value=$4
|
|
|
|
|
2013-03-08 14:15:35 +01:00
|
|
|
touch $ini_file
|
2013-09-09 05:06:01 +02:00
|
|
|
$CMD_inifile $(cygpath -pw "$ini_file") [$ini_section] $ini_option=$ini_value
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
###################
|
|
|
|
# Get Verison of File
|
|
|
|
#
|
|
|
|
# Copy file only if it is newer
|
|
|
|
#
|
|
|
|
# Parameter
|
|
|
|
# File: to process
|
|
|
|
# Var:
|
|
|
|
#
|
|
|
|
###################
|
|
|
|
get_file_version() {
|
|
|
|
local getver_file=$1
|
|
|
|
local getver_var=$2
|
2013-03-08 14:15:35 +01:00
|
|
|
|
2013-09-09 05:06:01 +02:00
|
|
|
if [ -f "$getver_file" ] ; then
|
|
|
|
$CMD_showver $getver_file | grep FileVersion: | rev | cut -d: -f1 | rev | tr -d ' ' > $getver_ver
|
|
|
|
echo "file $getver_file has version $getver_ver"
|
|
|
|
else
|
|
|
|
echo "$getver_file not found"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
###################
|
|
|
|
# Copy Verison
|
|
|
|
#
|
|
|
|
# Copy file only if it is newer
|
|
|
|
#
|
|
|
|
# Parameter
|
|
|
|
# source: sourcefiel
|
|
|
|
# target: Targetfile
|
|
|
|
#
|
|
|
|
###################
|
|
|
|
copyver() {
|
|
|
|
local source_file=$1
|
|
|
|
local target_file=$2
|
|
|
|
local source_ver
|
|
|
|
local target_ver
|
2013-03-10 05:57:28 +01:00
|
|
|
|
2013-09-09 05:06:01 +02:00
|
|
|
get_file_version $source_file $source_ver
|
2012-02-06 14:20:56 +01:00
|
|
|
}
|
2013-03-07 21:38:36 +01:00
|
|
|
|
2013-03-07 22:43:46 +01:00
|
|
|
###################
|
2013-09-09 05:06:01 +02:00
|
|
|
# Tidy xml
|
2013-03-07 22:43:46 +01:00
|
|
|
#
|
2013-09-09 05:06:01 +02:00
|
|
|
# Tidy XML files (mainly Sereby package.xml)
|
2013-03-07 22:43:46 +01:00
|
|
|
#
|
|
|
|
# Parameter
|
2013-09-09 05:06:01 +02:00
|
|
|
# source: sourcefiel
|
|
|
|
# target: Targetfile
|
2013-03-07 22:43:46 +01:00
|
|
|
#
|
|
|
|
###################
|
2013-09-09 05:06:01 +02:00
|
|
|
tidy_xml() {
|
|
|
|
local source_file=$1
|
|
|
|
local target_file=$2
|
2013-03-07 22:43:46 +01:00
|
|
|
|
2013-09-09 05:06:01 +02:00
|
|
|
cat $source_file | $CMD_tidy -utf8 -xml -w 255 -i -c -q -asxml | sed -e 's!>!>!g' -e 's!<!<!g' > $target_file
|
2013-03-07 22:43:46 +01:00
|
|
|
}
|
|
|
|
|