From 9149182599270053571d9a88c870e9c3c8c17719 Mon Sep 17 00:00:00 2001 From: Mattt Zmuda Date: Fri, 25 Aug 2023 05:00:57 -0700 Subject: [PATCH 1/4] Add install and uninstall targets to Makefile Adopt Makefile conventions of Cog and CLI --- Makefile | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index c117952..3cf4b29 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,36 @@ -all: - CGO_ENABLED=0 go build -ldflags '-extldflags "-static"' -o pget +SHELL := /bin/bash +DESTDIR ?= +PREFIX = /usr/local +BINDIR = $(PREFIX)/bin + +INSTALL := install -m 0755 +INSTALL_PROGRAM := $(INSTALL) + +GO := go +GOOS := $(shell $(GO) env GOOS) +GOARCH := $(shell $(GO) env GOARCH) + +default: all + +.PHONY: all +all: pget + +pget: + CGO_ENABLED=0 $(GO) build -o $@ \ + -ldflags '-extldflags "-static"' \ + main.go + +.PHONY: install +install: pget + $(INSTALL_PROGRAM) -d $(DESTDIR)$(BINDIR) + $(INSTALL_PROGRAM) pget $(DESTDIR)$(BINDIR)/pget + +.PHONY: uninstall +uninstall: + rm -f $(DESTDIR)$(BINDIR)/pget + +.PHONY: clean clean: - rm ./pget + $(GO) clean + rm -f replicate From 5d849238455d0b5938f23d5dd5fb88f5fb3bc584 Mon Sep 17 00:00:00 2001 From: Mattt Zmuda Date: Fri, 25 Aug 2023 05:04:30 -0700 Subject: [PATCH 2/4] Use make in CI workflow --- .github/workflows/ci.yaml | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d41df3a..aae701f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -5,7 +5,7 @@ on: branches: - main tags: - - '*' + - "*" pull_request: workflow_dispatch: @@ -22,13 +22,12 @@ jobs: name: Build runs-on: ubuntu-latest-8-cores steps: - - uses: actions/checkout@v3 - - uses: actions/setup-go@v4 - with: - go-version-file: go.mod - - run: script/build - - uses: ncipollo/release-action@v1 - if: ${{ startsWith(github.ref, 'refs/tags') }} - with: - artifacts: "pget" - + - uses: actions/checkout@v3 + - uses: actions/setup-go@v4 + with: + go-version-file: go.mod + - run: make + - uses: ncipollo/release-action@v1 + if: ${{ startsWith(github.ref, 'refs/tags') }} + with: + artifacts: "pget" From c3b05574b094908935f7c8fde9ee0eb9323579d4 Mon Sep 17 00:00:00 2001 From: Mattt Zmuda Date: Fri, 25 Aug 2023 05:04:55 -0700 Subject: [PATCH 3/4] Remove build script in favor of Makefile --- script/build | 2 -- 1 file changed, 2 deletions(-) delete mode 100755 script/build diff --git a/script/build b/script/build deleted file mode 100755 index d3ab6bd..0000000 --- a/script/build +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -CGO_ENABLED=0 go build -ldflags '-extldflags "-static"' -o pget From 6095df3ef35590f65c762a724e3bfff8a589b0e9 Mon Sep 17 00:00:00 2001 From: Mattt Zmuda Date: Fri, 25 Aug 2023 05:09:57 -0700 Subject: [PATCH 4/4] Add installation instructions to README --- README.md | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index a0c1d8e..51e907a 100644 --- a/README.md +++ b/README.md @@ -8,13 +8,31 @@ If the downloaded file is a tar archive, PGet can automatically extract the cont The efficiency of PGet's tar extraction lies in its approach to handling data. Instead of writing the downloaded tar file to disk and then reading it back into memory for extraction, PGet conducts the extraction directly from the in-memory download buffer. This method avoids unnecessary memory copies and disk I/O, leading to an increase in performance, especially when dealing with large tar files. This makes PGet not just a parallel downloader, but also an efficient file extractor, providing a streamlined solution for fetching and unpacking files. +## Install -## Usage +If you're using macOS, you can install PGet with Homebrew: + +```console +brew tap replicate/tap +brew install pget +``` + +Or you can build from source and install it with these commands +(requires Go 1.19 or later): + +```console +make +sudo make install +``` +This builds a static binary that can work inside containers. + +## Usage pget [-c concurrency] [-x] Parameters + - \: The URL of the file to download. - \: The destination where the downloaded file will be stored. - -c concurrency: The number of concurrent downloads. Default is 4 times the number of cores. @@ -33,20 +51,8 @@ PGet includes some error handling: 1. If a download any chunks fails, it will automatically retry up to 5 times before giving up. 2. If the downloaded file size does not match the expected size, it will also retry the download. -## Dependencies - -PGet is built in Go and has no external dependencies beyond the Go standard library. - -## Building - -To build PGet, you need a working Go environment. You can build the binary with the following - - make - -This builds a static binary that can work inside containers. - ## Future Improvements - as chunks are downloaded, start either writing to disk or extracting - can we check the content hash of the file in the background? -- support for zip files? \ No newline at end of file +- support for zip files?