Skip to content

Commit

Permalink
fixed package repo dereference
Browse files Browse the repository at this point in the history
  • Loading branch information
klaxalk committed Aug 12, 2023
1 parent 21d2fe6 commit 9c4fbad
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 25 deletions.
87 changes: 62 additions & 25 deletions .ci/get_build_matrix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,66 +3,103 @@
set -e

trap 'last_command=$current_command; current_command=$BASH_COMMAND' DEBUG
trap 'cat /tmp/log' ERR
trap 'echo "$0: \"${last_command}\" command failed with exit code $?"' ERR
trap 'echo "$0: \"${last_command}\" command failed with exit code $?, log:" && cat /tmp/log.txt' ERR

DEBUG=false

VARIANT=$1
ARCH=$2
WORKSPACE=/tmp/workspace
YAML_FILE=packages.yaml
ARTIFACTS_FOLDER=/tmp/artifacts

./.ci_scripts/package_build/install_ros.sh >/tmp/log.txt 2>&1
./.ci_scripts/package_build/add_ros_ppa.sh >> /tmp/log.txt 2>&1

curl https://ctu-mrs.github.io/ppa-$VARIANT/add_ppa.sh 2>/tmp/log.txt | bash >/tmp/log.txt 2>&1
# curl https://ctu-mrs.github.io/ppa-$VARIANT/add_ppa.sh 2>> /tmp/log.txt | bash >> /tmp/log.txt 2>&1

# dependencies need for build the deb package
sudo apt-get -y install ros-noetic-catkin python3-catkin-tools >/tmp/log.txt 2>&1
sudo apt-get -y install fakeroot dpkg-dev debhelper >/tmp/log.txt 2>&1
sudo pip3 install -U bloom >/tmp/log.txt 2>&1
sudo apt-get -y install ros-noetic-catkin python3-catkin-tools >> /tmp/log.txt 2>&1
sudo apt-get -y install fakeroot dpkg-dev debhelper >> /tmp/log.txt 2>&1
sudo pip3 install -U bloom >> /tmp/log.txt 2>&1

REPOS=$(./.ci/parse_yaml.py $YAML_FILE $VARIANT $ARCH)

mkdir -p $WORKSPACE >/tmp/log.txt 2>&1
mkdir -p $ARTIFACTS_FOLDER >/tmp/log.txt 2>&1
mkdir -p $WORKSPACE >> /tmp/log.txt 2>&1
mkdir -p $ARTIFACTS_FOLDER >> /tmp/log.txt 2>&1

cd $WORKSPACE >/tmp/log.txt 2>&1
mkdir src >/tmp/log.txt 2>&1
source /opt/ros/noetic/setup.bash >/tmp/log.txt 2>&1
catkin init >/tmp/log.txt 2>&1
cd $WORKSPACE >> /tmp/log.txt 2>&1
mkdir src >> /tmp/log.txt 2>&1
source /opt/ros/noetic/setup.bash >> /tmp/log.txt 2>&1
catkin init >> /tmp/log.txt 2>&1

cd src >/tmp/log.txt 2>&1
cd $WORKSPACE/src >> /tmp/log.txt 2>&1

# clone and checkout
echo "$REPOS" | while IFS= read -r REPO; do

$DEBUG && echo "Cloning $REPO"

PACKAGE=$(echo "$REPO" | awk '{print $1}')
URL=$(echo "$REPO" | awk '{print $2}')
BRANCH=$(echo "$REPO" | awk '{print $3}')

echo "$0: cloning '$URL --branch $BRANCH' into '$PACKAGE'" >/tmp/log.txt 2>&1
git clone $URL --branch $BRANCH $PACKAGE >/tmp/log.txt 2>&1
cd $PACKAGE >/tmp/log.txt 2>&1
git submodule update --init --recursive >/tmp/log.txt 2>&1
echo "$0: cloning '$URL --branch $BRANCH' into '$PACKAGE'" >> /tmp/log.txt 2>&1
git clone $URL --recurse-submodules --shallow-submodules --depth 1 --branch $BRANCH $PACKAGE >> /tmp/log.txt 2>&1
echo "$PACKAGE" > $PACKAGE/BUILD_THIS_REPO.txt
cd $PACKAGE >> /tmp/log.txt 2>&1

cd $WORKSPACE/src >/tmp/log.txt 2>&1
cd $WORKSPACE/src >> /tmp/log.txt 2>&1

done

$DEBUG && echo "Done cloning"

BUILD_ORDER=$(catkin list -u)

FIRST=true

# RESULT='{"matrix": ['
RESULT='['

for PACKAGE in $BUILD_ORDER; do
$DEBUG && echo "Sorting packages"

for ROS_PACKAGE in $BUILD_ORDER; do

cd $WORKSPACE
PKG_PATH=$(catkin locate "$ROS_PACKAGE")
cd $PKG_PATH

$DEBUG && echo "Gonna look for package location for '$ROS_PACKAGE'"

PACKAGE=""

while true; do

CUR_DIR=$(pwd)

if [ -e BUILD_THIS_REPO.txt ]; then
PACKAGE=$(cat BUILD_THIS_REPO.txt)
rm BUILD_THIS_REPO.txt
$DEBUG && echo "- ... found it, '$ROS_PACKAGE' originates from '$PACKAGE'"
break
fi

if [[ "$CUR_DIR" == "/" ]]; then
$DEBUG && echo "- ... did not find it, probably already on the list"
break
fi

cd ..
done

if [ ! -z $PACKAGE ]; then

if $FIRST; then
RESULT=$RESULT\"$PACKAGE\"
FIRST=false
else
RESULT="$RESULT, \"$PACKAGE\""
if $FIRST; then
RESULT=$RESULT\"$PACKAGE\"
FIRST=false
else
RESULT="$RESULT, \"$PACKAGE\""
fi
fi

done
Expand Down
2 changes: 2 additions & 0 deletions .ci/get_repo_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ def main():
except yaml.YAMLError as exc:
print(exc)

print("data: {}".format(data))

properties = data[repo_name]

architecture = properties['architecture']
Expand Down

0 comments on commit 9c4fbad

Please sign in to comment.