forked from RPi-Distro/pi-gen
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from learningequality/download
Change the way deb files are downloaded
- Loading branch information
Showing
1 changed file
with
14 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,23 @@ | ||
.PHONY: get-deb clean-deb | ||
|
||
DIST_DIR := dist | ||
|
||
|
||
clean-deb: | ||
rm -rf dist | ||
mkdir dist | ||
rm -rf $(DIST_DIR) | ||
mkdir $(DIST_DIR) | ||
|
||
get-deb: clean-deb | ||
# The eval and shell commands here are evaluated when the recipe is parsed, so we put the cleanup | ||
# into a prerequisite make step, in order to ensure they happen prior to the download. | ||
$(eval DLFILE = $(shell wget --content-disposition -P deb/ "${deb}" 2>&1 | grep "Saving to: " | sed 's/Saving to: ‘//' | sed 's/’//')) | ||
$(eval DLFILE = $(shell wget --content-disposition -P $(DIST_DIR)/ "${deb}" 2>&1 | grep "Saving to: " | sed 's/Saving to: ‘//' | sed 's/’//')) | ||
$(eval DLFILE := $(if $(DLFILE),$(DLFILE),$(notdir $(deb)))) | ||
|
||
$(eval DEBFILE = $(shell echo "${DLFILE}" | sed "s/\?.*//")) | ||
[ "${DLFILE}" = "${DEBFILE}" ] || mv "${DLFILE}" "${DEBFILE}" | ||
|
||
# GH artifacts are zipped, so we need to extract them | ||
@if [ "$(shell echo $(DLFILE) | rev | cut -d'.' -f1 | rev)" = "zip" ]; then \ | ||
unzip -d $(DIST_DIR)/ $(DIST_DIR)/$(DLFILE); \ | ||
rm $(DIST_DIR)/$(DLFILE); \ | ||
fi |