From a6ddd10014ad63698fe20ef8fa5ee2b3032004ee Mon Sep 17 00:00:00 2001 From: Gordon Hecker Date: Tue, 3 Nov 2009 19:03:36 +0100 Subject: [PATCH] example: include example project into source tree Signed-off-by: Gordon Hecker --- Changelog | 2 + example/Makefile | 85 +++++++++++++++++++++ example/README | 25 ++++++ example/example/in/.keep | 0 example/example/log/.keep | 0 example/example/proj/chroot | 19 +++++ example/example/proj/config | 8 ++ example/example/proj/env | 10 +++ example/example/proj/init/.keep | 0 example/example/proj/licences | 3 + example/example/res/.keep | 0 example/example/res/final/build-script | 30 ++++++++ example/example/res/final/config | 13 ++++ example/example/res/helloworld/build-script | 30 ++++++++ example/example/res/helloworld/config | 13 ++++ example/example/src/.keep | 0 example/example/src/helloworld/config | 21 +++++ example/setup_example.sh | 32 ++++++++ 18 files changed, 291 insertions(+) create mode 100644 example/Makefile create mode 100644 example/README create mode 100644 example/example/in/.keep create mode 100644 example/example/log/.keep create mode 100644 example/example/proj/chroot create mode 100644 example/example/proj/config create mode 100644 example/example/proj/env create mode 100644 example/example/proj/init/.keep create mode 100644 example/example/proj/licences create mode 100644 example/example/res/.keep create mode 100644 example/example/res/final/build-script create mode 100644 example/example/res/final/config create mode 100644 example/example/res/helloworld/build-script create mode 100644 example/example/res/helloworld/config create mode 100644 example/example/src/.keep create mode 100644 example/example/src/helloworld/config create mode 100755 example/setup_example.sh diff --git a/Changelog b/Changelog index 90391a4..2b77be3 100644 --- a/Changelog +++ b/Changelog @@ -30,6 +30,8 @@ NEXT: for files stored in the project configuration tree (on the "." server) * fix the bug that the project name configuratino from `proj/config` did not influence the BuildId + * the example project is now included in the main source tree. Additional + files and the e2factory.git repository can be fetched on-the-fly e2factory-2.3.1 * bugfixes diff --git a/example/Makefile b/example/Makefile new file mode 100644 index 0000000..470ccc0 --- /dev/null +++ b/example/Makefile @@ -0,0 +1,85 @@ +# +# e2factory, the emlix embedded build system +# +# Copyright (C) 2007-2009 Gordon Hecker , emlix GmbH +# Copyright (C) 2007-2009 Oskar Schirmer , emlix GmbH +# Copyright (C) 2007-2008 Felix Winkelmann, emlix GmbH +# +# For more information have a look at http://www.e2factory.org +# +# e2factory is a registered trademark by emlix GmbH. +# +# This file is part of e2factory, the emlix embedded build system. +# +# e2factory is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +TOPLEVEL = .. + +include $(TOPLEVEL)/make.vars + +CLEAN_FILES = *~ *.lc *.so + +DOWNLOAD = http://www.e2factory.org/source/example +E2FACTORY_GIT = http://git.e2factory.org/git/e2factory/e2factory.git + +E2_CONFIG = /etc/e2/e2.conf.sample +export E2_CONFIG + +CHROOTDIR = $(LOCALSTATEDIR)/chroot +RESULTSDIR = $(LOCALSTATEDIR)/results +RELEASESDIR = $(LOCALSTATEDIR)/releases +PROJECTSDIR = $(LOCALSTATEDIR)/projects +UPSTREAMDIR = $(LOCALSTATEDIR)/upstream + +default: example + +clean: + rm -fr e2factory-example + rm -fr e2factory.git + rm -fr base.tar.gz + rm -f $(CLEAN_FILES) + +base.tar.gz: + wget $(DOWNLOAD)/base.tar.gz + +e2factory.git: + git clone $(E2FACTORY_GIT) e2factory.git + +fetch: base.tar.gz e2factory.git + +install_example: fetch + for d in $(CHROOTDIR) $(RESULTSDIR) $(RELEASESDIR) $(PROJECTSDIR) \ + $(UPSTREAMDIR) ; do \ + install -d -m 775 -o root -g ebs $$d ;\ + done + install -m 644 base.tar.gz $(CHROOTDIR)/ + cp -r e2factory.git $(PROJECTSDIR)/ + # need 'env -i' here to avoid environment going from this build + # process to the local build inside e2-fetch-project. + env -i \ + PATH=$(PATH) \ + E2_CONFIG=$(E2_CONFIG) \ + HOME=$(HOME) \ + USER=$(USER) \ + E2_LOCAL_BRANCH=$(E2_LOCAL_BRANCH) \ + E2_LOCAL_TAG=$(E2_LOCAL_TAG) \ + ./setup_example.sh + +uninstall_example: + rm -fr $(PROJECTSDIR)/e2factory-example + rm -fr $(PROJECTSDIR)/e2factory.git + rm -f $(CHROOTDIR)/base.tar.gz + +.PHONY: example install_example uninstall_example diff --git a/example/README b/example/README new file mode 100644 index 0000000..78ac735 --- /dev/null +++ b/example/README @@ -0,0 +1,25 @@ +The example/ subdirectory includes an example project configuration. + +You can easily set up the example project by running + + $ make fetch + +to fetch files required to setup the example and + + $ make install_example + +to install files required for the the example project to your server +environment and setup the example project. +If you change the LOCALSTATEDIR setting in your e2factory build make sure +you use the same setting here. + +Finally you can checkout the project + + $ e2-fetch-project e2factory-example + $ cd e2factory-example + +and use it... + + $ e2-ls-project + $ e2-fetch-sources + $ e2-build diff --git a/example/example/in/.keep b/example/example/in/.keep new file mode 100644 index 0000000..e69de29 diff --git a/example/example/log/.keep b/example/example/log/.keep new file mode 100644 index 0000000..e69de29 diff --git a/example/example/proj/chroot b/example/example/proj/chroot new file mode 100644 index 0000000..5c48377 --- /dev/null +++ b/example/example/proj/chroot @@ -0,0 +1,19 @@ +-- e2 factory chroot configuration file -- +local cp = "sample/" +e2chroot { + default_groups = { + "base", + }, + groups = { + { + name = "base", + server = "chroot", + files = { + { + location = cp.."base.tar.gz", + sha1 = "284e7e9b03cf4e0343d509f564a1b2124933533d", + }, + }, + }, + }, +} diff --git a/example/example/proj/config b/example/example/proj/config new file mode 100644 index 0000000..367e524 --- /dev/null +++ b/example/example/proj/config @@ -0,0 +1,8 @@ +-- e2 factory project configuration file -- + +e2project { + name = "e2factory-example", + release_id = "e2factory-example", + default_results = { "final", }, + chroot_arch = "x86_32", +} diff --git a/example/example/proj/env b/example/example/proj/env new file mode 100644 index 0000000..06dd4ca --- /dev/null +++ b/example/example/proj/env @@ -0,0 +1,10 @@ +-- e2 factory environment configuration file -- +env { + -- global variables + -- key = "val", + + -- result specific variables (only available in ) + -- = { + -- key = "val", + -- }, +} diff --git a/example/example/proj/init/.keep b/example/example/proj/init/.keep new file mode 100644 index 0000000..e69de29 diff --git a/example/example/proj/licences b/example/example/proj/licences new file mode 100644 index 0000000..0b70070 --- /dev/null +++ b/example/example/proj/licences @@ -0,0 +1,3 @@ +-- e2 factory licence configuration file -- +e2licence { +} diff --git a/example/example/res/.keep b/example/example/res/.keep new file mode 100644 index 0000000..e69de29 diff --git a/example/example/res/final/build-script b/example/example/res/final/build-script new file mode 100644 index 0000000..664e9bb --- /dev/null +++ b/example/example/res/final/build-script @@ -0,0 +1,30 @@ +# e2 factory build script template +# +# The build system provides the following variables for use in build scripts: +# - TMPDIR pointing to a temporary directory with a directory structure +# - RESULT the name of the result currently building +# - BUILD_NUMBER the build number, 0 by default +# +# Additional variables can be provided in init files. +# Variables are not exported unless the init files do. +# +# The following directory structure is available, relative to TMPDIR +# +# ./build/ sources are located here +# ./root shall be used as the destination directory when +# installing software for packaging +# ./env files containing environment variables are located here +# ./init init scripts are located here +# ./script this directory holds the build driver and the build +# script +# ./in This directory is available but unused +# ./dep/ These directories hold result files from dependency +# results +# ./out Files that are left here are packaged into the result +# finally. +# + +# simple example: just extract and repackage everything +find / +tar -C ${E2_TMPDIR}/root -xzvf ${E2_TMPDIR}/dep/helloworld/helloworld.tar.gz +tar -C ${E2_TMPDIR}/root -czvf ${E2_TMPDIR}/out/${E2_RESULT}.tar.gz . diff --git a/example/example/res/final/config b/example/example/res/final/config new file mode 100644 index 0000000..704ec6e --- /dev/null +++ b/example/example/res/final/config @@ -0,0 +1,13 @@ +-- e2 factory result configuration template -- + +e2result { + -- a list of sources + sources = { }, + -- a list of dependencies + depends = { "helloworld", }, + -- a list of chroot groups + chroot = { }, + -- use the collect_project feature for this result? + collect_project = false, + -- collect_project_default_result = "", +} diff --git a/example/example/res/helloworld/build-script b/example/example/res/helloworld/build-script new file mode 100644 index 0000000..d0dd7a1 --- /dev/null +++ b/example/example/res/helloworld/build-script @@ -0,0 +1,30 @@ +# e2 factory build script template +# +# The build system provides the following variables for use in build scripts: +# - TMPDIR pointing to a temporary directory with a directory structure +# - RESULT the name of the result currently building +# - BUILD_NUMBER the build number, 0 by default +# +# Additional variables can be provided in init files. +# Variables are not exported unless the init files do. +# +# The following directory structure is available, relative to TMPDIR +# +# ./build/ sources are located here +# ./root shall be used as the destination directory when +# installing software for packaging +# ./env files containing environment variables are located here +# ./init init scripts are located here +# ./script this directory holds the build driver and the build +# script +# ./in This directory is available but unused +# ./dep/ These directories hold result files from dependency +# results +# ./out Files that are left here are packaged into the result +# finally. +# +cd helloworld +make hello +install -d ${E2_TMPDIR}/root/bin +install -m 755 hello ${E2_TMPDIR}/root/bin/hello +tar -C ${E2_TMPDIR}/root -czvf ${E2_TMPDIR}/out/helloworld.tar.gz . diff --git a/example/example/res/helloworld/config b/example/example/res/helloworld/config new file mode 100644 index 0000000..afd9bac --- /dev/null +++ b/example/example/res/helloworld/config @@ -0,0 +1,13 @@ +-- e2 factory result configuration template -- + +e2result { + -- a list of sources + sources = { "helloworld", }, + -- a list of dependencies + depends = { }, + -- a list of chroot groups + chroot = { }, + -- use the collect_project feature for this result? + collect_project = false, + -- collect_project_default_result = "", +} diff --git a/example/example/src/.keep b/example/example/src/.keep new file mode 100644 index 0000000..e69de29 diff --git a/example/example/src/helloworld/config b/example/example/src/helloworld/config new file mode 100644 index 0000000..27d5c7e --- /dev/null +++ b/example/example/src/helloworld/config @@ -0,0 +1,21 @@ +-- -*- Lua -*- + +e2source { + -- the source name + -- (is derived from the config file path if only one source is + -- specified per file) + name = "helloworld", + -- the source type + type = "git", + -- a list of licences from proj/licences + licences = { }, + -- git specific attributes + -- server name + server = "proj-storage", + -- the repository location relative to the server + location = "git/helloworld.git", + -- git branch name + branch = "master", + -- git tag names, the first one is used for building + tag = "helloworld-0.1", +} diff --git a/example/setup_example.sh b/example/setup_example.sh new file mode 100755 index 0000000..fd9297e --- /dev/null +++ b/example/setup_example.sh @@ -0,0 +1,32 @@ +#!/bin/bash +set -e + +E=e2factory-example +rm -fr $E + +e2-create-project $E +e2-fetch-project $E + +# merge the example project into the new project +tar -C example -cf - . | tar -C $E -xf - + +pushd $E +git add . +git commit -m 'configure example project' +git push +e2-new-source --git helloworld + +pushd in/helloworld +cat >hello.sh <