Skip to content

Commit 1789e3f

Browse files
cculianuftrader
authored andcommitted
[build] Allow gitian-build.py to run on macOS
Co-authored-by: Andrew#128 <andrew-128-github@protonmail.com> Summary ------- As a follow-up to !1248, it turns out with some minor modifications, it's possible to build using gitian on Docker for macOS! This may save time for people that run macOS natively (such as me). In short: This MR allows the `--docker` options to work on macOS without failing. In a future MR I will also compose some documentation about how to get it working on macOS 100%. For now it also needs you to use a fork of gitian-builder from here: https://github.com/cculianu/gitian-builder.git BRANCH: macos_support_no_debian_cache There is a PR for this change that I submitted to the main gitian-builder repo: devrandom/gitian-builder#252 Test Plan --------- - Run gitian builder on Linux as normal to ensure that nothing broke. **Optional:** - If you are on a **macOS** host, get docker installed and running, check-out this branch, and also check-out: https://github.com/cculianu/gitian-builder.git branch: `macos_support_no_debian_cache` into your `gitian-builder` directory. - Put the modified script from this MR on the top-level, next to your `bitcoin-cash-node` directory. - Run: `./gitian-build.py --setup --docker` - Run: `./gitian-build.py --docker -b -D -n -c -o lwm "satoshi" master` - After a great deal of time waiting for it to rebuild the universe, you should have some static binaries built!
1 parent f4c6d7c commit 1789e3f

3 files changed

Lines changed: 44 additions & 29 deletions

File tree

contrib/gitian-build.py

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,34 @@
1515
BOLD = ('\033[0m', '\033[1m')
1616
RED = ('\033[0m', '\033[0;31m')
1717

18+
is_mac = sys.platform == 'darwin'
19+
1820

1921
def setup():
2022
global args, workdir
21-
programs = ['ruby', 'git', 'apt-cacher-ng', 'make', 'wget']
22-
if args.kvm:
23-
programs += ['python-vm-builder', 'qemu-kvm', 'qemu-utils']
24-
elif args.docker:
25-
dockers = ['docker.io', 'docker-ce']
26-
for i in dockers:
27-
return_code = subprocess.call(
28-
['sudo', 'apt-get', 'install', '-qq', i])
29-
if return_code == 0:
30-
break
31-
if return_code != 0:
32-
print('Cannot find any way to install docker', file=sys.stderr)
33-
exit(1)
23+
if not is_mac:
24+
programs = ['ruby', 'git', 'apt-cacher-ng', 'make', 'wget']
25+
if args.kvm:
26+
programs += ['python-vm-builder', 'qemu-kvm', 'qemu-utils']
27+
elif args.docker:
28+
dockers = ['docker.io', 'docker-ce']
29+
for i in dockers:
30+
return_code = subprocess.call(
31+
['sudo', 'apt-get', 'install', '-qq', i])
32+
if return_code == 0:
33+
break
34+
if return_code != 0:
35+
print('Cannot find any way to install docker', file=sys.stderr)
36+
exit(1)
37+
else:
38+
programs += ['lxc', 'debootstrap']
39+
subprocess.check_call(['sudo', 'apt-get', 'install', '-qq'] + programs)
3440
else:
35-
programs += ['lxc', 'debootstrap']
36-
subprocess.check_call(['sudo', 'apt-get', 'install', '-qq'] + programs)
41+
if args.docker:
42+
print("Warning: macOS support is experimental and requires docker be already installed", file=sys.stderr)
43+
else:
44+
sys.exit("macOS support only works in --docker mode")
45+
3746
if not os.path.isdir('gitian-builder'):
3847
subprocess.check_call(
3948
['git', 'clone', 'https://github.com/devrandom/gitian-builder.git'])
@@ -240,7 +249,7 @@ def main():
240249
args = parser.parse_args()
241250
workdir = os.getcwd()
242251

243-
args.is_bionic = b'bionic' in subprocess.check_output(
252+
args.is_bionic = not is_mac and b'bionic' in subprocess.check_output(
244253
['lsb_release', '-cs'])
245254

246255
if args.kvm and args.docker:

doc/gitian-building.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ More independent Gitian builders are needed, which is why this guide exists.
1717
It is preferred you follow these steps yourself instead of using someone else's
1818
VM image to avoid 'contaminating' the build.
1919

20-
If you are running Debian or Ubuntu, see
21-
[Running Gitian with Docker on Ubuntu/Debian](./gitian-building/gitian-building-docker.md)
22-
for a relitively straightforward setup and build process.
20+
If you are running Debian, Ubuntu or Mac, see
21+
[Running Gitian with Docker](./gitian-building/gitian-building-docker.md)
22+
for a relatively straightforward setup and build process.
2323

2424
The instructions below use the automated script [gitian-build.py](../contrib/gitian-build.py)
2525
which only works in Debian/Ubuntu. For manual steps and instructions for fully

doc/gitian-building/gitian-building-docker.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,34 @@
1-
# Running Gitian with Docker on Ubuntu/Debian
2-
This is a streamlined guide for running Gitian builds with Docker on Ubuntu or
3-
Debian hardware. The following steps have been tested on Ubuntu 18.04.05.
4-
Similar, if not the same steps should work on other versions of Ubuntu and
5-
Debian.
1+
# Running Gitian with Docker
2+
This is a streamlined guide for running Gitian builds with Docker on Ubuntu,
3+
Debian or Mac hardware.
64

75
# Setup
86
Ensure you have Docker installed. See https://docs.docker.com/get-docker/ for
97
installation instructions.
108

11-
Make sure to go through the Linux post-install walkthrough, especially the
9+
If you're using Linux, make sure to go through the Linux post-install
10+
walkthrough, especially the
1211
[Manage Docker as a non-root user](https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user)
1312
section, to avoid having to use `sudo` all the time.
1413

15-
Prepare a workspace directory (e.g. `~/bchn-gitian`) and `cd` into it. You'll
14+
## Prepare a build workspace
15+
Create a workspace directory (e.g. `~/bchn-gitian`) and `cd` into it. You'll
1616
only need to run through this setup once so long as you retain the workspace.
1717

18-
```bash
19-
# Install dependencies
20-
sudo apt install curl git
18+
## Install dependencies
19+
You'll need `git` and `curl` installed. If on Linux, just do `sudo apt install
20+
curl git`.
2121

22+
## Gitian setup
23+
```bash
2224
# Fetch the `gitian-build.py` script
2325
git clone https://gitlab.com/bitcoin-cash-node/bitcoin-cash-node.git
2426
cp bitcoin-cash-node/contrib/gitian-build.py .
2527

28+
# If you are on a MacOS host, you will need the MacOS-capable fork
29+
# of gitian-builder, if on Linux, you can skip this step.
30+
git clone -b macos_support_no_debian_cache https://github.com/cculianu/gitian-builder.git
31+
2632
# Run the initial Gitian setup
2733
./gitian-build.py --docker --setup
2834

0 commit comments

Comments
 (0)