Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build the binaries on our own #15

Merged
merged 37 commits into from
Jan 13, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
3d039d8
Move docs around
dignifiedquire Dec 11, 2015
44ab3fd
Add travis
dignifiedquire Dec 11, 2015
54054d0
Add circle config
dignifiedquire Dec 11, 2015
74496ba
Refactor go-ipfs build of dist.json
dignifiedquire Dec 11, 2015
f2f7e97
Add dependencies
dignifiedquire Dec 11, 2015
84c32f3
Revert some things
dignifiedquire Dec 17, 2015
55b1844
Handle copying of dist files and update site
dignifiedquire Dec 18, 2015
2ddcdc9
Links and dist.json cleanup for go-ipfs
dignifiedquire Dec 18, 2015
72acba8
Add preleminary links for docs, changelog and all versions
dignifiedquire Dec 18, 2015
c356c46
build the binaries on our own
whyrusleeping Dec 9, 2015
4052254
better color printing maybe
whyrusleeping Dec 19, 2015
f599fdf
generate dist.json files
whyrusleeping Dec 20, 2015
f6e1358
chore: Upgrade dependencies
dignifiedquire Jan 5, 2016
196688e
feat: Implement gulp build
dignifiedquire Jan 5, 2016
836d6c3
a bit more generalized
whyrusleeping Jan 6, 2016
3bdd8f0
working towards zipping
whyrusleeping Jan 6, 2016
2a85a36
better git cleanups
whyrusleeping Jan 7, 2016
afdd7ed
cleaner folder structure
whyrusleeping Jan 7, 2016
3b6c402
more generalized build script, and dist dir copying
whyrusleeping Jan 8, 2016
07052fd
fix zip output
whyrusleeping Jan 8, 2016
a295ba2
add ipfs-update to dists
whyrusleeping Jan 8, 2016
2b3b5b5
add in fs-repo-migrations
whyrusleeping Jan 8, 2016
05054ce
better git commands and cleanup makefile
whyrusleeping Jan 8, 2016
27f7e00
factor out a few things, and have a more specific directory check
whyrusleeping Jan 9, 2016
30076b1
Merge branch 'feat/fresh2' into build-ourselves
dignifiedquire Jan 9, 2016
faebb8d
better filtering command that works on inferior operating systems
whyrusleeping Jan 9, 2016
aa8d8eb
cleanup and add descriptions
whyrusleeping Jan 10, 2016
168989e
bash cleanup
whyrusleeping Jan 10, 2016
8cb7d6f
Fix site for new dist.json format and add navigation
dignifiedquire Jan 10, 2016
ba5e4aa
Add footer
dignifiedquire Jan 10, 2016
a7c59a9
Make usable on mobile
dignifiedquire Jan 10, 2016
e321ea2
some more cleanup
whyrusleeping Jan 11, 2016
77af6da
Copy improvements Part 1
dignifiedquire Jan 11, 2016
64bb28d
site: Copy site into releases folder
dignifiedquire Jan 11, 2016
c4b71b7
proper dist naming and add zip to links
whyrusleeping Jan 12, 2016
c8ccbd2
Fix absolute paths
dignifiedquire Jan 12, 2016
b8dd155
add current version files
whyrusleeping Jan 12, 2016
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
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["es2015"]
}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ logs
**/node_modules
releases
dists/ipfs-app/build
www
**/gopath
**/tmp-build
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
language: node_js
node_js:
- '4'
- '5'
- stable

script:
- npm run lint
24 changes: 11 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
all: all_dists index
all: all_dists site

all_dists: go-ipfs
all_dists: go-ipfs ipfs-update fs-repo-migrations

ipfs-app:
echo "** making $@ **"
%:
echo "** $@ **"
cd dists/$@ && make

go-ipfs:
echo "** making $@ **"
cd dists/$@ && make

index:
echo "** making index.html **"
node gen-index.js >releases/index.html
cp -r static releases/.
site:
echo "** Building site **"
npm run build

publish: all_dists index
publish: all_dists site
ipfs add -s rabin -q -r releases | tail -n1 >>versions

clean:
rm -rf releases
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# IPFS distributions

[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io) [![](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io/) [![](https://img.shields.io/badge/freejs-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs)
[![Dependency Status](https://david-dm.org/ipfs/distributions.svg?style=flat-square)](https://david-dm.org/ipfs/distributions)
[![Travis CI](https://travis-ci.org/ipfs/distributions.svg?branch=master)](https://travis-ci.org/ipfs/distributions)
[![Circle CI](https://circleci.com/gh/ipfs/distributions.svg?style=svg)](https://circleci.com/gh/ipfs/distributions)

> Source for building https://dist.ipfs.io

## How this repo works
Expand Down
206 changes: 206 additions & 0 deletions build-go.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
#!/bin/bash
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this shell file is intense. did you lift it or make it from scratch?

cc @chriscool for some quick review?

(no need for sh, I'm ok to keep bash to save time here. all of the people releasing go-ipfs have bash installed.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wrote this all, lol.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I just commented on a few things that can be applied in many places.


# globals
releases=../../releases

# init colors
txtnon='\e[0m' # color reset
txtred='\e[0;31m' # Red
txtgrn='\e[0;32m' # Green
txtylw='\e[0;33m' # Yellow

function fail() {
printf $txtred%s$txtnon\\n "$@"
exit 1
}

function warn() {
printf $txtylw%s$txtnon\\n "$@"
}

function notice() {
printf $txtgrn%s$txtnon\\n "$@"
}

# dep checks
reqbins="jq zip go"
for b in $reqbins
do
if ! type $b > /dev/null; then
fail "must have '$b' installed"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Install with a makefile and gx (or ipget)? (we can leave this for a future PR)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah... jq i normally install with npm, zip with my package manager, and go from source. It would be nice to just be able to download them in the script if needed, but this is really just code that we're going to use internally (at least for now)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to have a note about how to install them in the readme. (No idea where and what jq is)

fi
done

function printDistInfo() {
# print json output
jq -e ".platforms[\"$goos\"]" dist.json > /dev/null
if [ ! $? -eq 0 ]; then
cp dist.json dist.json.temp
jq ".platforms[\"$goos\"] = {\"name\":\"$goos Binary\",\"archs\":{}}" dist.json.temp > dist.json
fi

local binname="$1"
cp dist.json dist.json.temp
jq ".platforms[\"$goos\"].archs[\"$goarch\"] = {\"link\":\"$goos-$goarch/$binname.zip\"}" dist.json.temp > dist.json
rm dist.json.temp
}

function doBuild() {
local goos=$1
local goarch=$2
local target=$3
local output=$4

echo "==> building for $goos $goarch"

dir=$output/$1-$2
if [ -e $dir ]; then
echo " $dir exists, skipping build"
return
fi
echo " output to $dir"

mkdir -p tmp-build

(cd tmp-build && GOOS=$goos GOARCH=$goarch go build $target 2> build-log)
if [ $? -ne 0 ]; then
warn " failed."
return 1
fi

notice " build succeeded!"

# copy dist assets if they exist
if [ -e $GOPATH/src/$target/dist ]; then
cp -r $GOPATH/src/$target/dist/* tmp-build/
fi

# now zip it all up
local binname=$(basename $target)
mkdir -p $dir
if zip -r $dir/$binname.zip tmp-build/* > /dev/null; then
printDistInfo $binname
rm -rf tmp-build
else
warn " failed to zip up output"
success=1
fi


# output results to results table
echo $target, $goos, $goarch, $success >> $output/results
}

function printInitialDistfile() {
local distname=$1
local version=$2
test -e description || fail "no description file found"

printf "{\"id\":\"$distname\",\"version\":\"$version\",\"releaseLink\":\"/$distname/$version\"}" |
jq ".name = \"$disname\"" |
jq ".platforms = {}" |
jq ".description = \"`cat description`\""
}

function printBuildInfo() {
# print out build information
local commit=$1
go version
echo "git sha of code: $commit"
uname -a
echo built on `date`
}

function buildWithMatrix() {
local matfile=$1
local gobin=$2
local output=$3
local commit=$4

test -n "$output" || fail "error: output dir not specified"
test -e "$matfile" || fail "build matrix $matfile does not exist"

mkdir -p "$output"

local distname=$(basename `pwd`)

printInitialDistfile $distname $version > dist.json
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah ok makes sense 👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah... its kindof a weird hack because doing cat X | something > X will leave you with no data.

printBuildInfo $commit > $output/build-info

# build each os/arch combo
while read line
do
doBuild $line $gobin $output
done < $matfile

mv dist.json $output/dist.json
}

function cleanRepo() {
local repopath=$1

reporoot=$(cd "$repopath" && git rev-parse --show-toplevel)
(cd "$reporoot" && git clean -df)
(cd "$reporoot" && git reset --hard)
}

function checkoutVersion() {
local repopath=$1
local ref=$2

test -n "$repopath" || fail "checkoutVersion: no repo to check out specified"

echo "==> checking out version $ref in $repopath"
cleanRepo "$repopath"
(cd "$repopath" && git checkout $ref > /dev/null)

test $? -eq 0 || fail "failed to check out $ref in $reporoot"
}

function currentSha() {
(cd $1 && git show --pretty="%H")
}

function printVersions() {
versarr=$(tr \n ' ' < versions)
echo "building versions: $versarr"
}

function startGoBuilds() {
distname=$1
gpath=$2

outputDir="$releases/$distname"

# if the output directory already exists, warn user
if [ -e $outputDir ]; then
warn "dirty output directory"
warn "will skip building already existing binaries"
fi

export GOPATH=$(pwd)/gopath
if [ ! -e $GOPATH/src/$gpath ]; then
echo "fetching $distname code..."
go get $gpath 2> /dev/null
fi

repopath="$GOPATH/src/$gpath"

(cd "$repopath" && git reset --hard && git clean -df)

printVersions

echo ""
while read version
do
notice "Building version $version binaries"
checkoutVersion $repopath $version

buildWithMatrix matrices/$version $gpath $outputDir/$version $(currentSha $repopath)
echo ""
done < versions

notice "build complete!"
}

startGoBuilds $1 $2
7 changes: 7 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
machine:
node:
version: stable

test:
override:
- npm run lint
22 changes: 22 additions & 0 deletions dists/fs-repo-migrations/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
repo=http://github.com/ipfs/fs-repo-migrations
releases=../../releases/fs-repo-migrations

all: dist

dist: versions
mkdir -p $(releases)
cp versions $(releases)/versions
../../build-go.sh fs-repo-migrations github.com/ipfs/fs-repo-migrations

versions: filtered_versions
git ls-remote -t $(repo) | egrep -o "refs/tags/v(.*)" | sed 's/refs\/tags\///' | sort > tag_versions
comm -23 -- tag_versions filtered_versions > versions

filtered_versions:
touch filtered_versions

clean:
rm -rf ./gopath
rm -rf $(releases)
rm versions tag_versions

1 change: 1 addition & 0 deletions dists/fs-repo-migrations/current
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v1.0.0
1 change: 1 addition & 0 deletions dists/fs-repo-migrations/description
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fs-repo-migrations is a tool to help migration ipfs storage repos to newer versions
10 changes: 10 additions & 0 deletions dists/fs-repo-migrations/matrices/v1.0.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
darwin 386
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need these? As far as I know 32 bit is not used on any current OS X system that is able to run these binaries (and pretty much nobody, not even go-lang or node.js, gives you 32 bit binaries for OS X)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This applies for ipfs and other binaries as well

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, okay. I just picked a few that seemed reasonable, i'll remove it. But all of these binaries are supported by the go compiler. Which do you think should be kept?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hold on, i think we do need darwin 386. I remember running into problems in pre-Yosemite with the mac mini and having to recompile as 386.

If the go team has it there still, it's there for a reason. Let's keep it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(to be clear, i understand that osx has been supposed to run only on amd64 for years now, but have seen this specific problem. Until golang disallows darwin 386 as a target, I think we should continue to have it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(there is also the possibility of suppressing it from the distributions page, if we think "almost all users wont need it and it will be confusing". i twill still be available in the version file listing itself)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mmkay, i left it in.

darwin amd64
freebsd 386
freebsd amd64
freebsd arm
linux 386
linux amd64
linux arm
windows 386
windows amd64
1 change: 1 addition & 0 deletions dists/fs-repo-migrations/versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v1.0.0
1 change: 1 addition & 0 deletions dists/go-ipfs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
gopath/*
28 changes: 6 additions & 22 deletions dists/go-ipfs/Makefile
Original file line number Diff line number Diff line change
@@ -1,32 +1,16 @@
repo = http://github.com/ipfs/go-ipfs
gpath = github.com/ipfs/go-ipfs/cmd/ipfs
releases = ../../releases/go-ipfs
gbcli = $(shell which gobuilder-cli)

all: dist

dist: versions deps
dist: versions
mkdir -p $(releases)
cp versions $(releases)/versions
./go-ipfs-dist all
../../build-go.sh go-ipfs github.com/ipfs/go-ipfs/cmd/ipfs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pretty sweet! 👍 😄


versions: filtered_versions
git ls-remote -t $(repo) | egrep -o "refs/tags/v(.*)" | sed 's/refs\/tags\///' > tag_versions
cat tag_versions | grep -f filtered_versions -vE > versions
git ls-remote -t $(repo) | egrep -o "refs/tags/v(.*)" | sed 's/refs\/tags\///' | sort > tag_versions
comm -23 -- tag_versions filtered_versions > versions

deps: bin bin/gobuilder-cli go-ipfs-dist-x

bin:
@mkdir -p bin

go-ipfs-dist-x:
chmod +x go-ipfs-dist

bin/gobuilder-cli: bin
#TODO: make this not require a go compiler...
go get github.com/Luzifer/gobuilder/cmd/gobuilder-cli
cp $(gbcli) bin/gobuilder-cli

# bin/go-env:
# ipfs get -o bin/go-env QmfS4PZj7G7KgAztPN3JxXyY6KHJDZ77EaxzocWqsa3XhQ/go-env
# chmox +x bin/go-env
clean:
rm -rf $(releases)
1 change: 1 addition & 0 deletions dists/go-ipfs/current
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v0.3.11
1 change: 1 addition & 0 deletions dists/go-ipfs/description
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
go-ipfs is the main implementation of IPFS. It is the base distribution, and includes:\n- an IPFS core implementation\n- an IPFS daemon server\n- extensive command line tooling\n- an HTTP API for controlling the node\n- an HTTP Gateway for serving content to HTTP browsers\n
6 changes: 0 additions & 6 deletions dists/go-ipfs/dist.json

This file was deleted.

Loading