Commit cf6bee1b authored by sebt3's avatar sebt3
Browse files

initial commit

parents
Pipeline #53 failed with stages
FROM debian:buster-slim AS stage
RUN apt-get update && apt-get install -y qemu-user-static wget
RUN mkdir -p /source/usr/bin && cp /usr/bin/qemu-arm-static /source/usr/bin/
COPY bashlibs/* /target/usr/lib/bashlibs/
COPY entrypoint.sh /target/usr/bin/
COPY env.sh /target/etc/profile.d/
COPY install.sh /target/toolchain/
RUN chmod +x /target/usr/bin/entrypoint.sh /target/toolchain/install.sh \
&& mkdir -p /target/drone/src
RUN wget -O /tmp/pyra-rootfs.tgz http://packages.pyra-handheld.com/images/buster/pyra-debian-buster-mate-rootfs.tgz
RUN tar -C /source -xf /tmp/pyra-rootfs.tgz && cp /usr/bin/qemu-arm-static /source/usr/bin/
FROM scratch as source
COPY --from=stage /source/ /
RUN apt-get update \
&& apt-get install -y libbz2-dev libfreetype6-dev libgles2-mesa-dev libsamplerate0-dev libsasl2-dev libsdl2-dev libsdl2-gfx-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-net-dev libsdl2-ttf-dev libsdl-gfx1.2-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-net1.2-dev libsdl-sound1.2-dev libsdl-ttf2.0-dev libsndfile1-dev libv4l-dev libjpeg62-turbo-dev ca-certificates
FROM debian:buster-slim
COPY --from=stage /target/ /
COPY --from=source / /toolchain/rootfs/
RUN apt-get update \
&& apt-get install -y gawk \
&& /toolchain/install.sh install
WORKDIR /drone/src
CMD ["/usr/bin/entrypoint.sh"]
FROM debian:buster-slim AS stage
RUN apt-get update && apt-get install -y qemu-user-static wget
RUN mkdir -p /source/usr/bin && cp /usr/bin/qemu-arm-static /source/usr/bin/
COPY bashlibs/* /target/usr/lib/bashlibs/
COPY entrypoint.sh /target/usr/bin/
COPY env.sh /target/etc/profile.d/
COPY install.sh /target/toolchain/
RUN chmod +x /target/usr/bin/entrypoint.sh /target/toolchain/install.sh \
&& mkdir -p /target/drone/src
FROM arm32v7/debian:buster-slim AS source
COPY --from=stage /source/ /
RUN apt-get update \
&& apt-get install -y libsdl1.2-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-net1.2-dev libsdl-ttf2.0-dev libsdl-gfx1.2-dev libsdl2-dev libsdl2-gfx-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-net-dev libsdl2-ttf-dev libsdl-sound1.2-dev ca-certificates
FROM debian:buster-slim
COPY --from=stage /target/ /
COPY --from=source / /toolchain/rootfs/
RUN apt-get update \
&& apt-get install -y gawk \
&& /toolchain/install.sh install
WORKDIR /drone/src
CMD ["/usr/bin/entrypoint.sh"]
#!/bin/bash
# BSD 3-Clause License
#
# Copyright (c) 2017-2020, Sébastien Huss
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# * Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
SCRIPT_file=${0##*/}
SCRIPT_name=${SCRIPT_file%.sh}
SCRIPT_path=$(dirname "$(readlink -f "$0")")
is.set() { [ ! -z ${!1+x} ]; }
is.number() { [[ $1 =~ ^-?[0-9]+$ ]]; }
is.function() { typeset -f $1 >/dev/null; }
is.array() { is.set $1 && [[ "$(declare -p $1)" =~ "declare -a" ]]; }
array.have () { local e match="$1";shift;for e; do [[ "$e" == "$match" ]] && return 0; done;return 1; }
OUT_levels=(NONE FAIL ERROR OK TASK WARNING STDERR NOTICE CMD INFO STDOUT DETAIL ASSERT ALL)
OUT_level=${OUT_level:-STDOUT}
out.levelID() {
local i
for (( i=0; i<${#OUT_levels[@]}; i++));do
if [[ "$1" = "${OUT_levels[$i]}" ]];then
echo $i
return
fi
done
echo 0
}
OUT_color=()
OUT_color[$(out.levelID NONE)]="${OUT_color[$(out.levelID NONE)]:-$(tput sgr0)}"
OUT_color[$(out.levelID FAIL)]="${OUT_color[$(out.levelID FAIL)]:-$(tput setb 4;tput setab 1)}"
OUT_color[$(out.levelID ERROR)]="${OUT_color[$(out.levelID ERROR)]:-$(tput setf 4;tput setaf 1)}"
OUT_color[$(out.levelID STDERR)]="${OUT_color[$(out.levelID STDERR )]:-$(tput setf 4;tput setaf 1)}"
OUT_color[$(out.levelID OK)]="${OUT_color[$(out.levelID OK)]:-$(tput setf 2;tput setaf 2)}"
OUT_color[$(out.levelID WARNING)]="${OUT_color[$(out.levelID WARNING)]:-$(tput setf 6;tput setaf 3)}"
OUT_color[$(out.levelID INFO)]="${OUT_color[$(out.levelID INFO)]:-$(tput setf 3;tput setaf 4)}"
OUT_color[$(out.levelID NOTICE)]="${OUT_color[$(out.levelID NOTICE)]:-$(tput setf 5;tput setaf 13)}"
OUT_color[$(out.levelID DETAIL)]="${OUT_color[$(out.levelID DETAIL)]:-$(tput setf 3;tput setaf 11)}"
OUT_color[$(out.levelID ASSERT)]="${OUT_color[$(out.levelID ASSERT)]:-$(tput setf 3;tput setaf 12)}"
OUT_color[$(out.levelID CMD)]="${OUT_color[$(out.levelID CMD)]:-$(tput setf 6;tput setaf 4)}"
OUT_cmd=()
OUT_needLF=()
OUT_closeLF=()
out.init() {
[ -x /usr/bin/resize ] && eval $(/usr/bin/resize) >/dev/null 2>&1
local space="\033[$((${COLUMNS:-80} - 11))G"
OUT_fd=1
for lvl in ${OUT_levels[*]};do
if [[ $lvl = "NONE" || $lvl = "ALL" ]];then continue;fi
OUT_id=$(out.levelID $lvl)
case "$lvl" in
TASK) OUT_cmd[$OUT_id]="${OUT_cmd[$OUT_id]:-"printf '\\r[ %7s ] %s' \"\" \"\$*\""}";;
STDOUT) OUT_cmd[$OUT_id]="${OUT_cmd[$OUT_id]:-"printf '\\r%s\\n' \"\$*\""}";;
CMD) OUT_cmd[$OUT_id]="${OUT_cmd[$OUT_id]:-"printf '\\r${OUT_color[$OUT_id]}%s>${OUT_color[$(out.levelID NONE)]} %s\\n' $lvl \"\$*\""}";;
*) OUT_cmd[$OUT_id]="${OUT_cmd[$OUT_id]:-"printf '\\r[ ${OUT_color[$OUT_id]}%7s${OUT_color[$(out.levelID NONE)]} ] %s\\n' $lvl \"\$*\""}";;
esac
echo "${OUT_cmd[$OUT_id]}"|grep -q '\\n'
OUT_needLF[$OUT_id]=$?
case "$lvl" in
FAIL|OK) OUT_closeLF[$OUT_id]=1;;
*) OUT_closeLF[$OUT_id]=0;;
esac
done
OUT_levelID=$(out.levelID $OUT_level)
OUT_levelID=${OUT_levelID:-$(out.levelID STDOUT)}
OUT_currentLF=0
}
out.lvl() {
local lvl=$1;shift
local id=$(out.levelID $lvl)
id=${id:-10}
local cmd=${OUT_cmd[$id]}
if [ $id -le ${OUT_levelID:-13} ];then
[ $OUT_currentLF -eq 1 ] && [ ${OUT_closeLF[$id]} -ne 1 ] && eval "echo >&${OUT_fd:-1}"
OUT_currentLF=0
[ ${OUT_needLF[$id]} -eq 1 ] && OUT_currentLF=1
eval "${cmd:-"printf '\\r%s\\n' \"\$*\""} >&${OUT_fd:-1}"
fi
log.lvl "$lvl" "$*"
return 0
}
out.return() {
local id=$(out.levelID $1)
[ ${id:-10} -le ${OUT_levelID:-13} ] && eval "printf '\\n' >&${OUT_fd:-1}"
}
out.put() { while read line;do out.lvl STDOUT "$line";done; }
out.error() { out.lvl ERROR "$*"; }
out.ok() { out.lvl OK "$*"; }
out.warn() { out.lvl WARNING "$*"; }
out.info() { out.lvl INFO "$*"; }
out.notice() { out.lvl NOTICE "$*"; }
out.detail() { out.lvl DETAIL "$*"; }
out.task() { out.lvl TASK "$*"; }
out.fail() { out.lvl FAIL "$*";exit 1; }
out.cmd() { out.lvl CMD "$@";eval "$@" 2>&1|out.put; test ${PIPESTATUS[0]} -eq 0; }
log.stamp() { date '+%Y%m%d_%H%M%S'; }
log.separator() { local c=${1:-"="};awk -v "V=$c" 'BEGIN{while (c++<80) printf V;printf "\n"}';}
LOG_dir=${LOG_dir:-"$SCRIPT_path"}
LOG_file=${LOG_file:-"${SCRIPT_name}.log.$(log.stamp)"}
LOG_cmd=${LOG_cmd:-'printf "[$(log.stamp) - %-7s ] %s\n" "$lvl" "$text"'}
LOG_level=${LOG_level:-ALL}
LOG_head=(ARGS_cmd USER PWD)
log.lvl() {
local lvl=$1;shift
local text="$*"
local id=$(out.levelID $lvl)
if [ ${id:-10} -le ${LOG_levelID:-0} ];then
if [[ "$lvl" = "TASK" ]];then
[ $OUT_fd -eq 1 ] && log.separator >> $LOG_dir/$LOG_file
[ $OUT_fd -ne 1 ] && eval "log.separator >&${LOG_fd:-1}"
fi
[ $OUT_fd -eq 1 ] && eval "$LOG_cmd" >> $LOG_dir/$LOG_file
[ $OUT_fd -ne 1 ] && eval "$LOG_cmd >&${LOG_fd:-1}"
fi
}
log.start() {
local i=0
out.init
LOG_levelID=$(out.levelID ${LOG_level:-ALL})
[ ${LOG_levelID} -eq 0 ] && return 0
exec 4>&1
exec 1>>$LOG_dir/$LOG_file 2>&1
OUT_fd=4
LOG_fd=1
log.separator "#"
for i in ${LOG_head[*]};do
printf "%-15s : %s\n" "$i" "$(eval echo "\$$i")"
done
log.separator "#"
}
log.end() {
local R=${1:-$?}
[ ${LOG_levelID:-15} -eq 0 ] || log.separator "#"
[ $R -ne 0 ] && out.error "This script returned $R" || out.detail "This script succeded"
[ ${LOG_levelID:-15} -eq 0 ] || log.separator "#"
[ ${LOG_levelID:-15} -eq 0 ] || exec >&- >&4
OUT_fd=1
return $R
}
ARGS_vars=()
ARGS_short=()
ARGS_long=()
ARGS_haveVal=()
ARGS_mandatory=()
ARGS_validate=()
ARGS_option=()
ARGS_desc=()
ARGS_cb=()
ARGS_info=${ARGS_info:-''}
ARGS_cmd="$*"
ARGS_short_cmd=()
ARGS_helpCallback=${ARGS_helpCallback:-""}
args.declare() {
local ARGS_cnt=${#ARGS_vars[@]}
ARGS_validate[$ARGS_cnt]="N"
if [[ $1 == "DoValidate" ]];then
ARGS_validate[$ARGS_cnt]="Y"
shift
fi
LOG_head+=($1)
ARGS_cb[$ARGS_cnt]=""
ARGS_vars[$ARGS_cnt]=$1;shift
ARGS_short[$ARGS_cnt]=$1;shift
ARGS_long[$ARGS_cnt]=$1;shift
case $1 in
Y*|y*|1|V*|v*) ARGS_haveVal[$ARGS_cnt]='Y';shift;;
*) ARGS_haveVal[$ARGS_cnt]='N';eval "${ARGS_vars[$ARGS_cnt]}=N";shift;;
esac
case $1 in
Y*|y*|1|o*|O*) ARGS_option[$ARGS_cnt]='Y';eval "ARGS_values_${ARGS_vars[$ARGS_cnt]}=();ARGS_desc_${ARGS_vars[$ARGS_cnt]}=()";shift;;
*) ARGS_option[$ARGS_cnt]='N';shift;;
esac
case $1 in
Y*|y*|1|m*|M*) ARGS_mandatory[$ARGS_cnt]='Y';shift;;
*) ARGS_mandatory[$ARGS_cnt]='N';shift;;
esac
ARGS_desc[$ARGS_cnt]="$*";
}
args.callback() {
local i v=$1;shift
for (( i=0; i<${#ARGS_vars[@]}; i++ ));do
if [[ ${ARGS_vars[$i]} == $v ]];then
ARGS_cb[$i]="$*"
fi
done
}
args.option.declare() {
local V=$1;shift;
local s=$1;shift;
local l=$1;shift;
local m=$1;shift;
local c="";
case $1 in
Y*|y*|1|V*|v*|C*|c*) c="DoValidate";;
esac
shift;
args.declare $c "$V" "$s" "$l" Vals Option $m "$*"
}
args.option() {
local A=$1;shift;local V=$1;shift
eval "ARGS_values_$A+=($V)"
eval "ARGS_desc_${A}+=('$*')"
}
args.use.help() {
args.declare ARGS_help -h --help NoVal NoOption NotMandatory Show this help text
}
args.help() {
local l="$0"
local s="$0"
local v=""
local n=0
local i=0
if is.set ARGS_short_cmd;then
ARGS_tmp=("${ARGS_short_cmd[@]}")
while is.set ARGS_tmp;do
v=${ARGS_tmp[0]};ARGS_tmp=("${ARGS_tmp[@]:1}")
for (( i=0; i<${#ARGS_vars[@]}; i++ ));do
if [[ "${ARGS_vars[$i]}" == "$v" ]];then
if [[ "${ARGS_mandatory[$i]}" = "Y" ]];then
s="$s $v"
else
s="$s [$v]"
fi
fi
done
done
fi
for (( i=0; i<${#ARGS_vars[@]}; i++ ));do
v="${ARGS_short[$i]}|${ARGS_long[$i]}"
[[ "${ARGS_haveVal[$i]}" = "Y" ]] && v="$v ${ARGS_vars[$i]}"
if [[ "${ARGS_mandatory[$i]}" = "Y" ]];then
l="$l $v"
else
l="$l [$v]"
fi
done
[ -n "$ARGS_info" ] && echo "$ARGS_info"
echo $l
is.set ARGS_short_cmd && echo $s
for (( i=0; i<${#ARGS_vars[@]}; i++ ));do
v="${ARGS_short[$i]}|${ARGS_long[$i]}"
[[ "${ARGS_haveVal[$i]}" = "Y" ]] && v="$v ${ARGS_vars[$i]}"
printf "%-25s: %s\n" "$v" "${ARGS_desc[$i]}"
done
for (( i=0; i<${#ARGS_vars[@]}; i++ ));do
if [[ "${ARGS_option[$i]}" = "Y" ]];then
echo;echo "Available values for ${ARGS_vars[$i]} (${ARGS_desc[$i]}):";n=0
for j in $(eval "echo \${ARGS_values_${ARGS_vars[$i]}[*]}");do
l=$(eval "echo \${ARGS_desc_${ARGS_vars[$i]}[$n]}")
n=$(( $n +1 ))
printf "%-25s: %s\n" "$j" "$l"
done
fi
done
echo
if [ ! -z "$ARGS_helpCallback" ] && is.function "$ARGS_helpCallback";then
$ARGS_helpCallback
echo
fi
}
args.parse() {
local f=0
out.init
if is.function args.pre;then
args.pre
fi
if [ $# -gt 0 ] && [[ "$1" == -* ]];then
while [ $# -gt 0 ];do
f=0
for (( i=0; i<${#ARGS_vars[@]}; i++ ));do
case "$1" in
${ARGS_short[$i]}|${ARGS_long[$i]})
if [[ "${ARGS_vars[$i]}" = "ARGS_help" ]];then
args.help
exit 0
elif [[ "${ARGS_haveVal[$i]}" != "Y" ]];then
eval "${ARGS_vars[$i]}=Y"
ARGS_mandatory[$i]='N'
f=1
elif [ $# -lt 2 ];then
out.error "$1 expect a value"
args.help
out.error "$1 expect a value"
exit 1
elif [[ "${ARGS_option[$i]}" = "Y" ]] && [[ "${ARGS_validate[$i]}" = "Y" ]];then
for j in $(eval "echo \${ARGS_values_${ARGS_vars[$i]}[*]}");do
[[ "$2" = "$j" ]] && f=1
done
if [ $f -eq 0 ];then
out.error "\"$2\" is an invalid value for \"${ARGS_desc[$i]}\" ($1)"
args.help
out.error "\"$2\" is an invalid value for \"${ARGS_desc[$i]}\" ($1)"
exit 1
fi
eval "${ARGS_vars[$i]}=\"$2\"";
ARGS_mandatory[$i]='N'
shift
else
eval "${ARGS_vars[$i]}=\"$2\"";
ARGS_mandatory[$i]='N'
f=1
shift
fi
if [[ "${ARGS_cb[$i]}" != "" ]];then
local v=$(eval echo \$${ARGS_vars[$i]})
if ! ${ARGS_cb[$i]} $v;then
out.error "\"$v\" is an invalid value for \"${ARGS_vars[$i]}\""
args.help
out.error "\"$v\" is an invalid value for \"${ARGS_vars[$i]}\""
exit 1
fi
fi;;
esac
done
if [ $f -eq 0 ];then
out.error "Unknown flag \"$1\""
args.help
out.error "Unknown flag \"$1\""
exit 1
fi
shift
done
elif [ $# -gt 0 ] && is.set ARGS_short_cmd;then
ARGS_tmp=("${ARGS_short_cmd[@]}")
while is.set ARGS_tmp;do
[ $# -eq 0 ] && break;
v=${ARGS_tmp[0]};ARGS_tmp=("${ARGS_tmp[@]:1}")
for (( i=0; i<${#ARGS_vars[@]}; i++ ));do
if [[ "${ARGS_vars[$i]}" == "$v" ]];then
ARGS_mandatory[$i]='N'
if [[ "${ARGS_option[$i]}" = "Y" ]] && [[ "${ARGS_validate[$i]}" = "Y" ]];then
f=0
for j in $(eval "echo \${ARGS_values_${ARGS_vars[$i]}[*]}");do
[[ "$1" = "$j" ]] && f=1
done
if [ $f -eq 0 ];then
out.error "\"$1\" is an invalid value for \"$v\""
args.help
out.error "\"$1\" is an invalid value for \"$v\""
exit 1
fi
fi
if is.set ARGS_tmp;then
eval "${ARGS_vars[$i]}=\"$1\"";
else
eval "${ARGS_vars[$i]}=\"$*\"";
fi
if [[ "${ARGS_cb[$i]}" != "" ]];then
if ! ${ARGS_cb[$i]} $1;then
out.error "\"$1\" is an invalid value for \"${ARGS_vars[$i]}\""
args.help
out.error "\"$1\" is an invalid value for \"${ARGS_vars[$i]}\""
exit 1
fi
fi
shift;break
fi
done
done
fi
f=0
for (( i=0; i<${#ARGS_vars[@]}; i++ ));do
if [[ "${ARGS_mandatory[$i]}" = "Y" ]];then
f=1
out.error "flag ${ARGS_long[$i]} should be used"
args.help
out.error "flag ${ARGS_long[$i]} should be used"
exit 3
fi
done
if is.function args.post;then
args.post
fi
}
cfg.file.exist() {
[ -r "$CFG_file" ]
}
cfg.exist() {
cfg.file.exist || return 2
awk -v P="$1" -F= 'BEGIN{R=1}END{exit R}$1~"^"P"[ ]*$"{R=0}'<"$CFG_file"
}
cfg.get() {
cfg.file.exist || return 2
awk -v P="$1" -F= '$1~"^"P"[ ]*$"{sub("^[ ]*","",$2);print $2}' < "$CFG_file"
}
#!/bin/bash
# BSD 3-Clause License
#
# Copyright (c) 2019-2020, Sébastien Huss
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# * Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
################################################################################
###
## install functions
#
chroot.mount() {
if awk -v D="$DEST/rootfs$1" 'BEGIN{R=1}$2==D{R=0}END{exit R}'</etc/mtab;then
out.info "$1 already mounted, skipping"
else
out.cmd mount --bind $1 $DEST/rootfs$1
fi
}
chroot.umount() {
if awk -v D="$DEST/rootfs$1" 'BEGIN{R=1}$2==D{R=0}END{exit R}'</etc/mtab;then
out.cmd umount $DEST/rootfs$1
fi
}
chroot.cmd() {
unset LD_PRELOAD;export LANG=C;
chroot.mount /dev
chroot.mount /dev/pts
chroot.mount /proc
out.cmd chroot $DEST/rootfs "$@"
chroot.umount /proc
chroot.umount /dev/pts
chroot.umount /dev
}
rootfs.fix() {
local la pc d
for la in $(find $DEST/rootfs -type f -name '*.la');do
sed -i "s#libdir='/usr/lib#libdir='$DEST/rootfs/usr/lib#g" $la
done
for d in $(find $DEST/rootfs -name pkgconfig -type d);do
for pc in $(find $d -name '*pc');do
sed -i "s#prefix=/usr\$#prefix=$DEST/rootfs/usr#g;s#libdir=/usr/lib#libdir=$DEST/rootfs/usr/lib#g;s#includedir=/usr/include#includedir=$DEST/rootfs/usr/include#g" $pc
done
done
mkdir -p $DEST/bin
for f in $(find $DEST/rootfs/usr/bin -type f -name "*-config");do
if file $f|grep -q shell;then
cp -f $f $DEST/bin
sed -i "s#prefix=/usr\$#prefix=$DEST/rootfs/usr#g;s#libdir=/usr/lib#libdir=$DEST/rootfs/usr/lib#g;s#includedir=/usr/include#includedir=$DEST/rootfs/usr/include#g" "$DEST/bin/$(basename $f)"
fi
done
for f in $(find $DEST/rootfs/usr/lib/arm-linux-gnueabihf -type l);do
[ ! -e $f ] && ln -sf "../../..$(readlink $f)" "$f"
done
for f in $DEST/rootfs/etc/alternatives/lib*;do
[ ! -e $f ] && ln -sf "../..$(readlink $f)" "$f"
done
for f in $DEST/rootfs/usr/lib/arm-linux-gnueabihf/lib*so;do
if [ -h $f ] && [ ! -h $DEST/rootfs/usr/lib/$(basename $f) ] ;then
l=$(readlink $f)
if [[ "$(basename $l)" == "$l" ]];then
ln -sf "arm-linux-gnueabihf/$l" "$DEST/rootfs/usr/lib/$(basename $f)"
elif [[ "$l" = ../* ]];then
ln -sf "$(echo $l|sed 's#^../##')" "$DEST/rootfs/usr/lib/$(basename $f)"
fi
fi
done
}
pyra.apt() { chroot.cmd apt-get -y "$@"; }
pyra.update() { pyra.apt update; }
pyra.upgrade() { pyra.apt upgrade; }
pyra.build-dep() { pyra.apt build-dep $OPTS; }
pyra.install() {
local pkgs=${OPTS:-"build-essential libsdl1.2-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-net1.2-dev libsdl-ttf2.0-dev libsdl-gfx1.2-dev libsdl2-dev libsdl2-gfx-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-net-dev libsdl2-ttf-dev"}
pyra.apt install $pkgs
}
pyra_getprjroot() {
echo /drone/src
}
export DBPS_TARGETDIR=/out
depo.publish.verify() { task.verify.permissive; }
depo.publish () {
local dest="${1:-"${PLUGIN_SSHDEST:-"depo@depo.toolchain:htdocs/pyra/"}"}"
local pushed=0 i
if [ ! -z ${PLUGIN_SSHKEY+x} ];then
mkdir -p ~/.ssh
echo "${PLUGIN_SSHKEY}">~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
chmod 700 ~/.ssh
fi
for i in /out/*.deb;do
if [ -f "$i" ];then
pushed=$(( $pushed + 1 ))
scp -o StrictHostKeyChecking=no "$i" "${dest}"
fi
done
for i in /out/*dbp;do
if [ -f "$i" ];then
pushed=$(( $pushed + 1 ))
scp -o StrictHostKeyChecking=no "$i" "${dest}"
fi
done
if [ $pushed -ne 0 ];then
return 0