From b2ed292dad0444be17ba8846bb97baed711072e9 Mon Sep 17 00:00:00 2001
From: Robert Nelson <robertcnelson@gmail.com>
Date: Tue, 26 Dec 2023 12:43:45 -0600
Subject: [PATCH] ci: build native riscv64 gateware package and deploy debian
 repo over gitlab pages

Signed-off-by: Robert Nelson <robertcnelson@gmail.com>
---
 .gitlab-ci.yml                                | 35 +++++++++++++++++++
 ....io-gateware-my-custom-fpga-design.install |  3 ++
 debian/changelog                              |  5 +++
 debian/compat                                 |  1 +
 debian/control                                | 17 +++++++++
 debian/rules                                  | 10 ++++++
 6 files changed, 71 insertions(+)
 create mode 100644 debian/bbb.io-gateware-my-custom-fpga-design.install
 create mode 100644 debian/changelog
 create mode 100644 debian/compat
 create mode 100644 debian/control
 create mode 100755 debian/rules

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index ca0aee0..f8ce005 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,5 +1,6 @@
 stages:          # List of stages for jobs, and their order of execution
   - build
+  - deploy
 
 build-job:       # This job runs in the build stage, which runs first.
   stage: build
@@ -38,3 +39,37 @@ build-job:       # This job runs in the build stage, which runs first.
       - gateware-builds-tester/artifacts/
     reports:
       junit: gateware-builds-tester/artifacts/tests_report.xml
+
+pages:
+  image: robertcnelson/beagle-devscripts-ubuntu-23.04-riscv64:latest
+  # https://git.beagleboard.org/beagleboard/ci-docker-images
+  stage: deploy
+  tags:
+    - docker-riscv64-ci
+  variables:
+    BUILD_OPTIONS_DIRECTORY: "custom-fpga-design"
+  script:
+    - rm -rf ./src/ || true
+    - mkdir -p ./src/debian/ || true
+    - rsync -av ./debian/* ./src/debian/
+    - mkdir -p ./src/gateware-builds-tester || true
+    - rsync -av ./gateware-builds-tester/* ./src/gateware-builds-tester/
+    - echo "bbb.io-gateware-my-custom-fpga-design (1.$(LANG=C date +%Y%m%d).0~lunar) lunar; urgency=low" > ./src/debian/changelog
+    - echo "" >> ./src/debian/changelog
+    - echo "  * ci build of $CI_PROJECT_URL" >> ./src/debian/changelog
+    - echo "" >> ./src/debian/changelog
+    - echo " -- $GITLAB_USER_NAME <$GITLAB_USER_EMAIL>  $(LANG=C date -R)" >> ./src/debian/changelog
+    - echo "" >> ./src/debian/changelog
+    - cat ./src/debian/changelog
+    - cd ./src/ ; debuild -b -us -uc ; cd ../
+    - mkdir -p ./public/dists/stable/main/binary-riscv64/
+    - mkdir -p ./public/pool
+    - cp -v *.deb ./public/pool/ || true
+    - cp -v *.build ./public/ || true
+    - cp -v *.buildinfo ./public/ || true
+    - cd ./public ; dpkg-scanpackages ./pool/ | gzip > ./dists/stable/main/binary-riscv64/Packages.gz || true ; cd ../
+    - apindex public
+  artifacts:
+    when: on_success
+    paths:
+      - public
diff --git a/debian/bbb.io-gateware-my-custom-fpga-design.install b/debian/bbb.io-gateware-my-custom-fpga-design.install
new file mode 100644
index 0000000..443448b
--- /dev/null
+++ b/debian/bbb.io-gateware-my-custom-fpga-design.install
@@ -0,0 +1,3 @@
+gateware-builds-tester/artifacts/bitstreams/my_custom_fpga_design/DirectC/* /usr/share/beagleboard/gateware/my_custom_fpga_design/DirectC
+gateware-builds-tester/artifacts/bitstreams/my_custom_fpga_design/FlashProExpress/* /usr/share/beagleboard/gateware/my_custom_fpga_design/FlashProExpress
+gateware-builds-tester/artifacts/bitstreams/my_custom_fpga_design/LinuxProgramming/* /usr/share/beagleboard/gateware/my_custom_fpga_design/LinuxProgramming
\ No newline at end of file
diff --git a/debian/changelog b/debian/changelog
new file mode 100644
index 0000000..eb1960d
--- /dev/null
+++ b/debian/changelog
@@ -0,0 +1,5 @@
+bbb.io-gateware-my-custom-fpga-design (1.20231226.0~lunar) lunar; urgency=low
+
+  * ci build of https://git.beagleboard.org/beaglev-fire/gateware
+
+ -- Robert Nelson <robertcnelson@beagleboard.org>  Tue, 26 Dec 2023 17:41:26 +0000
diff --git a/debian/compat b/debian/compat
new file mode 100644
index 0000000..f599e28
--- /dev/null
+++ b/debian/compat
@@ -0,0 +1 @@
+10
diff --git a/debian/control b/debian/control
new file mode 100644
index 0000000..9215394
--- /dev/null
+++ b/debian/control
@@ -0,0 +1,17 @@
+Source: bbb.io-gateware-my-custom-fpga-design
+Section: misc
+Priority: extra
+Maintainer: Robert Nelson <robertcnelson@gmail.com>
+Build-Depends:
+ debhelper (>= 10)
+Standards-Version: 4.5.1
+
+Package: bbb.io-gateware-my-custom-fpga-design
+Architecture: all
+Depends:
+ ${shlibs:Depends}
+ , ${misc:Depends}
+ , bbb.io-gateware
+ , mtd-utils
+Description: bbb.io-gateware-my-custom-fpga-design
+ bbb.io-gateware-my-custom-fpga-design
diff --git a/debian/rules b/debian/rules
new file mode 100755
index 0000000..9752fa6
--- /dev/null
+++ b/debian/rules
@@ -0,0 +1,10 @@
+#!/usr/bin/make -f
+# See debhelper(7) (uncomment to enable)
+# output every command that modifies files on the build system.
+DH_VERBOSE = 1
+
+%:
+	dh $@
+
+override_dh_builddeb:
+	dh_builddeb -- -Zxz
-- 
GitLab