From d85cb2098e3f0127136ad1f75292b08abebc271d Mon Sep 17 00:00:00 2001
From: dgelessus <dgelessus@users.noreply.github.com>
Date: Fri, 6 Oct 2023 12:32:16 +0200
Subject: [PATCH] Add instructions and script for updating the Rodin sources

---
 README.md         | 46 +++++++++++++++++++++++++++++++++++
 update_sources.sh | 62 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 108 insertions(+)
 create mode 100755 update_sources.sh

diff --git a/README.md b/README.md
index e78b87b..7fdb5ea 100644
--- a/README.md
+++ b/README.md
@@ -20,3 +20,49 @@ We also added the following files to support the Maven Central build/upload proc
 * pubring.gpg.enc
 * secring.gpg.enc
 * settings.gradle
+* update_sources.sh
+
+## How to update this project to a new Rodin version
+
+First, remove any local changes in your clone of this repo, to avoid possible conflicts or other issues:
+
+```sh
+$ git restore --staged --worktree . # DELETES ALL LOCAL CHANGES!
+```
+
+In a different directory, clone the rodincore repo (if you haven't already):
+
+```sh
+$ cd /some/work/directory
+$ git clone "https://git.code.sf.net/p/rodin-b-sharp/rodincore" rodin-b-sharp-rodincore
+$ cd rodin-b-sharp-rodincore
+```
+
+Check out the desired Rodin release, for example:
+
+```sh
+$ git switch --detach RodinCore/3.3
+```
+
+In this repo, run the `update_sources.sh` script and pass the path of the source org.eventb.core.ast project:
+
+```sh
+$ cd .../rodin_eventb_ast
+$ ./update_sources.sh /some/work/directory/rodin-b-sharp-rodincore/org.eventb.core.ast
+```
+
+Update the version number in build.gradle to the appropriate version *with a SNAPSHOT suffix*, for example:
+
+```groovy
+project.version = "3.3.0-SNAPSHOT"
+```
+
+Add the version change and commit and push everything:
+
+```sh
+$ git add build.gradle
+$ git commit -m "Update to Rodin 3.3 sources"
+$ git push
+```
+
+Once you have confirmed that the new snapshot works, you can remove the -SNAPSHOT suffix and make a proper release to Maven Central.
diff --git a/update_sources.sh b/update_sources.sh
new file mode 100755
index 0000000..68e43b1
--- /dev/null
+++ b/update_sources.sh
@@ -0,0 +1,62 @@
+#!/bin/sh
+
+set -e -u
+
+if [ "$#" -ne 1 ]
+then
+	echo "$0: expected exactly 1 argument, not $#" >&2
+	echo "usage: $0 RODINCORE_AST_PATH" >&2
+	exit 2
+fi
+
+original_path="$1"
+own_sources_path="$(dirname "$0")"
+
+if [ -z "${own_sources_path}" ]
+then
+	echo "$0: failed to determine destination path"
+	exit 1
+fi
+
+git rm -r \
+	"${own_sources_path}/build-gen.xml" \
+	"${own_sources_path}/build.properties" \
+	"${own_sources_path}/customBuildCallbacks.xml" \
+	"${own_sources_path}/epl-v10.html" \
+	"${own_sources_path}/META-INF" \
+	"${own_sources_path}/notice.html" \
+	"${own_sources_path}/plugin.properties" \
+	"${own_sources_path}/src" \
+	"${own_sources_path}/tom" \
+	"${own_sources_path}/tools"
+
+cp -R \
+	"${original_path}/build-gen.xml" \
+	"${original_path}/build.properties" \
+	"${original_path}/customBuildCallbacks.xml" \
+	"${original_path}/epl-v10.html" \
+	"${original_path}/META-INF" \
+	"${original_path}/notice.html" \
+	"${original_path}/plugin.properties" \
+	"${original_path}/src" \
+	"${original_path}/tom" \
+	"${original_path}/tools" \
+	"${own_sources_path}"
+
+# We replaced this file - keep our version instead of the original.
+git restore --staged --worktree "${own_sources_path}/src/org/eventb/internal/core/ast/ASTPlugin.java"
+
+git add \
+	"${own_sources_path}/build-gen.xml" \
+	"${own_sources_path}/build.properties" \
+	"${own_sources_path}/customBuildCallbacks.xml" \
+	"${own_sources_path}/epl-v10.html" \
+	"${own_sources_path}/META-INF" \
+	"${own_sources_path}/notice.html" \
+	"${own_sources_path}/plugin.properties" \
+	"${own_sources_path}/src" \
+	"${own_sources_path}/tom" \
+	"${own_sources_path}/tools"
+
+echo "Successfully updated with sources from ${original_path}"
+echo "Remember to update the version number in build.gradle!"
-- 
GitLab