From 9979c2f565e5c9f67fc6e8751c713853cf749ef8 Mon Sep 17 00:00:00 2001
From: Peter Galonza
Date: Tue, 14 May 2024 23:45:47 +0300
Subject: [PATCH] add nx-hbmenu and nx-hbloader in build
---
Dockerfile | 2 ++
atmosphere.mk | 11 +++++++++--
docs/building.md | 10 ++++++++--
software.sh | 28 ++++++++++++++++++++++++++++
4 files changed, 47 insertions(+), 4 deletions(-)
create mode 100644 software.sh
diff --git a/Dockerfile b/Dockerfile
index 88d9fe284..4d92a35be 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -4,6 +4,8 @@ WORKDIR /app/
COPY ./requirements.txt /opt/requirements.txt
+RUN apt-get install -y --no-install-recommends jq curl
+
RUN apt-get install -y --no-install-recommends python3-venv && \
python3 -m venv /opt/venv && \
. /opt//venv/bin/activate && \
diff --git a/atmosphere.mk b/atmosphere.mk
index cca6fc106..9c44324e9 100644
--- a/atmosphere.mk
+++ b/atmosphere.mk
@@ -12,6 +12,10 @@ ATMOSPHERE_MICRO_VERSION := $(shell grep 'define ATMOSPHERE_RELEAS
ATMOSPHERE_SUPPORTED_HOS_MAJOR_VERSION := $(shell grep 'define ATMOSPHERE_SUPPORTED_HOS_VERSION_MAJOR\b' $(ATMOSPHERE_LIBRARIES_DIR)/libvapours/include/vapours/ams/ams_api_version.h | tr -s [:blank:] | cut -d' ' -f3)
ATMOSPHERE_SUPPORTED_HOS_MINOR_VERSION := $(shell grep 'define ATMOSPHERE_SUPPORTED_HOS_VERSION_MINOR\b' $(ATMOSPHERE_LIBRARIES_DIR)/libvapours/include/vapours/ams/ams_api_version.h | tr -s [:blank:] | cut -d' ' -f3)
ATMOSPHERE_SUPPORTED_HOS_MICRO_VERSION := $(shell grep 'define ATMOSPHERE_SUPPORTED_HOS_VERSION_MICRO\b' $(ATMOSPHERE_LIBRARIES_DIR)/libvapours/include/vapours/ams/ams_api_version.h | tr -s [:blank:] | cut -d' ' -f3)
+NX_HBMENU_VERSION := $(shell curl -s https://api.github.com/repos/switchbrew/nx-hbmenu/releases/latest | jq ".tag_name" | tr -d [v])
+NX_HBLOADER_VERSION := $(shell curl -s https://api.github.com/repos/switchbrew/nx-hbloader/releases/latest | jq ".tag_name" | tr -d [v])
+NX_HBMENU_DOWNLOAD := $(shell curl -s https://api.github.com/repos/switchbrew/nx-hbmenu/releases/latest | jq ".assets[0].browser_download_url")
+NX_HBLOADER_DOWNLOAD := $(shell curl -s https://api.github.com/repos/switchbrew/nx-hbloader/releases/latest | jq ".assets[0].browser_download_url")
ATMOSPHERE_VERSION := $(ATMOSPHERE_MAJOR_VERSION).$(ATMOSPHERE_MINOR_VERSION).$(ATMOSPHERE_MICRO_VERSION)-$(ATMOSPHERE_GIT_REVISION)
@@ -109,7 +113,10 @@ dist-no-debug: package3 $(CURRENT_DIRECTORY)/$(ATMOSPHERE_OUT_DIR)
cp troposphere/reboot_to_payload/reboot_to_payload.nro $(DIST_DIR)/switch/reboot_to_payload.nro
cp troposphere/daybreak/daybreak.nro $(DIST_DIR)/switch/daybreak.nro
cp troposphere/haze/haze.nro $(DIST_DIR)/switch/haze.nro
- cd $(DIST_DIR); zip -r ../atmosphere-$(ATMOSPHERE_VERSION).zip ./*; cd ../;
+ chmod +x $(CURRENT_DIRECTORY)/software.sh; $(CURRENT_DIRECTORY)/software.sh $(DIST_DIR);
+ $(eval NX_HBMENU_VERSION = $(curl -s https://api.github.com/repos/switchbrew/nx-hbmenu/releases/latest | jq -r ".tag_name" | tr -d [v]))
+ $(eval NX_HBLOADER_VERSION = $(curl -s https://api.github.com/repos/switchbrew/nx-hbloader/releases/latest | jq -r ".tag_name" | tr -d [v]))
+ cd $(DIST_DIR); zip -r ../atmosphere-$(ATMOSPHERE_VERSION)-hbl-$(NX_HBLOADER_VERSION)+hbmenu-$(NX_HBMENU_VERSION).zip ./*; cd ../;
rm -rf $(DIST_DIR)
cp fusee/$(ATMOSPHERE_BOOT_OUT_DIR)/fusee.bin $(CURRENT_DIRECTORY)/$(ATMOSPHERE_OUT_DIR)/fusee.bin
@@ -118,7 +125,7 @@ package3: emummc fusee stratosphere mesosphere exosphere troposphere
@echo "Built package3!"
emummc:
- $(MAKE) -C $(CURRENT_DIRECTORY)/emummc all
+ $(MAKE) -C $(CURRENT_DIRECTORY)/emummc
fusee: libexosphere_boot
@$(MAKE) --no-print-directory -C $(CURRENT_DIRECTORY)/fusee -f $(CURRENT_DIRECTORY)/fusee/fusee.mk ATMOSPHERE_CPU="$(strip $(ATMOSPHERE_BOOT_CPU))"
diff --git a/docs/building.md b/docs/building.md
index 4f000acf0..e14d90128 100644
--- a/docs/building.md
+++ b/docs/building.md
@@ -8,6 +8,8 @@ Building Atmosphère is a very straightforward process that relies almost exclus
+ [LZ4](https://pypi.org/project/lz4)
+ [PyCryptodome](https://pypi.org/project/pycryptodome) (optional)
+ [hactool](https://github.com/SciresM/hactool)
+* [JQ](https://github.com/jqlang/jq)
+* [Curl](https://github.com/curl/curl)
## Instructions
1. Follow the guide located [here](https://devkitpro.org/wiki/Getting_Started) to install and configure all the tools necessary for the build process.
@@ -20,7 +22,11 @@ Building Atmosphère is a very straightforward process that relies almost exclus
+ `devkitarm-rules`
+ `hactool`
-3. Install the following library via python's package manager `pip`, required by [exosphere](components/exosphere.md):
+3. Install he following packages via apt/dnf/yum/pacman
+ + `curl`
+ + `jq`
+
+4. Install the following library via python's package manager `pip`, required by [exosphere](components/exosphere.md):
+ `lz4`
-4. Finally, clone the Atmosphère repository and run `make` under its root directory.
+5. Finally, clone the Atmosphère repository and run `make` under its root directory.
diff --git a/software.sh b/software.sh
new file mode 100644
index 000000000..8e9eae72f
--- /dev/null
+++ b/software.sh
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+set -o errexit
+set -o xtrace
+
+TMP_DIR="$(dirname $0)/tmp"
+BUILD_DIR=$(if [[ -z $1 ]]; then echo "./"; else echo $1; fi)
+
+UNZIP_COMMAND="unzip -o"
+
+prepare_nx_hbmenu() {
+ download_url=$(curl -s https://api.github.com/repos/switchbrew/nx-hbmenu/releases/latest | jq -r ".assets[0].browser_download_url")
+ curl -O -L $download_url --output-dir $TMP_DIR
+ $UNZIP_COMMAND $TMP_DIR/nx-hbmenu_*.zip -d $BUILD_DIR
+}
+
+prepare_nx_hbloader() {
+ download_url=$(curl -s https://api.github.com/repos/switchbrew/nx-hbloader/releases/latest | jq -r ".assets[0].browser_download_url")
+ curl -O -L $download_url --output-dir $TMP_DIR
+ cp $TMP_DIR/hbl.nsp -d $BUILD_DIR/atmosphere
+}
+
+mkdir $TMP_DIR
+
+prepare_nx_hbloader
+prepare_nx_hbmenu
+
+rm -rf $TMP_DIR