Commit adaf4f3c authored by Martijn Braam's avatar Martijn Braam Committed by Oliver Smith

Added build helper for

parent 0188930f
#!/bin/sh -e
# Copyright 2018 Oliver Smith
# SPDX-License-Identifier: GPL-3.0-or-later
# Config: pmbootstrap tag (or branch)
# Get download URL and pmaports path
pmaports="$(cd $(dirname $0)/..; pwd -P)"
# Set up binfmt_misc
echo "Setting-up binfmt_misc"
sudo mount -t binfmt_misc none /proc/sys/fs/binfmt_misc
# Download pmbootstrap (to /tmp/pmbootstrap)
echo "Downloading pmbootstrap ($tag): $url"
cd /tmp
wget -q -O "pmb.tar.bz2" "$url"
tar -xf "pmb.tar.bz2"
mv pmbootstrap-* pmbootstrap
# Install to $PATH and init
sudo ln -s /tmp/pmbootstrap/ /usr/bin/pmbootstrap
echo "Initializing pmbootstrap with aports at '$pmaports'"
yes '' | pmbootstrap -q --aports "$pmaports" init
#!/usr/bin/env python3
import os
import argparse
import json
import requests
commit_default = os.environ['COMMIT'] if 'COMMIT' in os.environ else None
parser = argparse.ArgumentParser(description='tool to send data to')
parser.add_argument('--token', default='~/.pmos_token', help='secret token to authenticate to')
parser.add_argument('--host', default='', help='base url for the submit request')
parser.add_argument('--commit', default=commit_default, help='value for the X-Commit header')
parser.add_argument('--arch', default='x86_64', help='value for the X-Arch header')
parser.add_argument('--id', help='id of the job in the queue, value for the X-Id header')
parser.add_argument('--json', action='store_true', help='datafile is a json file, do extra sanity checks')
parser.add_argument('--verbose', '-v', action='store_true', help='show more debug info')
parser.add_argument('endpoint', help='endpoint name on the API')
parser.add_argument('datafile', help='file containing the data to be submitted')
args = parser.parse_args()
if args.commit is None:
print('You need to either add COMMIT to the environment or specify --commit')
if args.verbose:
with open(os.path.expanduser(args.token), encoding="utf-8") as handle:
secret =
url = '{}/api/{}'.format(, args.endpoint)
if args.json:
# Send contents of file as HTTP POST with json payload
with open(args.datafile, encoding="utf-8") as handle:
data =
data = json.loads(data)
print('Sending json data to {}'.format(url))
response =, json=data, headers={
'X-Secret': secret,
'X-Commit': args.commit,
'X-Arch': args.arch
filename = os.path.basename(args.datafile)
# Send contents of file as HTTP POST with multipart/formdata payload
files = {
'file': (filename, open(args.datafile, 'rb'), 'application/octet-stream')
print('Uploading {} to {}'.format(filename, url))
response =, files=files, headers={
'X-Secret': secret,
'X-Commit': args.commit,
'X-Arch': args.arch,
if response.status_code > 399:
print('Error occured:')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment