aboutsummaryrefslogtreecommitdiffstats
path: root/autorelease/scripts/fix-names.sh
diff options
context:
space:
mode:
authorGary Wu <gary.i.wu@huawei.com>2017-07-28 12:26:54 -0700
committerGary Wu <gary.i.wu@huawei.com>2017-07-28 12:26:54 -0700
commitd04e4407a6a5888b8f6d924e0c9706378c3d285a (patch)
treea1847dab1f8bbf784747166eaf623df958aa9e30 /autorelease/scripts/fix-names.sh
parent14387356f435a416f1f180d0d670d5760888c6b3 (diff)
Add integration scripts from OPEN-O
Change-Id: Ife6951ed9ea8c5b9dcea68e7a095b6bd5180e7d1 Signed-off-by: Gary Wu <gary.i.wu@huawei.com>
Diffstat (limited to 'autorelease/scripts/fix-names.sh')
-rwxr-xr-xautorelease/scripts/fix-names.sh42
1 files changed, 42 insertions, 0 deletions
diff --git a/autorelease/scripts/fix-names.sh b/autorelease/scripts/fix-names.sh
new file mode 100755
index 000000000..9540ac594
--- /dev/null
+++ b/autorelease/scripts/fix-names.sh
@@ -0,0 +1,42 @@
+#!/bin/bash
+##############################################################################
+# Copyright (c) 2015, 2016 The Linux Foundation. All rights reserved.
+##############################################################################
+
+# autorelease root dir
+ROOT=`git rev-parse --show-toplevel`/autorelease
+
+BUILD_DIR=$ROOT/build
+
+mkdir -p $BUILD_DIR
+cd $BUILD_DIR
+
+# MAP of path to a parent pom from the perspective of hosting directory
+# starting from the autorelease repo root.
+#
+# Format: <groupId>:<artifactId>:<path>
+
+fix_name() {
+ pom=$1
+ echo -e "\nScanning $pom"
+ pomPath=`dirname $pom`
+
+ projectPath=${pomPath#*/} # Path to pom file from the perspective of hosting repo
+
+ relativePath="$projectPath" # Calculated relative path to parent pom
+
+ # Update any existing project names
+ xmlstarlet ed -P -N x=http://maven.apache.org/POM/4.0.0 \
+ -u "/x:project/x:name" -v "$relativePath" \
+ "$pom" > "${pom}.new"
+ mv "${pom}.new" "${pom}"
+
+ # Add missing ones
+ xmlstarlet ed -P -N x=http://maven.apache.org/POM/4.0.0 \
+ -s "/x:project[count(x:name)=0]" -t elem -n name -v "$relativePath" \
+ "$pom" > "${pom}.new"
+ mv "${pom}.new" "${pom}"
+}
+
+# Find all project poms ignoring the /src/ paths (We don't want to scan code)
+find . -name pom.xml -not -path "*/src/*" | xargs -I^ -P8 bash -c "$(declare -f fix_name); fix_name ^"