Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/ci.macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: CI macOS

on:
workflow_run:
workflows: ["CI"]
types:
- completed

concurrency:
group: macos-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
runs-on: macos-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:

- name: Checkout
uses: actions/checkout@v3

- name: Install dependencies
run: brew install curl

- name: Build macOS
run: make -f Makefile.macos

- name: Upload macOS
uses: actions/upload-artifact@v4
with:
name: macOS-arm64
path: ./fetchpkg
if-no-files-found: error
31 changes: 31 additions & 0 deletions Makefile.macos
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright (C) 2024 John Törnblom
#
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; see the file COPYING. If not see
# <http://www.gnu.org/licenses/>.

BREW_PREFIX := $(shell brew --prefix)
CURL_PREFIX := $(BREW_PREFIX)/opt/curl

CFLAGS := -O2 -Wall -Werror -I$(CURL_PREFIX)/include
LDFLAGS := -L$(CURL_PREFIX)/lib
LDADD := -lcurl

ELF := fetchpkg
all: $(ELF)

$(ELF): main.c dl.c parson.c sha256.c sha1.c
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDADD)

clean:
rm -f $(ELF)
6 changes: 3 additions & 3 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ along with this program; see the file COPYING. If not, see
*
**/
static const char*
basename(const char *path) {
pkg_basename(const char *path) {
const char* ptr = path;

while(path && *path) {
Expand Down Expand Up @@ -139,14 +139,14 @@ int main(int argc, char *argv[]) {
}

if(!output[0]) {
strcpy(output, basename(url));
strcpy(output, pkg_basename(url));
if(endswith(output, ".json")) {
output[strlen(output)-5] = 0;
strcat(output, ".pkg");
}
}

if(dl_package(url, output, on_progress, (void*)basename(output))) {
if(dl_package(url, output, on_progress, (void*)pkg_basename(output))) {
return -1;
}

Expand Down