1#!/bin/bash -xe
2#
3# Purpose:
4#  This script is responsible for setting up a openbmc/openbmc build
5#  environment for a meta-* repository.
6#
7# Required Inputs:
8#  WORKSPACE:      Directory which contains the extracted meta-*
9#                  layer test is running against
10#  GERRIT_PROJECT: openbmc/meta-* layer under test (i.e. openbmc/meta-phosphor)
11#  GERRIT_BRANCH:  Branch under test (default is master)
12
13export LANG=en_US.UTF8
14cd "$WORKSPACE"
15
16GERRIT_BRANCH=${GERRIT_BRANCH:-"master"}
17
18# Grab this for the downstream job
19# TODO - Need test repo to branch
20# git clone https://github.com/openbmc/openbmc-test-automation.git --branch ${GERRIT_BRANCH} --single-branch
21git clone https://github.com/openbmc/openbmc-test-automation.git --branch master --single-branch
22
23META_REPO=$(basename "$GERRIT_PROJECT")
24export META_REPO
25
26# Move the extracted meta layer to a dir based on it's meta-* name
27mv "$GERRIT_PROJECT" "$META_REPO"
28
29# Remove openbmc dir in prep for full repo clone
30rm -rf openbmc
31
32# Clone openbmc/openbmc
33git clone https://github.com/openbmc/openbmc.git --branch "${GERRIT_BRANCH}" --single-branch
34
35# Make sure meta-* directory is there
36mkdir -p ./openbmc/"$META_REPO"/
37
38# Clean out the dir to handle delete/rename of files
39rm -rf ./openbmc/"$META_REPO"/*
40
41# Copy the extracted meta code into it
42cp -Rf "$META_REPO"/* ./openbmc/"$META_REPO"/
43
44# Create a dummy commit so code update will pick it up
45cd openbmc
46git add -A && git commit --allow-empty -m "Dummy commit to cause code update"
47