ipfs.mk 1.92 KB
Newer Older
1 2 3 4 5
# This file contains quick phony targets to build IPFS packages

ARCH ?= amd64
OS ?= linux

6 7 8
ifeq ($(ARCH),arm)
	DEB_ARCH := armhf
endif
9
DEB_ARCH ?= $(ARCH)
10

Lorenzo Setale's avatar
Lorenzo Setale committed
11
IPFS_VERSION?=$(shell curl --silent "https://api.github.com/repos/ipfs/go-ipfs/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
Lorenzo Setale's avatar
Lorenzo Setale committed
12
IPFS_PKG_VERSION:=$(shell echo ${IPFS_VERSION} | sed 's/v//')-0
13

14
_download_ipfs:
15 16
	mkdir -p build/orig/
	curl -L --output build/orig/ipfs-${IPFS_VERSION}-${ARCH}.tar.gz \
Lorenzo Setale's avatar
Lorenzo Setale committed
17
		https://github.com/ipfs/go-ipfs/releases/download/${IPFS_VERSION}/go-ipfs_${IPFS_VERSION}_${OS}-${ARCH}.tar.gz
18
.PHONY: _download_ipfs
19

20
_unpack_ipfs: _download_ipfs
21 22 23
	rm -rf build/source/go-ipfs/${ARCH}
	mkdir -p build/source/go-ipfs/${ARCH}
	tar -xvzf build/orig/ipfs-${IPFS_VERSION}-${ARCH}.tar.gz -C build/source/go-ipfs/${ARCH}
24
.PHONY: _unpack_ipfs
25

26
_prepare_ipfs_deb: _unpack_ipfs
Lorenzo Setale's avatar
Lorenzo Setale committed
27 28 29
	mkdir -p build/deb/${DEB_ARCH}/ipfs-${IPFS_PKG_VERSION}
	cp -aR source/ipfs.deb/* build/deb/${DEB_ARCH}/ipfs-${IPFS_PKG_VERSION}/
	chmod +x build/deb/${DEB_ARCH}/ipfs-${IPFS_PKG_VERSION}/debian/rules
30 31 32 33 34 35
	# Updates details of the package
	sed -i 's/$${VERSION}/${IPFS_PKG_VERSION}/' build/deb/${DEB_ARCH}/ipfs-${IPFS_PKG_VERSION}/debian/control
	sed -i 's/$${DEB_ARCH}/${DEB_ARCH}/' build/deb/${DEB_ARCH}/ipfs-${IPFS_PKG_VERSION}/debian/control
	# Updates the pseudo-changelog
	sed -i 's/$${VERSION}/${IPFS_PKG_VERSION}/' build/deb/${DEB_ARCH}/ipfs-${IPFS_PKG_VERSION}/debian/changelog
	sed -i 's/$${DATE}/$(shell date -R)/' build/deb/${DEB_ARCH}/ipfs-${IPFS_PKG_VERSION}/debian/changelog
36
	# Move the source here
Lorenzo Setale's avatar
Lorenzo Setale committed
37
	cp -aR build/source/go-ipfs/${ARCH}/go-ipfs build/deb/${DEB_ARCH}/ipfs-${IPFS_PKG_VERSION}/
38
.PHONY: _prepare_ipfs_deb
39

40
_build_ipfs_deb_package: _prepare_ipfs_deb
Lorenzo Setale's avatar
Lorenzo Setale committed
41
	cd build/deb/${DEB_ARCH}/ipfs-${IPFS_PKG_VERSION} ;\
42
	dpkg-buildpackage -us -uc -d --host-arch ${DEB_ARCH}
43 44 45
.PHONY: ipfs_deb_package

deb_ipfs_%:
Lorenzo Setale's avatar
Lorenzo Setale committed
46 47 48
	$(MAKE) clean_build \
		_build_ipfs_deb_package \
		collect_deb_packages \
Lorenzo Setale's avatar
Lorenzo Setale committed
49
		-e ARCH=$*