From 4b5fd855cc253823f54f5df753a509362ce703f2 Mon Sep 17 00:00:00 2001 From: Arsen Musayelyan Date: Sun, 29 Jan 2023 18:07:37 -0800 Subject: [PATCH] Check ~archive parameter for file downloader --- docs/packages/build-scripts.md | 4 ++-- internal/dl/file.go | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/packages/build-scripts.md b/docs/packages/build-scripts.md index 3fb0d3c..856c2cf 100644 --- a/docs/packages/build-scripts.md +++ b/docs/packages/build-scripts.md @@ -168,7 +168,7 @@ The `replaces` array contains the packages that are replaced by this package. Ge The `sources` array contains URLs which are downloaded into `$srcdir` before the build starts. -If the URL provided is an archive or compressed file, it will be extracted. To disable this, add the `~postproc=false` (`postproc` stands for postprocessing) query parameter. Example: +If the URL provided is an archive or compressed file, it will be extracted. To disable this, add the `~archive=false` query parameter. Example: Extracted: ```text @@ -177,7 +177,7 @@ https://example.com/archive.tar.gz Not extracted: ```text -https://example.com/archive.tar.gz?~postproc=false +https://example.com/archive.tar.gz?~archive=false ``` If the URL scheme starts with `git+`, the source will be downloaded as a git repo. The git download mode supports multiple parameters: diff --git a/internal/dl/file.go b/internal/dl/file.go index 746af6a..97d4bb9 100644 --- a/internal/dl/file.go +++ b/internal/dl/file.go @@ -46,6 +46,9 @@ func (FileDownloader) Download(opts Options) (Type, string, error) { name := query.Get("~name") query.Del("~name") + archive := query.Get("~archive") + query.Del("~archive") + u.RawQuery = query.Encode() res, err := http.Get(u.String()) @@ -57,6 +60,8 @@ func (FileDownloader) Download(opts Options) (Type, string, error) { name = getFilename(res) } + opts.PostprocDisabled = archive == "false" + path := filepath.Join(opts.Destination, name) fl, err := os.Create(path) if err != nil {