Handmade Hero»Forums»Code
David Owens II
69 posts
A software engineer that enjoys living in enemy territory.
Easy Downloads for Mac/Linux (updated script)
Edited by David Owens II on Reason: Fixed the script so it works on both Mac and Linux now thatnks to help from mmozeiko.
I wrote an Automator workflow and bash script to download the source code and unpack it all. If you're interested, you can find more info about it here: http://owensd.io/2015/01/12/keepi...p-to-date-with-handmade-hero.html, or you can go straight to the source here: https://github.com/owensd/handmade/tree/master/ref.

This only works for the Mac as I didn't spend the time to figure out the redirect headers that Sendowl and AWS needs, so I have a workflow handle the downloading of the zip files.

Also note, you'll need to create a url.secret file, as mentioned in the blog post, to put the link you received in your signup mail.
Kyle Partridge
1 posts
Easy Downloads for Mac/Linux (updated script)
I've been able to just `wget` from the download button link. Does that link change?


1
wget <download_link> -O handmade.zip
David Owens II
69 posts
A software engineer that enjoys living in enemy territory.
Easy Downloads for Mac/Linux (updated script)
I didn't try wget as it's not installed by default on OS X. I'll give it a try later. I don't think that URL changes though.
Mārtiņš Možeiko
2559 posts / 2 projects
Easy Downloads for Mac/Linux (updated script)
Try curl, AFAIK it is available on OSX by default:
1
curl -o handmade.zip <download_link>
David Owens II
69 posts
A software engineer that enjoys living in enemy territory.
Easy Downloads for Mac/Linux (updated script)
As mentioned in the blog entry, curl doesn't handle the redirect's correctly. At least, it wasn't for me.
Mārtiņš Možeiko
2559 posts / 2 projects
Easy Downloads for Mac/Linux (updated script)
Oh, sorry I missed that. But blog entry doesn't explain what is wrong with redirects.
Have you tried using -L option? Just now tried, and it works for me (although on Windows, not OSX):
1
curl -L -o handmade.zip <url>
David Owens II
69 posts
A software engineer that enjoys living in enemy territory.
Easy Downloads for Mac/Linux (updated script)
AH! That's what I was missing. Yes, the -L flag worked. I've updated the blog entry and my script:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
rm -rf ./src >/dev/null 2>&1

DOWNLOAD_ASSETS=YES
if [ "$1" == "-noassets" ]; then
    DOWNLOAD_ASSETS=NO
fi

if [ "$DOWNLOAD_ASSETS" == "YES" ]; then
    rm -rf ./assets >/dev/null 2>&1
fi

mkdir -p tmp
mkdir -p src
mkdir -p assets

source ./etc/url.secret

# Download the webpage and get the links for the downloads
echo "Downloading source files..."
curl -L -# "$PRODUCTS_URL" -o ./tmp/source.zip

if [ $? != 0 ]; then
    echo "Unable to download source files."
    exit 1
fi

if [ "$DOWNLOAD_ASSETS" == "YES" ]; then
    echo "Downloading asset files..."
    curl -L -# "$ASSETS_URL" -o ./tmp/assets.zip

    if [ $? != 0 ]; then
        echo "Unable to download asset files."
        exit 1
    fi

    unzip -n ./tmp/assets.zip -d assets/  >/dev/null 2>&1
fi

unzip ./tmp/*source.zip -d tmp/  >/dev/null 2>&1

for FILE in ./tmp/*_day_*.zip; do
    NAME="${FILE/.\/tmp\/handmade_hero_/}"
    NAME="${NAME/_source.zip/}"
    
    unzip "$FILE" -d ./src/$NAME/ >/dev/null 2>&1
done

rm -rf ./tmp >/dev/null 2>&1