Commit 88ad83ab authored by Vladimir Bashkirtsev's avatar Vladimir Bashkirtsev

Added support for www builds

parent 916ef1ef
......@@ -6,8 +6,6 @@
<property name="MACH" value="${env.MACH}"/>
<import file="machines/${MACH}/definition.xml" optional="true"/>
<fail unless="BOARD" message="Correct machine type must be specified"/>
<property name="VERSION" value="${ID}-${MACH}"/>
<exec executable="bash" outputproperty="LAST_COMMIT">
......@@ -162,6 +160,29 @@
<antcall target="fill-secondary-mender-keys"/>
</target>
<target name="fill-secondary-www">
<mkdir dir="${sysdir}/www"/>
<copy todir="${sysdir}/www" failonerror="true">
<fileset dir="${basedir}">
<include name="**/*"/>
<exclude name=".git/"/>
<exclude name="build/"/>
<exclude name="build-system/"/>
<exclude name="build.xml"/>
<exclude name="host/"/>
<exclude name="packages/"/>
<exclude name="guestmount.pid"/>
</fileset>
</copy>
<exec executable="cp" failonerror="true">
<arg line="-drv ${basedir}/packages ${sysdir}"/>
</exec>
<exec executable="cp" failonerror="true">
<arg line="-drv ${basedir}/build-system/Makefile.common ${sysdir}/packages"/>
</exec>
<antcall target="fill-secondary-mender-keys"/>
</target>
<target name="fill-secondary-mender-keys" if="MENDER_KEYS">
<exec executable="cp" failonerror="true">
<arg line="-drv ${basedir}/host/server.crt ${sysdir}/packages/mender"/>
......@@ -323,6 +344,7 @@
</target>
<target name="build-boot-kernel">
<fail unless="BOARD" message="Correct machine type must be specified"/>
<antcall target="mount"/>
<antcall target="setup-build-boot-kernel"/>
<antcall target="unmount"/>
......@@ -339,6 +361,7 @@
</target>
<target name="setup-build-boot-kernel">
<fail unless="BOARD" message="Correct machine type must be specified"/>
<delete file="${sysdir}/.success"/>
<echo file="${sysdir}/lib/systemd/system/build.service">[Unit]
Description=Build boot kernel
......@@ -414,6 +437,7 @@ rm /lib/systemd/system/build
</target>
<target name="build-image">
<fail unless="BOARD" message="Correct machine type must be specified"/>
<antcall target="mount"/>
<antcall target="setup-build"/>
<antcall target="unmount"/>
......@@ -426,6 +450,7 @@ rm /lib/systemd/system/build
</target>
<target name="setup-build">
<fail unless="BOARD" message="Correct machine type must be specified"/>
<delete file="${sysdir}/.success"/>
<echo file="${sysdir}/lib/systemd/system/machine-id.service">[Unit]
Description=Setup /etc/machine-id
......@@ -497,6 +522,109 @@ rm /lib/systemd/system/build
</exec>
</target>
<target name="build-image-www">
<fail unless="BOARD" message="Correct machine type must be specified"/>
<antcall target="mount"/>
<antcall target="setup-build-www"/>
<antcall target="unmount"/>
<antcall target="make-secondary"/>
<antcall target="mount-secondary"/>
<antcall target="fill-secondary-www"/>
<antcall target="unmount"/>
<antcall target="run-system-with-secondary-${BOARD}"/>
<antcall target="check-build-success"/>
<antcall target="mount"/>
<antcall target="return-www-build-results"/>
<antcall target="unmount"/>
</target>
<target name="setup-build-www">
<fail unless="BOARD" message="Correct machine type must be specified"/>
<delete file="${sysdir}/.success"/>
<echo file="${sysdir}/lib/systemd/system/machine-id.service">[Unit]
Description=Setup /etc/machine-id
Before=systemd-networkd.service
After=local-fs.target
[Service]
Type=oneshot
StandardOutput=tty
ExecStart=/bin/systemd-machine-id-setup
[Install]
WantedBy=rescue.target
</echo>
<echo file="${sysdir}/lib/systemd/system/build.service">[Unit]
Description=Build ${ant.project.name}
After=network-online.target
Wants=systemd-networkd.service
Wants=systemd-resolved.service
[Service]
Type=oneshot
StandardOutput=tty
ExecStart=/lib/systemd/system/build
ExecStartPost=/sbin/poweroff
[Install]
WantedBy=rescue.target
</echo>
<echo file="${sysdir}/lib/systemd/system/build">#!/bin/sh
LC_ALL=POSIX
PATH=/bin:/usr/bin:/sbin:/usr/sbin
PROJECT_NAME="${ant.project.name}"
ID="${ID}"
PRETTY_NAME="${PRETTY_NAME}"
HOSTNAME="${HOSTNAME}"
COPYRIGHT="${copyright}"
LICENSE="${license}"
VERSION="${VERSION}"
BUILD_ID=${BUILD_ID}
ARTIFACT_NAME=${ARTIFACT_NAME}
DEVICE_TYPE=${DEVICE_TYPE}
BOARD="${BOARD}"
CONSOLE="${CONSOLE}"
ROOT_DEVICE="${ROOT_DEVICE}"
DISK="${DISK}"
SECONDARY="${SECONDARY}"
SHUTDOWN_WATCHDOG="${SHUTDOWN_WATCHDOG}"
RUNTIME_WATCHDOG="${RUNTIME_WATCHDOG}"
export LC_ALL PATH PROJECT_NAME ID PRETTY_NAME HOSTNAME COPYRIGHT LICENSE VERSION BUILD_ID ARTIFACT_NAME DEVICE_TYPE BOARD CONSOLE ROOT_DEVICE DISK SECONDARY SHUTDOWN_WATCHDOG RUNTIME_WATCHDOG HOSTTYPE
mount -o remount,rw /
mkdir /build
mount /dev/${SECONDARY}1 /build
make -C /build/packages
if [ $? -eq 0 ]; then
umount /dev/${SECONDARY}1
rm -rf /build
fi
rm -rf /etc/systemd/system/rescue.target.wants
rm /lib/systemd/system/machine-id.service
rm /lib/systemd/system/build.service
rm /lib/systemd/system/build
</echo>
<chmod file="${sysdir}/lib/systemd/system/build" perm="755"/>
<mkdir dir="${sysdir}/etc/systemd/system/rescue.target.wants"/>
<exec executable="ln" failonerror="true">
<arg line="-s /lib/systemd/system/build.service ${sysdir}/etc/systemd/system/rescue.target.wants/build.service"/>
</exec>
</target>
<target name="return-www-build-results">
<copy todir="${builddir}" failonerror="true">
<fileset dir="${sysdir}/srv/www/build">
<include name="**/*"/>
</fileset>
</copy>
<delete dir="${sysdir}/srv/www/build"/>
<exec executable="bash" failonerror="true">
<arg line="-c 'find . -name &quot;*.xml&quot; -o -name &quot;*.html&quot; -type f -exec sed -e &quot;s|/srv/www|${builddir}|g&quot; -i {} +'"/>
</exec>
</target>
<target name="check-build-success">
<antcall target="mount"/>
<available file="${sysdir}/.success" property="success"/>
......@@ -514,6 +642,7 @@ rm /lib/systemd/system/build
</target>
<target name="check-strip-and-trim">
<fail unless="BOARD" message="Correct machine type must be specified"/>
<antcall target="copy-to-secondary"/>
<antcall target="mount"/>
<antcall target="setup-check-strip-and-trim"/>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment