diff options
author | cajun-rat <p@beta16.co.uk> | 2017-04-04 14:45:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-04 14:45:31 +0200 |
commit | 610469510ec9dbac95fc415f71abdcb55e0fc18b (patch) | |
tree | bd18751638ce99904dcd68ad2eba6e6db7851f41 /scripts | |
parent | feb5a6a1da2faf088d6c5d3e3eeb07471074f0bf (diff) | |
parent | 82a3c13a0b0c9979fa0812143d619748aa89c85d (diff) | |
download | meta-updater-610469510ec9dbac95fc415f71abdcb55e0fc18b.tar.gz |
Merge pull request #40 from advancedtelematic/feat/syncagl
Synchronize with AGL's meta-sota progress
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/envsetup.sh | 53 | ||||
-rw-r--r-- | scripts/lib/wic/canned-wks/sdimage-sota.wks | 7 | ||||
-rw-r--r-- | scripts/lib/wic/plugins/otaimage.py | 69 |
3 files changed, 129 insertions, 0 deletions
diff --git a/scripts/envsetup.sh b/scripts/envsetup.sh new file mode 100755 index 0000000..316a782 --- /dev/null +++ b/scripts/envsetup.sh | |||
@@ -0,0 +1,53 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | SCRIPT="envsetup.sh" | ||
4 | |||
5 | MACHINE=$1 | ||
6 | |||
7 | if [ "$#" -lt 1 ]; then | ||
8 | echo "Usage: ${SCRIPT} <machine> [builddir]" | ||
9 | return -1 | ||
10 | elif [ "$#" -eq 2 ]; then | ||
11 | BUILDDIR=$2 | ||
12 | else | ||
13 | BUILDDIR=build | ||
14 | fi | ||
15 | BULDDIR=$2 | ||
16 | |||
17 | # detect if this script is sourced: see http://stackoverflow.com/a/38128348/6255594 | ||
18 | SOURCED=0 | ||
19 | if [ -n "$ZSH_EVAL_CONTEXT" ]; then | ||
20 | [[ $ZSH_EVAL_CONTEXT =~ :file$ ]] && { SOURCED=1; SOURCEDIR=$(cd $(dirname -- $0) && pwd -P); } | ||
21 | elif [ -n "$KSH_VERSION" ]; then | ||
22 | [[ "$(cd $(dirname -- $0) && pwd -P)/$(basename -- $0)" != "$(cd $(dirname -- ${.sh.file}) && pwd -P)/$(basename -- ${.sh.file})" ]] && { SOURCED=1; SOURCEDIR=$(cd $(dirname -- ${.sh.file}) && pwd -P); } | ||
23 | elif [ -n "$BASH_VERSION" ]; then | ||
24 | [[ $0 != "$BASH_SOURCE" ]] && { SOURCED=1; SOURCEDIR=$(cd $(dirname -- $BASH_SOURCE) && pwd -P); } | ||
25 | fi | ||
26 | |||
27 | if [ $SOURCED -ne 1 ]; then | ||
28 | unset SOURCED | ||
29 | unset SOURCEDIR | ||
30 | echo "Error: this script needs to be sourced in a supported shell" >&2 | ||
31 | echo "Please check that the current shell is bash, zsh or ksh and run this script as '. $0 <args>'" >&2 | ||
32 | exit -1 | ||
33 | fi | ||
34 | |||
35 | SCRIPTDIR=$(cd $(dirname $BASH_SOURCE) && pwd -P) | ||
36 | METADIR=$(cd $(dirname $BASH_SOURCE)/../.. && pwd -P) | ||
37 | |||
38 | if ! [[ -e ${SCRIPTDIR}/../conf/include/local/sota_${MACHINE}.inc && -e ${SCRIPTDIR}/../conf/include/bblayers/sota_${MACHINE}.inc ]]; then | ||
39 | echo "Error: invalid machine: ${MACHINE}" >&2 | ||
40 | return -1 | ||
41 | fi | ||
42 | |||
43 | if [ -e ${BUILDDIR}/conf/local.conf ]; then | ||
44 | source $METADIR/poky/oe-init-build-env ${BUILDDIR} | ||
45 | else | ||
46 | source $METADIR/poky/oe-init-build-env ${BUILDDIR} | ||
47 | echo "METADIR := \"\${@os.path.abspath('${METADIR}')}\"" >> conf/bblayers.conf | ||
48 | cat ${METADIR}/meta-updater/conf/include/bblayers/sota.inc >> conf/bblayers.conf | ||
49 | cat ${METADIR}/meta-updater/conf/include/bblayers/sota_${MACHINE}.inc >> conf/bblayers.conf | ||
50 | echo "include conf/include/local/sota_${MACHINE}.inc" >> conf/local.conf | ||
51 | echo "include conf/distro/sota.conf.inc" >> conf/local.conf | ||
52 | fi | ||
53 | |||
diff --git a/scripts/lib/wic/canned-wks/sdimage-sota.wks b/scripts/lib/wic/canned-wks/sdimage-sota.wks new file mode 100644 index 0000000..c31c3a5 --- /dev/null +++ b/scripts/lib/wic/canned-wks/sdimage-sota.wks | |||
@@ -0,0 +1,7 @@ | |||
1 | # short-description: Create OTA-enabled SD card image | ||
2 | # long-description: Creates a partitioned SD card image with OSTree | ||
3 | # physical sysroot as a payload. Boot files are located in the | ||
4 | # first vfat partition. | ||
5 | |||
6 | part /boot --source bootimg-partition --ondisk mmcblk --fstype=vfat --label boot --active --align 4096 --size 20 | ||
7 | part / --source otaimage --ondisk mmcblk --fstype=ext4 --label root --align 4096 | ||
diff --git a/scripts/lib/wic/plugins/otaimage.py b/scripts/lib/wic/plugins/otaimage.py new file mode 100644 index 0000000..016c996 --- /dev/null +++ b/scripts/lib/wic/plugins/otaimage.py | |||
@@ -0,0 +1,69 @@ | |||
1 | # ex:ts=4:sw=4:sts=4:et | ||
2 | # -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- | ||
3 | # | ||
4 | # This program is free software; you can redistribute it and/or modify | ||
5 | # it under the terms of the GNU General Public License version 2 as | ||
6 | # published by the Free Software Foundation. | ||
7 | # | ||
8 | # This program is distributed in the hope that it will be useful, | ||
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | # GNU General Public License for more details. | ||
12 | # | ||
13 | # You should have received a copy of the GNU General Public License along | ||
14 | # with this program; if not, write to the Free Software Foundation, Inc., | ||
15 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
16 | # | ||
17 | |||
18 | import os | ||
19 | |||
20 | from wic import msger | ||
21 | from wic.pluginbase import SourcePlugin | ||
22 | from wic.utils.oe.misc import get_bitbake_var | ||
23 | |||
24 | class OTAImagePlugin(SourcePlugin): | ||
25 | """ | ||
26 | Add an already existing filesystem image to the partition layout. | ||
27 | """ | ||
28 | |||
29 | name = 'otaimage' | ||
30 | |||
31 | @classmethod | ||
32 | def do_install_disk(cls, disk, disk_name, cr, workdir, oe_builddir, | ||
33 | bootimg_dir, kernel_dir, native_sysroot): | ||
34 | """ | ||
35 | Called after all partitions have been prepared and assembled into a | ||
36 | disk image. Do nothing. | ||
37 | """ | ||
38 | pass | ||
39 | |||
40 | @classmethod | ||
41 | def do_configure_partition(cls, part, source_params, cr, cr_workdir, | ||
42 | oe_builddir, bootimg_dir, kernel_dir, | ||
43 | native_sysroot): | ||
44 | """ | ||
45 | Called before do_prepare_partition(). Possibly prepare | ||
46 | configuration files of some sort. | ||
47 | """ | ||
48 | pass | ||
49 | |||
50 | @classmethod | ||
51 | def do_prepare_partition(cls, part, source_params, cr, cr_workdir, | ||
52 | oe_builddir, bootimg_dir, kernel_dir, | ||
53 | rootfs_dir, native_sysroot): | ||
54 | """ | ||
55 | Called to do the actual content population for a partition i.e. it | ||
56 | 'prepares' the partition to be incorporated into the image. | ||
57 | """ | ||
58 | if not bootimg_dir: | ||
59 | bootimg_dir = get_bitbake_var("DEPLOY_DIR_IMAGE") | ||
60 | if not bootimg_dir: | ||
61 | msger.error("Couldn't find DEPLOY_DIR_IMAGE, exiting\n") | ||
62 | |||
63 | msger.debug('Bootimg dir: %s' % bootimg_dir) | ||
64 | |||
65 | src = bootimg_dir + "/" + get_bitbake_var("IMAGE_LINK_NAME") + ".otaimg" | ||
66 | |||
67 | msger.debug('Preparing partition using image %s' % (src)) | ||
68 | part.prepare_rootfs_from_fs_image(cr_workdir, src, "") | ||
69 | |||