-
Notifications
You must be signed in to change notification settings - Fork 0
/
orxpm.sh
executable file
·77 lines (60 loc) · 1.99 KB
/
orxpm.sh
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
git diff-index --quiet HEAD # Check for uncommitted changes
RC=$?
if [[ $RC != 0 ]]; then
echo "You have uncommitted changes, please run orxpm.sh with a clean repo."
exit 1
fi
if [ "$#" -eq 1 ]; then
REMOTE=$1
elif [ -f .orxpm/remote ]; then
REMOTE=$(cat .orxpm/remote)
echo "Using the previous package repository: $REMOTE"
else
DEFAULT_REMOTE='https://github.com/orx/orxhub.git'
echo "Using the default remote: $DEFAULT_REMOTE"
REMOTE=$DEFAULT_REMOTE
fi
mkdir -p .orxpm
echo $REMOTE > .orxpm/remote
mkdir -p .orxpm/workbench
cd .orxpm/workbench
git init > /dev/null
echo "Updating the local package repository..."
git fetch $REMOTE '+refs/heads/*:refs/heads/orxhub/*'
echo "Resetting the local package repository state..."
git branch -D empty >/dev/null 2>&1
git checkout --orphan empty
git reset --hard
git clean -f -d
echo "Constructing the platform from packages..."
while read PACKAGE; do
git merge orxhub/package/$PACKAGE
done < ../../orx_packages
echo "Converting the platform to a monolithic commit..."
git branch -D new_platform >/dev/null 2>&1
git checkout --orphan new_platform
if [ -f ../platform ]; then
PLATFORM=$(cat ../platform)
echo "The old platform commit was $PLATFORM"
git fetch ../../
git reset $PLATFORM
git add .
fi
echo "Creating the new platform commit..."
git commit -m "$(echo "Creating a new platform with packages:"; cat ../../orx_packages)"
NEW_PLATFORM=$(git rev-parse HEAD)
echo $NEW_PLATFORM > ../platform
cd ../..
echo "Merging the new platform from commit $NEW_PLATFORM"
git fetch .orxpm/workbench new_platform
git merge $NEW_PLATFORM --no-edit
echo "Committing the OrxPM metadata..."
git add orx_packages .orxpm/platform .orxpm/remote
echo $NEW_PLATFORM $(git rev-parse HEAD)
if [ "$NEW_PLATFORM" == "$(git rev-parse HEAD)" ]; then
git commit -m "OrxPM metadata"
else
git commit --amend --no-edit
fi
echo "Touching src/CMakeLists.txt so that new source files are discovered during next build."
touch src/CMakeLists.txt