Skip to content

Commit 96f11df

Browse files
authored
Merge branch 'feature/preagonal-changes' into feature/ghidra-11.4
2 parents aed1cf1 + cb80fea commit 96f11df

File tree

12 files changed

+333
-61
lines changed

12 files changed

+333
-61
lines changed

.gitmodules

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[submodule "Ghidra/Extensions/GhidraMCP"]
2+
path = Ghidra/Extensions/GhidraMCP
3+
url = ../GhidraMCP
4+
[submodule "Ghidra/Extensions/ExtractCPPStruct"]
5+
path = Ghidra/Extensions/ExtractCPPStruct
6+
url = ../Ghidra.Plugins.ExtractCPPStruct

.idea/runConfigurations/GhidraLauncher.xml

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM eclipse-temurin:23 AS build
2+
COPY . /home/gradle/src
3+
USER root
4+
WORKDIR /home/gradle/src
5+
RUN apt update ; apt install -y build-essential python3 python3-pip git unzip
6+
RUN git config --global user.email "[email protected]"
7+
RUN git config --global user.name "Your Name"
8+
RUN ./gradlew -I gradle/support/fetchDependencies.gradle
9+
RUN ./gradlew prepDev
10+
RUN ./gradlew buildGhidra --parallel --no-daemon --stacktrace

Ghidra/Extensions/ExtractCPPStruct

Submodule ExtractCPPStruct added at 7e423f3

Ghidra/Extensions/GhidraMCP

Submodule GhidraMCP added at 054da8c

Ghidra/application.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
application.name=Ghidra
22
application.version=11.4
3-
application.release.name=DEV
3+
application.release.name=Preagonal
44
application.layout.version=3
55
application.gradle.min=8.5
66
application.gradle.max=

Jenkinsfile

Lines changed: 272 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,272 @@
1+
def notify(status){
2+
emailext (
3+
body: '$DEFAULT_CONTENT',
4+
recipientProviders: [
5+
[$class: 'CulpritsRecipientProvider'],
6+
[$class: 'DevelopersRecipientProvider'],
7+
[$class: 'RequesterRecipientProvider']
8+
],
9+
replyTo: '$DEFAULT_REPLYTO',
10+
subject: '$DEFAULT_SUBJECT',
11+
to: '$DEFAULT_RECIPIENTS'
12+
)
13+
}
14+
15+
@NonCPS
16+
def killall_jobs() {
17+
def jobname = env.JOB_NAME;
18+
def buildnum = env.BUILD_NUMBER.toInteger();
19+
def killnums = "";
20+
def job = Jenkins.instance.getItemByFullName(jobname);
21+
def split_job_name = env.JOB_NAME.split(/\/{1}/);
22+
def fixed_job_name = split_job_name[1].replace('%2F',' ');
23+
24+
for (build in job.builds) {
25+
if (!build.isBuilding()) { continue; }
26+
if (buildnum == build.getNumber().toInteger()) { continue; println "equals"; }
27+
if (buildnum < build.getNumber().toInteger()) { continue; println "newer"; }
28+
29+
echo("Kill task = ${build}");
30+
31+
killnums += "#" + build.getNumber().toInteger() + ", ";
32+
33+
build.doStop();
34+
}
35+
36+
if (killnums != "") {
37+
discordSend description: "in favor of #${buildnum}, ignore following failed builds for ${killnums}", footer: "", link: env.BUILD_URL, result: "ABORTED", title: "[${split_job_name[0]}] Killing task(s) ${fixed_job_name} ${killnums}", webhookURL: env.GS2EMU_WEBHOOK
38+
}
39+
echo("Done killing");
40+
}
41+
42+
def buildStepDocker() {
43+
def split_job_name = env.JOB_NAME.split(/\/{1}/);
44+
def fixed_job_name = split_job_name[1].replace('%2F',' ');
45+
46+
try {
47+
checkout(scm);
48+
49+
def buildenv = "";
50+
def tag = '';
51+
def VER = '';
52+
def EXTRA_VER = '';
53+
54+
55+
if(env.TAG_NAME) {
56+
sh(returnStdout: true, script: "echo '```' > RELEASE_DESCRIPTION.txt");
57+
env.RELEASE_DESCRIPTION = sh(returnStdout: true, script: "git tag -l --format='%(contents)' ${env.TAG_NAME} >> RELEASE_DESCRIPTION.txt");
58+
sh(returnStdout: true, script: "echo '```' >> RELEASE_DESCRIPTION.txt");
59+
}
60+
61+
if (env.BRANCH_NAME.equals('main')) {
62+
tag = "latest";
63+
} else {
64+
tag = "${env.BRANCH_NAME.replace('/','-')}";
65+
}
66+
67+
def PUSH_ARTIFACT = false;
68+
69+
if (env.TAG_NAME) {
70+
EXTRA_VER = "";
71+
VER = "${env.TAG_NAME}";
72+
PUSH_ARTIFACT = true;
73+
} else if (env.BRANCH_NAME.equals('dev')) {
74+
EXTRA_VER = "--build-arg VER_EXTRA=-beta";
75+
} else {
76+
EXTRA_VER = "--build-arg VER_EXTRA=-${tag}";
77+
}
78+
79+
docker.withRegistry("https://index.docker.io/v1/", "dockergraal") {
80+
def release_name = env.JOB_NAME.replace('%2F','/');
81+
def release_type = ("${release_name}").replace('/','-').replace('node-grc-','').replace('main','').replace('dev','');
82+
83+
def customImage;
84+
85+
stage("Building project") {
86+
customImage = docker.build("ghidra:${tag}", "--build-arg BUILDENV=${buildenv} ${EXTRA_VER} --network=host --pull -f Dockerfile .");
87+
}
88+
89+
if (PUSH_ARTIFACT) {
90+
stage("Archiving artifacts...") {
91+
customImage.inside("") {
92+
sh "mkdir -p ./dist && cp -fvr /home/gradle/src/build/dist/* ./dist"
93+
94+
dir("./dist") {
95+
sh "unzip -j ghidra_*.zip */Extensions/Ghidra/*.zip"
96+
archiveArtifacts artifacts: '*.zip,*.tar.gz,*.tgz', allowEmptyArchive: true
97+
//discordSend description: "Docker Image: ${DOCKER_ROOT}/${DOCKERIMAGE}:${tag}", footer: "", link: env.BUILD_URL, result: currentBuild.currentResult, title: "[${split_job_name[0]}] Artifact Successful: ${fixed_job_name} #${env.BUILD_NUMBER}", webhookURL: env.GS2EMU_WEBHOOK;
98+
}
99+
}
100+
def dockerImageRef = docker.image("amigadev/docker-base:latest");
101+
dockerImageRef.pull();
102+
103+
dockerImageRef.inside("") {
104+
105+
stage("Github Release") {
106+
withCredentials([string(credentialsId: 'PREAGONAL_GITHUB_TOKEN', variable: 'GITHUB_TOKEN')]) {
107+
dir("./dist") {
108+
if (!env.CHANGE_ID) { // Don't run on PR's
109+
def release_type_tag = 'develop';
110+
def pre_release = '--pre-release';
111+
if (env.TAG_NAME) {
112+
pre_release = '';
113+
release_type_tag = env.TAG_NAME;
114+
} else if (env.BRANCH_NAME.equals('master')) {
115+
release_type_tag = 'nightly';
116+
}
117+
118+
119+
if (!env.TAG_NAME) {
120+
sh(returnStdout: true, script: "echo -e '${release_type_tag} releases' > ../RELEASE_DESCRIPTION.txt");
121+
}
122+
123+
def files = sh(returnStdout: true, script: 'find . -name "*.zip" -o -name "*.tar.gz"').split('\n');
124+
125+
try {
126+
sh "cat ../RELEASE_DESCRIPTION.txt | github-release release --user Preagonal --repo ghidra --tag ${release_type_tag} --name \"Ghidra ${release_type_tag}\" ${pre_release} --description -"
127+
} catch(err) {
128+
129+
}
130+
131+
try {
132+
files.eachWithIndex { file, idx ->
133+
try {
134+
if (file != null && !file.allWhitespace) {
135+
def file2 = sh (script: "basename ${file}",returnStdout:true).trim();
136+
try {
137+
sh "github-release upload --user Preagonal --repo ghidra --tag ${release_type_tag} --name \"${file2}\" --file ${file2} --replace";
138+
} catch(err) {
139+
echo("err(3): ${err}");
140+
141+
sleep 15;
142+
sh "github-release upload --user Preagonal --repo ghidra --tag ${release_type_tag} --name \"${file2}\" --file ${file2} --replace";
143+
}
144+
}
145+
} catch(err) {
146+
echo("err(2): ${err}");
147+
}
148+
}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​
149+
} catch(err) {
150+
echo("err(1): ${err}");
151+
}
152+
}
153+
}
154+
}
155+
}
156+
}
157+
}
158+
} else {
159+
// Do nothing
160+
}
161+
162+
def archive_date = sh (
163+
script: 'date +"-%Y%m%d-%H%M"',
164+
returnStdout: true
165+
).trim();
166+
167+
if (env.TAG_NAME) {
168+
archive_date = '';
169+
}
170+
171+
if (env.TAG_NAME) {
172+
173+
}
174+
}
175+
} catch(err) {
176+
currentBuild.result = 'FAILURE'
177+
discordSend description: "", footer: "", link: env.BUILD_URL, result: currentBuild.currentResult, title: "[${split_job_name[0]}] Build Failed: ${fixed_job_name} #${env.BUILD_NUMBER}", webhookURL: env.GS2EMU_WEBHOOK
178+
179+
notify("Build Failed: ${fixed_job_name} #${env.BUILD_NUMBER}")
180+
throw err
181+
}
182+
}
183+
184+
node('master') {
185+
killall_jobs();
186+
def split_job_name = env.JOB_NAME.split(/\/{1}/);
187+
def fixed_job_name = split_job_name[1].replace('%2F',' ');
188+
checkout(scm);
189+
190+
env.COMMIT_MSG = sh(
191+
script: 'git log -1 --pretty=%B ${GIT_COMMIT}',
192+
returnStdout: true
193+
).trim();
194+
195+
env.GIT_COMMIT = sh(
196+
script: 'git log -1 --pretty=%H ${GIT_COMMIT}',
197+
returnStdout: true
198+
).trim();
199+
200+
//sh('git fetch --tags');
201+
202+
env.LATEST_TAG = sh(
203+
script: 'git tag --sort=creatordate -l | tail -1',
204+
returnStdout: true
205+
).trim();
206+
207+
echo("Latest tag: ${env.LATEST_TAG}");
208+
209+
def version = env.LATEST_TAG.split(/\./);
210+
211+
echo("Version: ${version}");
212+
213+
def verMajor = version[0] as Integer;
214+
def verMinor = version[1] as Integer;
215+
def verPatch = version[2] as Integer;
216+
def verRev = version[3] as Integer;
217+
def versionChanged = false;
218+
219+
echo("Version - Major: ${verMajor}, Minor: ${verMinor}, Patch: ${verPatch}");
220+
221+
if (env.BRANCH_NAME.equals('main')) {
222+
verMinor++;
223+
verPatch = 0;
224+
versionChanged = true;
225+
} else if (env.BRANCH_NAME.equals('dev')) {
226+
verPatch++;
227+
versionChanged = true;
228+
} else if (env.BRANCH_NAME.equals('feature/preagonal-changes')) {
229+
verRev++;
230+
versionChanged = true;
231+
}
232+
233+
if (versionChanged) {
234+
withCredentials([string(credentialsId: 'PREAGONAL_GITHUB_TOKEN', variable: 'GITHUB_TOKEN')]) {
235+
def tagName = "${verMajor}.${verMinor}.${verPatch}.${verRev}";
236+
237+
def iso8601Date = sh(
238+
script: 'date -Iseconds',
239+
returnStdout: true
240+
).trim();
241+
242+
env.JSON_RESPONSE = sh(
243+
script: "curl -L -X POST -H \"Accept: application/vnd.github+json\" -H \"Authorization: Bearer ${env.GITHUB_TOKEN}\" -H \"X-GitHub-Api-Version: 2022-11-28\" https://api.github.com/repos/Preagonal/ghidra/git/tags -d '{\"tag\":\"${tagName}\",\"message\":\"${env.COMMIT_MSG}\",\"object\":\"${env.GIT_COMMIT}\",\"type\":\"tree\",\"tagger\":{\"name\":\"preagonal-pipeline[bot]\",\"email\":\"119898225+preagonal-pipeline[bot]@users.noreply.github.com\",\"date\":\"${iso8601Date}\"}}'",
244+
returnStdout: true
245+
);
246+
def response = readJSON(text: env.JSON_RESPONSE);
247+
248+
sh(
249+
script: "curl -L -X POST -H \"Accept: application/vnd.github+json\" -H \"Authorization: Bearer ${env.GITHUB_TOKEN}\" -H \"X-GitHub-Api-Version: 2022-11-28\" https://api.github.com/repos/Preagonal/ghidra/git/refs -d '{\"ref\": \"refs/tags/${tagName}\", \"sha\": \"${response.sha}\"}'",
250+
returnStdout: true
251+
);
252+
}
253+
}
254+
255+
discordSend description: "${env.COMMIT_MSG}", footer: "", link: env.BUILD_URL, result: currentBuild.currentResult, title: "[${split_job_name[0]}] Build Started: ${fixed_job_name} #${env.BUILD_NUMBER}", webhookURL: env.GS2EMU_WEBHOOK
256+
257+
if (env.TAG_NAME) {
258+
sh(returnStdout: true, script: "echo '```' > RELEASE_DESCRIPTION.txt");
259+
env.RELEASE_DESCRIPTION = sh(returnStdout: true, script: "git tag -l --format='%(contents)' ${env.TAG_NAME} >> RELEASE_DESCRIPTION.txt");
260+
sh(returnStdout: true, script: "echo '```' >> RELEASE_DESCRIPTION.txt");
261+
}
262+
263+
node("linux") {
264+
buildStepDocker();
265+
}
266+
267+
if (env.TAG_NAME) {
268+
//def DESC = sh(returnStdout: true, script: 'cat RELEASE_DESCRIPTION.txt');
269+
}
270+
271+
sh("rm -rf ./*");
272+
}

gradle/wrapper/gradle-wrapper.jar

42.7 KB
Binary file not shown.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
6+
zipStoreBase=GRADLE_USER_HOME
7+
zipStorePath=wrapper/dists

gradlew

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
1717
#
18+
# SPDX-License-Identifier: Apache-2.0
19+
#
1820

1921
##############################################################################
2022
#
@@ -55,7 +57,7 @@
5557
# Darwin, MinGW, and NonStop.
5658
#
5759
# (3) This script is generated from the Groovy template
58-
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
60+
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
5961
# within the Gradle project.
6062
#
6163
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -84,7 +86,7 @@ done
8486
# shellcheck disable=SC2034
8587
APP_BASE_NAME=${0##*/}
8688
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
87-
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
89+
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
8890

8991
# Use the maximum available, or set MAX_FD != -1 to use that value.
9092
MAX_FD=maximum
@@ -112,32 +114,8 @@ case "$( uname )" in #(
112114
NONSTOP* ) nonstop=true ;;
113115
esac
114116

115-
#------------Ghidra Additions ----------------------------------------------------------------------
116-
117-
# Set variables based on Production vs Dev environment
118-
if [ -f "${APP_HOME}/gradle-wrapper.jar" ]; then
119-
# Production Environment
120-
CLASSPATH="${APP_HOME}/gradle-wrapper.jar"
121-
GHIDRA_HOME="${APP_HOME}/../.."
122-
else
123-
# Development Environment (Eclipse classes or "gradle jar")
124-
CLASSPATH="${APP_HOME}/Ghidra/RuntimeScripts/Common/support/gradle/gradle-wrapper.jar"
125-
GHIDRA_HOME="${APP_HOME}"
126-
fi
117+
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
127118

128-
# Read application properties
129-
while IFS='=' read -r key value
130-
do
131-
key=$(echo $key | tr '.' '_')
132-
eval ${key}=\${value}
133-
done < "${GHIDRA_HOME}/Ghidra/application.properties"
134-
135-
# Only proceed with wrapper if we are in single-repo PUBLIC/DEV mode
136-
if [ -d "${GHIDRA_HOME}/../ghidra.bin" ] || ([ ${application_release_name} != "PUBLIC" ] && [ ${application_release_name} != "DEV" ]) ; then
137-
echo "Please install Gradle ${application_gradle_min} or later and put it on your PATH."
138-
exit 1
139-
fi
140-
#---------------------------------------------------------------------------------------------------
141119

142120
# Determine the Java command to use to start the JVM.
143121
if [ -n "$JAVA_HOME" ] ; then
@@ -227,7 +205,7 @@ fi
227205
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
228206

229207
# Collect all arguments for the java command:
230-
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
208+
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
231209
# and any embedded shellness will be escaped.
232210
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
233211
# treated as '${Hostname}' itself on the command line.

0 commit comments

Comments
 (0)