| 140 | |
| 141 | |
| 142 | def build_release(tag, args) -> int: |
| 143 | githubUrl = "https://github.com/bitcoin/bitcoin" |
| 144 | if args.remove_dir: |
| 145 | if Path(tag).is_dir(): |
| 146 | shutil.rmtree(tag) |
| 147 | if not Path(tag).is_dir(): |
| 148 | # fetch new tags |
| 149 | subprocess.run( |
| 150 | ["git", "fetch", githubUrl, "--tags"]) |
| 151 | output = subprocess.check_output(['git', 'tag', '-l', tag]) |
| 152 | if not output: |
| 153 | print('Tag {} not found'.format(tag)) |
| 154 | return 1 |
| 155 | ret = subprocess.run([ |
| 156 | 'git', 'clone', githubUrl, tag |
| 157 | ]).returncode |
| 158 | if ret: |
| 159 | return ret |
| 160 | with pushd(tag): |
| 161 | ret = subprocess.run(['git', 'checkout', tag]).returncode |
| 162 | if ret: |
| 163 | return ret |
| 164 | host = args.host |
| 165 | if args.depends: |
| 166 | with pushd('depends'): |
| 167 | ret = subprocess.run(['make', 'NO_QT=1']).returncode |
| 168 | if ret: |
| 169 | return ret |
| 170 | host = os.environ.get( |
| 171 | 'HOST', subprocess.check_output(['./config.guess'])) |
| 172 | config_flags = '--prefix={pwd}/depends/{host} '.format( |
| 173 | pwd=os.getcwd(), |
| 174 | host=host) + args.config_flags |
| 175 | cmds = [ |
| 176 | './autogen.sh', |
| 177 | './configure {}'.format(config_flags), |
| 178 | 'make', |
| 179 | ] |
| 180 | for cmd in cmds: |
| 181 | ret = subprocess.run(cmd.split()).returncode |
| 182 | if ret: |
| 183 | return ret |
| 184 | # Move binaries, so they're in the same place as in the |
| 185 | # release download |
| 186 | Path('bin').mkdir(exist_ok=True) |
| 187 | files = ['bitcoind', 'bitcoin-cli', 'bitcoin-tx'] |
| 188 | for f in files: |
| 189 | Path('src/'+f).rename('bin/'+f) |
| 190 | return 0 |
| 191 | |
| 192 | |
| 193 | def check_host(args) -> int: |