Skip to content

Commit

Permalink
fix patches url, add sys-patch updating, re-license from GPL to MIT
Browse files Browse the repository at this point in the history
  • Loading branch information
ITotalJustice committed May 21, 2023
1 parent 3bb4925 commit 6cf118c
Show file tree
Hide file tree
Showing 12 changed files with 278 additions and 810 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/build_depoly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: build
on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
container: devkitpro/devkita64:latest

steps:
- name: Checkout 🛎️
uses: actions/checkout@master

- name: Build
run: make dist -j2

- uses: actions/upload-artifact@master
with:
name: sigpatch-updater
path: sigpatch-updater.zip
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/old_romfs*
/.vscode*
/build*
build
*.elf
*.nacp
*.nro
!.vscode/c_cpp_properties.json
*.zip
out
18 changes: 18 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"configurations": [
{
"name": "switch",
"includePath": [
"${default}",
"${workspaceFolder}/**",
"${DEVKITPRO}/libnx/include/",
"${DEVKITPRO}/portlibs/switch/include/"
],
"defines": [],
"cStandard": "c17",
"cppStandard": "c++23",
"compilerPath": "${DEVKITPRO}/devkitA64/bin/aarch64-none-elf-gcc"
}
],
"version": 4
}
695 changes: 21 additions & 674 deletions LICENSE

Large diffs are not rendered by default.

17 changes: 13 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ include $(DEVKITPRO)/libnx/switch_rules
# of a homebrew executable (.nro). This is intended to be used for sysmodules.
# NACP building is skipped as well.
#---------------------------------------------------------------------------------
APP_TITLE := Sigpatch-Updater
APP_TITLE := sigpatch-updater
APP_AUTHOR := TotalJustice
APP_VERSION := 0.1.4
APP_VERSION := 0.2.0

TARGET := $(notdir $(CURDIR))
TARGET := sigpatch-updater
BUILD := build
SOURCES := source
DATA := data
Expand All @@ -53,7 +53,7 @@ INCLUDES := includes
#---------------------------------------------------------------------------------
ARCH := -march=armv8-a+crc+crypto -mtune=cortex-a57 -mtp=soft -fPIE

CFLAGS := -Wall -O3 -ffunction-sections \
CFLAGS := -Wall -O2 -ffunction-sections \
$(ARCH) $(DEFINES)

CFLAGS += $(INCLUDE) -D__SWITCH__
Expand Down Expand Up @@ -168,6 +168,10 @@ $(BUILD):
@[ -d $@ ] || mkdir -p $@
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile

@rm -rf out/
@mkdir -p out/switch/sigpatch-updater/
@cp $(CURDIR)/$(TARGET).nro out/switch/sigpatch-updater/

#---------------------------------------------------------------------------------
clean:
@echo clean ...
Expand All @@ -176,7 +180,12 @@ ifeq ($(strip $(APP_JSON)),)
else
@rm -fr $(BUILD) $(TARGET).nsp $(TARGET).nso $(TARGET).npdm $(TARGET).elf
endif
#---------------------------------------------------------------------------------
dist: all
@echo making dist ...

@rm -f sigpatch-updater.zip
@cd out; zip -r ../sigpatch-updater.zip ./*; cd ../
#---------------------------------------------------------------------------------
nxlink: all
@echo making and nxlinking ...
Expand Down
28 changes: 19 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,35 @@
# Sigpatch-Updater

This is a updater for you sigpatches! Currently it has the option to:
This is a updater for you sigpatches!

* Download patches needed for Atmosphere
Currently it has the option to:

- Update patches needed for Atmosphere
- Update sys-patch and auto run the sysmod
- Update the app

---

![Img](images/example.jpg)

----

## Where does it download the patches from?

The patches are download from my [patches repo](https://github.com/ITotalJustice/patches).
The patches are download from [a new host](https://sigmapatches.coomer.party). Huge thanks to them!

----
---

## Special Thanks!
## What is sys-patch?

[toph](https://github.com/sudot0ph) for the design of the app icon!
you can read more about it [here](https://github.com/ITotalJustice/sys-patch).

The-4n for continuing to update the sigpatch thread of gbatemp!
----

Joonie for their help with hekate patches in the past!
## Special Thanks!

TeJay for maintaining the patches repo!
- [toph](https://github.com/sudot0ph) for the design of the app icon
- The-4n for previously updating the sigpatch thread on gbatemp
- Joonie for their help with hekate patches in the past
- TeJay for previously maintaining the patches repo
- Archbox for being very helpful as always
Binary file modified images/example.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion includes/download.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#ifndef _DOWNLOAD_H_
#define _DOWNLOAD_H_

#define AMS_SIG_URL "https://github.com/ITotalJustice/patches/releases/latest/download/SigPatches.zip"
#define AMS_SIG_URL "https://sigmapatches.coomer.party/sigpatches.zip?latest"
#define APP_URL "https://github.com/ITotalJustice/sigpatch-updater/releases/latest/download/sigpatch-updater.nro"
#define SYS_PATCH_URL "https://github.com/ITotalJustice/sys-patch/releases/latest/download/sys-patch.zip"
#define TEMP_FILE "/switch/sigpatch-updater/temp"

#define ON 1
Expand Down
5 changes: 1 addition & 4 deletions includes/unzip.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#ifndef _UNZIP_H_
#define _UNZIP_H_

#define UP_SIGS 0
#define UP_APP 1

int unzip(const char *output);
bool unzip(const char *output);

#endif
36 changes: 12 additions & 24 deletions source/download.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,23 @@
#define API_AGENT "ITotalJustice"
#define _1MiB 0x100000

typedef struct
{
typedef struct {
char *memory;
size_t size;
} MemoryStruct_t;

typedef struct
{
typedef struct {
u_int8_t *data;
size_t data_size;
u_int64_t offset;
FILE *out;
} ntwrk_struct_t;

static size_t WriteMemoryCallback(void *contents, size_t size, size_t num_files, void *userp)
{
static size_t WriteMemoryCallback(void *contents, size_t size, size_t num_files, void *userp) {
ntwrk_struct_t *data_struct = (ntwrk_struct_t *)userp;
const size_t realsize = size * num_files;

if (realsize + data_struct->offset >= data_struct->data_size)
{
if (realsize + data_struct->offset >= data_struct->data_size) {
fwrite(data_struct->data, data_struct->offset, 1, data_struct->out);
data_struct->offset = 0;
}
Expand All @@ -44,31 +40,26 @@ static size_t WriteMemoryCallback(void *contents, size_t size, size_t num_files,
return realsize;
}

static int download_progress(void *p, double dltotal, double dlnow, double ultotal, double ulnow)
{
static int download_progress(void *p, double dltotal, double dlnow, double ultotal, double ulnow) {
if (dltotal <= 0.0) return 0;

struct timeval tv = {0};
gettimeofday(&tv, NULL);
const int counter = round(tv.tv_usec / 100000);

if (counter == 0 || counter == 2 || counter == 4 || counter == 6 || counter == 8)
{
if (counter == 0 || counter == 2 || counter == 4 || counter == 6 || counter == 8) {
printf("* DOWNLOADING: %.2fMB of %.2fMB *\r", dlnow / _1MiB, dltotal / _1MiB);
consoleUpdate(NULL);
}

return 0;
}

bool downloadFile(const char *url, const char *output, int api)
{
bool downloadFile(const char *url, const char *output, int api) {
CURL *curl = curl_easy_init();
if (curl)
{
if (curl) {
FILE *fp = fopen(output, "wb");
if (fp)
{
if (fp) {
printf("\n");

ntwrk_struct_t chunk = {0};
Expand All @@ -86,8 +77,7 @@ bool downloadFile(const char *url, const char *output, int api)
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &chunk);

if (api == OFF)
{
if (api == OFF) {
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L);
curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, download_progress);
}
Expand All @@ -96,8 +86,7 @@ bool downloadFile(const char *url, const char *output, int api)
CURLcode res = curl_easy_perform(curl);

// write from mem to file
if (chunk.offset)
{
if (chunk.offset) {
fwrite(chunk.data, 1, chunk.offset, fp);
}

Expand All @@ -106,8 +95,7 @@ bool downloadFile(const char *url, const char *output, int api)
free(chunk.data);
fclose(chunk.out);

if (res == CURLE_OK)
{
if (res == CURLE_OK) {
printf("\n\ndownload complete!\n\n");
consoleUpdate(NULL);
return true;
Expand Down
Loading

0 comments on commit 6cf118c

Please sign in to comment.