summaryrefslogtreecommitdiff
path: root/convert
blob: e41b44f9c2b2b88f4ced36a6f18cb3d1ff5accc6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/bash
# Baserock definitions -> BuildStream conversion script.
#
# This script aims to be the "canonical" conversion of the Baserock definitions
# repository for use with the BuildStream build tool.

set -eu

# This must point to a clone of https://gitlab.com/BuildStream/defs2bst/
CONVERTER=./defs2bst/defs2bst.py

# This must point to a clone of https://gitlab.com/baserock/ybd/
YBD=./ybd/ybd.py

# Only the following systems will be converted.
systems="
    systems/base-system-x86_64-generic.morph
    systems/build-system-x86_64.morph
    systems/minimal-system-x86_64-generic.morph
    gnome/systems/gnome-system-x86_64.morph
    genivi/systems/genivi-demo-platform-x86_64-generic.morph
    ivi/systems/ivi-system-x86_64.morph
    trove/systems/trove-system-x86_64.morph
    weston/systems/weston-system-x86_64-generic.morph
    weston/systems/weston-qt5-system-x86_64.morph
    unmaintained/systems/openstack-system-x86_64.morph"

mkdir -p elements/
mkdir -p elements/systems/

for system_morph in $systems; do
    # Run the defs2bst script for $system_morph. This will produce a .bst
    # file for every chunk involved in the build, and will produce a file named
    # something like XX-system-x86_64-content.bst from the system .morph file.
    $CONVERTER --ybd $YBD \
               --definitions old-definitions-morph-format \
               --output ./elements \
               --rebase strata/build-essential.morph gnu-toolchain.bst \
               $system_morph x86_64

    # Figure out the .bst file defs2bst will have produced for $system_morph.
    system_bst_initial=$(echo $system_morph | sed -e 's@systems/@@' -e 's@\.morph$@-content.bst@')

    # Now we remove x86_64 from the name; BuildStream allows architecture
    # conditionals so we don't need to duplicate everything per platform.
    #
    # We take the opportunity to remove -generic as well if present.
    system_bst_final=$(basename $system_bst_initial | sed -e 's@-x86_64@@' -e 's@-generic@@')

    # All systems go in an elements/systems/ subdirectory, rather than being
    # spread around different dirs like they are currently.
    mv elements/$system_bst_initial elements/systems/$system_bst_final

    echo
    echo "convert: Created elements/systems/$system_bst_final from elements/$system_bst_initial"
    echo
done

# Manual fix for libffi build instructions. The output of $(gcc -dumpmachine)
# is not the same as the output of $(sh ./config.guess) when building with
# the BuildStream gnu-toolchain definitions.
#
# We cannot fix this in definitions.git master, see: https://gitlab.com/baserock/definitions/merge_requests/49
sed -i elements/core/libffi.bst -e 's@\$(gcc -dumpmachine)@$(sh ./config.guess)@'

# Replace the x86_64-only BSP with a generic one that I manually created.
find elements/systems/*.bst -exec \
    sed -i \{} -e 's@bsp-x86_64-generic.bst@bsp-generic.bst@' \;