How does Autobuild.sh work?
Added by Sean Warner about 2 years ago
I understand how to build TVHeadend using commands such as these from a cloned tvheadend directory:
./configure --enable-hdhomerun_client --disable-hdhomerun_static --disable-dvbscan --enable-libav
make -j$(nproc)
make install
I understand that the Autobuild.sh script is used to make an installer .deb file... but when I run it it also builds tvheadend so it must be calling the make command somewhere.
You can call it like this...
AUTOBUILD_CONFIGURE_EXTRA="--enable-hdhomerun_client --disable-hdhomerun_static --disable-dvbscan --enable-libav" ./Autobuild.sh
But I cannot understand exactly how Autobuild.sh works. Can anyone explain it?
This is the Autobuild.sh script...
#!/bin/bash
#
# Entry point for the Doozer autobuild system
#
# (c) Andreas Öman 2011. All rights reserved.
#
#
set -eu
BUILD_API_VERSION=3
EXTRA_BUILD_NAME=""
JARGS=""
JOBSARGS=""
TARGET="debian"
RELEASE="--release"
WORKINGDIR="/var/tmp/showtime-autobuild"
FILELIST="$PWD/filelist.txt"
OP="build"
while getopts "vht:e:j:w:o:c:" OPTION
do
case $OPTION in
v)
echo $BUILD_API_VERSION
exit 0
;;
h)
echo "This script is intended to be used by the autobuild system only"
exit 0
;;
t)
TARGET="$OPTARG"
;;
e)
EXTRA_BUILD_NAME="$OPTARG"
;;
j)
JOBSARGS="--jobs=$OPTARG"
JARGS="-j$OPTARG"
;;
w)
WORKINGDIR="$OPTARG"
;;
o)
OP="$OPTARG"
;;
esac
done
if [[ -z $TARGET ]]; then
echo "target (-t) not specified"
exit 1
fi
#
# $1 = local file path
# $2 = type
# $3 = content-type
# $4 = filename
#
artifact() {
echo "doozer-artifact:$PWD/$1:$2:$3:$4"
echo "$PWD/$1" >> "$FILELIST"
}
versioned_artifact() {
echo "doozer-versioned-artifact:$PWD/$1:$2:$3:$4"
echo "$PWD/$1" >> "$FILELIST"
}
git status
if [ -f Autobuild/${TARGET}.sh ]; then
source Autobuild/${TARGET}.sh
else
echo "target $TARGET not supported"
exit 1
fi
What calls artifact() and versioned_artifact() ?
On my system I would expect this line to get called...
source Autobuild/debian.sh
This is deban.sh
CHANGELOG=debian/changelog
NOW=`date -R`
VER=`$(dirname $0)/support/version`
[ -z "${DEBDIST:-}" ] && DEBDIST=""
BUILD_DEPS=`awk '\
BEGIN {cnt = 1;}
/^Build-Depends:/ {
split($0, line, ":");
split(line[2], deps, ",");
for (i in deps) {
d = deps[i];
sub(/^ */, "", d);
sub(/ *$/, "", d);
n = split(d, tokens, " ");
packages[cnt++] = tokens[1];
}
}
END {
out = "";
for(i = 1; i <= cnt; i++) {
out = out packages[i] " ";
}
print out;
}' debian/control`
case "${DEBDIST}" in
precise|trusty|jessie|raspbianjessie)
BUILD_DEPS=`echo ${BUILD_DEPS} | sed -e 's/libpcre2-dev/libpcre3-dev/g'` ;;
esac
build()
{
$(dirname $0)/support/changelog "$CHANGELOG" "$DEBDIST" "$VER"
export JOBSARGS
export JARGS
export AUTOBUILD_CONFIGURE_EXTRA
if ccache=$(which ccache); then
echo "Using ccache"
ccache -s
USE_CCACHE="--ccache"
else
USE_CCACHE=""
fi
export USE_CCACHE
dpkg-buildpackage -b -us -uc
for a in ../tvheadend*${VER}*.deb; do
versioned_artifact "$a" deb application/x-deb `basename $a`
done
for a in ../tvheadend*${VER}*.changes; do
versioned_artifact "$a" changes text/plain `basename $a`
done
}
clean()
{
for a in ../tvheadend*${VER}*.deb; do
rm -f "$a"
done
for a in ../tvheadend*${VER}*.changes; do
rm -f "$a"
done
rm -f ${CHANGELOG}
dh_clean
}
deps()
{
if [[ $EUID -ne 0 ]]; then
echo "Build dependencies must be installed as root"
exit 1
fi
apt-get -y install ${BUILD_DEPS}
}
buildenv()
{
echo $BUILD_DEPS | shasum | awk '{print $1}'
}
eval $OP
What process calls the methods: build(), clean(), deps and buildenv()?
What is calling the configure script, the make and make install commands?
What script or routine makes use of the build options in the AUTOBUILD_CONFIGURE_EXTRA environment variable?
Cheers,
Flex
Replies (4)
RE: How does Autobuild.sh work? - Added by Max Bey almost 2 years ago
Sean Warner wrote:
But I cannot understand exactly how Autobuild.sh works. Can anyone explain it?
I don't know the autotools very well. But I will try. You've already determined that the while loop is not executed as there are no parameters, and that the if condition executed script debian.sh.
What calls artifact() and versioned_artifact() ?
What makes you certain that these functions are called at all?
What process calls the methods: build(), clean(), deps and buildenv()?
build() is called by the last line, eval build. I'm not sure the others are actually called.
What is calling the configure script, the make and make install commands?
dpkg-buildpackage
What script or routine makes use of the build options in the AUTOBUILD_CONFIGURE_EXTRA environment variable?
Probably also either dpkg-buildpackage, or one of the autotools.
RE: How does Autobuild.sh work? - Added by Sean Warner almost 2 years ago
Thanks Max, although I could use a little more detail...
I had a look at the man page for dpkg-buildpackage but it does not mention the "configure" script or the "AUTOBUILD_CONFIGURE_EXTRA" environment variable.
I think knowing what uses them is key to understanding how the Autobuild script works.
At least you have given me some things to google about. Thank you.
Flex
RE: How does Autobuild.sh work? - Added by Flole Systems almost 2 years ago
That script is only intended for automatic build to create the Tvheadend packages for the repository. There's a newer version available now which kinda works in a different way.
RE: How does Autobuild.sh work? - Added by Sean Warner almost 2 years ago
Flole Systems
OK, and Autobuild.sh is also being used by people to build a TVHeadend installer package by themselves as evidenced by several posts in these forums.
Any chance you could help me understand how Autobuild.sh works? I just want to understand is all. My questions are in my first comment above.
Where is the newer version and how does it work?
Any help you can provide much appreciated.
Flex