From 3dd9bc13ebb42a27e2169b61239343eb54ba83bb Mon Sep 17 00:00:00 2001
From: Stefan Moll <stefan@stefaus.de>
Date: Wed, 14 Sep 2022 12:20:33 +0200
Subject: [PATCH] changed pb_submitter build, added to readme

---
 pb_utils/pb_submitter/.gitignore     |  2 ++
 pb_utils/pb_submitter/Makefile       |  7 -------
 pb_utils/pb_submitter/build.sh       | 14 +++++++-------
 pb_utils/pb_submitter/example_run.sh |  2 +-
 pb_utils/pb_submitter/pb_submitter.c |  3 ++-
 pb_utils/readme.md                   |  6 ++++++
 6 files changed, 18 insertions(+), 16 deletions(-)
 create mode 100644 pb_utils/pb_submitter/.gitignore
 delete mode 100644 pb_utils/pb_submitter/Makefile

diff --git a/pb_utils/pb_submitter/.gitignore b/pb_utils/pb_submitter/.gitignore
new file mode 100644
index 000000000000..6d5984422b40
--- /dev/null
+++ b/pb_utils/pb_submitter/.gitignore
@@ -0,0 +1,2 @@
+pb_submitter
+test_prog
diff --git a/pb_utils/pb_submitter/Makefile b/pb_utils/pb_submitter/Makefile
deleted file mode 100644
index 55503d9ce1a2..000000000000
--- a/pb_utils/pb_submitter/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-obj-m += pb_module.o
-
-all:
-	make -C $(PWD)/../../ M=$(PWD) modules
-
-clean:
-	make -C $(PWD)/../../ M=$(PWD) clean
diff --git a/pb_utils/pb_submitter/build.sh b/pb_utils/pb_submitter/build.sh
index 4b92faed1e92..518b471e4177 100755
--- a/pb_utils/pb_submitter/build.sh
+++ b/pb_utils/pb_submitter/build.sh
@@ -1,14 +1,14 @@
 #!/bin/bash
 
-#make
-mkdir -p mnt
+if [ ! -d "/mnt/pb_utils/pb_submitter" ]; then
+    echo "are you running this in chroot or the build system?"
+    exit 1
+fi
 
+cd /mnt/pb_utils/pb_submitter
 gcc -static -o pb_submitter pb_submitter.c
 gcc -static -o test_prog test_prog.c
 
-sudo mount -o loop ../build/qemu-image.img ./mnt
-sudo cp pb_submitter test_prog example_run.sh example_plan ./mnt/root
+cp pb_submitter test_prog example_run.sh example_plan /root
 
-sudo umount ./mnt
-
-echo "All done. Run ./run_qemu.sh now"
+echo "All done. Run '/root/example_run.sh' within ./run_qemu.sh now"
diff --git a/pb_utils/pb_submitter/example_run.sh b/pb_utils/pb_submitter/example_run.sh
index 380e11c0c248..43de115acb58 100755
--- a/pb_utils/pb_submitter/example_run.sh
+++ b/pb_utils/pb_submitter/example_run.sh
@@ -1,3 +1,3 @@
 #!/bin/sh
-
+cd /root
 ./pb_submitter test_prog example_plan
diff --git a/pb_utils/pb_submitter/pb_submitter.c b/pb_utils/pb_submitter/pb_submitter.c
index 023146b98c0c..bfa3d2815756 100644
--- a/pb_utils/pb_submitter/pb_submitter.c
+++ b/pb_utils/pb_submitter/pb_submitter.c
@@ -71,7 +71,8 @@ int main(int argc, char** argv)
         return -1;
     }
 
-    for (size_t i = 0; i < plan.num_tasks; i++) {
+    size_t i;
+    for (i = 0; i < plan.num_tasks; i++) {
         cnt = getline(&line, &len, fp);
 
         if (cnt < 0) {
diff --git a/pb_utils/readme.md b/pb_utils/readme.md
index f7f06bf91c68..6372d259c9a6 100644
--- a/pb_utils/readme.md
+++ b/pb_utils/readme.md
@@ -26,6 +26,12 @@ run `./chroot_image.sh`, this drops you in a shell on the created debian and run
 /mnt/pb_utils/mod_gen/build.sh
 ```
 
+## chroot into debian rootfs to build pb_submitter
+run `./chroot_image.sh`, this drops you in a shell on the created debian and run
+```bash
+/mnt/pb_utils/pb_submitter/build.sh
+```
+
 # run the build kernel with the created rootfs
 run `./run_qemu.sh`
 
-- 
GitLab