summaryrefslogtreecommitdiff
path: root/tests.build/setup-build-essential
blob: 28847d76636788427998373de499242e623fae15 (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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/bin/sh
#
# Copyright (C) 2013-2015  Codethink Limited
#
# This program 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; version 2 of the License.
#
# 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 <http://www.gnu.org/licenses/>.

# Set up a stratum which resembles Baserock's 'build-essential' slightly. Used
# for testing 'morph cross-bootstrap' and the 'bootstrap' build mode.

# Add a mock compiler chunk.
mkdir -p "$DATADIR/cc-repo"
cd "$DATADIR/cc-repo"

cat <<EOF > "morph-test-cc"
#!/bin/sh
echo "I'm a compiler!"
EOF
chmod +x morph-test-cc

git init -q
git add morph-test-cc
git commit -q -m "Create compiler chunk"

cd "$DATADIR/morphs-repo"

cat <<EOF > "stage1-cc.morph"
name: stage1-cc
kind: chunk
install-commands:
  - install -d "\$DESTDIR\$PREFIX/bin"
  - install -m 755 morph-test-cc "\$DESTDIR\$PREFIX/bin/morph-test-cc"
EOF

cat <<EOF > "cc.morph"
name: cc
kind: chunk
configure-commands:
  - [ -e ../tools/bin/morph-test-cc ]
install-commands:
  - install -d "\$DESTDIR\$PREFIX/bin"
  - install -m 755 morph-test-cc "\$DESTDIR\$PREFIX/bin/morph-test-cc"
EOF

git add cc.morph stage1-cc.morph
git commit -q -m "Add build instructions for mock compiler."

# Require 'cc' in hello-chunk. We should have the second version available
# but *not* the first one.
cat <<EOF > "hello.morph"
name: hello
kind: chunk
configure-commands:
  - [ ! -e ../tools/bin/morph-test-cc ]
  - [ -e ../usr/bin/morph-test-cc ]
build-commands:
  - ../usr/bin/morph-test-cc > hello
install-commands:
  - install -d "\$DESTDIR\$PREFIX/bin"
  - install hello "\$DESTDIR\$PREFIX/bin/hello"
EOF
git add hello.morph stage1-cc.morph cc.morph

# Add 'build-essential' stratum and make hello-stratum depend upon it. Only
# the *second* 'cc' chunk should make it into the build-essential stratum
# artifact, and neither should make it into the system.

cat <<EOF > "build-essential.morph"
name: build-essential
kind: stratum
chunks:
  - name: stage1-cc
    morph: stage1-cc.morph
    repo: test:cc-repo
    ref: master
    morph: stage1-cc.morph
    build-depends: []
    build-mode: bootstrap
    prefix: /tools
  - name: cc
    morph: cc.morph
    repo: test:cc-repo
    ref: master
    morph: cc.morph
    build-depends:
      - stage1-cc
    build-mode: test
EOF

cat <<EOF > "hello-stratum.morph"
name: hello-stratum
kind: stratum
build-depends:
  - morph: build-essential
chunks:
  - name: hello
    morph: hello.morph
    repo: test:chunk-repo
    ref: farrokh
    morph: hello.morph
    build-depends: []
    build-mode: test
EOF

git add build-essential.morph hello-stratum.morph hello-system.morph
git commit -q -m "Add fake build-essential stratum"