Use repo.build.vm as local build host

This commit is contained in:
Disassembler 2019-12-09 21:41:04 +01:00
parent 0351abcb92
commit 9532bc7405
No known key found for this signature in database
GPG Key ID: 524BD33A0EE29499
8 changed files with 63 additions and 61 deletions

@ -1 +1 @@
Subproject commit ca10263696d9488ee384430b2e2a0bc55e877b77
Subproject commit ad1bfc8860b84148794f26c437a42b932087495f

View File

@ -44,16 +44,13 @@ cat <<EOF >/etc/hosts
127.0.0.1 localhost
::1 localhost
172.17.0.1 host
172.17.0.1 repo.spotter.cz
172.17.0.1 repo.build.vm
EOF
# Reset vmmgr config
export ADMINPWD=$(python3 -c "import json; f = open('/etc/vmmgr/config.json'); j = json.load(f); print(j['host']['adminpwd'])")
envsubst </etc/vmmgr/config.default.json >/etc/vmmgr/config.json
# Reset lxcmgr config
echo '{"url":"https://repo.spotter.cz/lxc","user":"","pwd":""}' >/etc/lxcmgr/repo.json
# Clean locally installed LXC packages
rm -rf /var/lib/lxcmgr/storage/*
rm -rf /var/lib/lxcmgr/cache/apps/*

View File

@ -1,6 +1,6 @@
server {
listen [::]:80;
server_name repo.spotter.cz;
server_name repo.build.vm;
location / {
root /srv/build;

View File

@ -28,9 +28,12 @@ mkdir -p /srv/build/lxc/apps /srv/build/lxc/images
# Prepare local APK repository
cp etc/nginx/conf.d/apkrepo.conf /etc/nginx/conf.d/apkrepo.conf
echo "172.17.0.1 repo.spotter.cz" >>/etc/hosts
echo "172.17.0.1 repo.build.vm" >>/etc/hosts
service nginx reload
# Change LXCMgr repository
echo '{"url":"http://repo.build.vm/lxc","user":"","pwd":""}' >/etc/lxcmgr/repo.json
# Supply abuild key
# echo '/srv/build/repokey.rsa' | abuild-keygen

View File

@ -8,19 +8,6 @@ from lxcbuild.app import App
from lxcbuild.image import Image
from lxcbuild.imagebuilder import BuildType
parser = argparse.ArgumentParser(description='VM application builder and packager')
group = parser.add_mutually_exclusive_group()
group.add_argument('-f', '--force', action='store_true', help='Force rebuild already built package')
group.add_argument('-s', '--scratch', action='store_true', help='Build container for testing purposes, i.e. without cleanup on failure and packaging')
group.add_argument('-r', '--remove-image', action='store_true', help='Delete image (including scratch) from build repository')
group.add_argument('-e', '--remove-app', action='store_true', help='Delete application from build repository')
parser.add_argument('buildarg', help='Either specific "lxcfile" or "meta" file or a directory containing at least one of them')
if len(sys.argv) < 2:
parser.print_usage()
sys.exit(1)
args = parser.parse_args()
def build_and_pack_image(path, args):
image = Image()
if args.scratch:
@ -33,45 +20,60 @@ def pack_app(path):
app = App()
app.pack(path)
if args.remove_image:
image = Image()
image.name = args.buildarg
image.remove()
elif args.remove_app:
app = App()
app.name = args.buildarg
app.remove()
else:
buildpath = os.path.realpath(args.buildarg)
# If the buildpath is a file, determine type from filename
if os.path.isfile(buildpath):
basename = os.path.basename(buildpath)
if basename == 'lxcfile' or basename.endswith('.lxcfile'):
build_and_pack_image(buildpath, args)
# Compose files needs to be ignored when performing scratch builds
elif not args.scratch and basename == 'meta':
pack_app(buildpath)
else:
print('Unknown file {} given, expected "lxcfile"{}'.format(buildpath, '' if args.scratch else ' or "meta"'))
sys.exit(1)
# If the buildpath is a directory, build as much as possible, unless scratch build was requested, in which case don't build anything
def main(args):
if args.remove_image:
image = Image()
image.name = args.buildarg
image.remove()
elif args.remove_app:
app = App()
app.name = args.buildarg
app.remove()
else:
if args.scratch:
lxcfile = os.path.join(buildpath, 'lxcfile')
if os.path.exists(lxcfile):
build_and_pack_image(lxcfile, args)
buildpath = os.path.realpath(args.buildarg)
# If the buildpath is a file, determine type from filename
if os.path.isfile(buildpath):
basename = os.path.basename(buildpath)
if basename == 'lxcfile' or basename.endswith('.lxcfile'):
build_and_pack_image(buildpath, args)
# Compose files needs to be ignored when performing scratch builds
elif not args.scratch and basename == 'meta':
pack_app(buildpath)
else:
print('Please specify an lxcfile for scratch build')
print('Unknown file {} given, expected "lxcfile"{}'.format(buildpath, '' if args.scratch else ' or "meta"'))
sys.exit(1)
# If the buildpath is a directory, build as much as possible, unless scratch build was requested, in which case don't build anything
else:
valid_dir = False
for entry in os.scandir(buildpath):
if entry.is_file() and (entry.name == 'lxcfile' or entry.name.endswith('.lxcfile')):
if args.scratch:
lxcfile = os.path.join(buildpath, 'lxcfile')
if os.path.exists(lxcfile):
build_and_pack_image(lxcfile, args)
else:
print('Please specify an lxcfile for scratch build')
sys.exit(1)
else:
valid_dir = False
for entry in os.scandir(buildpath):
if entry.is_file() and (entry.name == 'lxcfile' or entry.name.endswith('.lxcfile')):
valid_dir = True
build_and_pack_image(entry.path, args)
meta = os.path.join(buildpath, 'meta')
if os.path.exists(meta):
valid_dir = True
build_and_pack_image(entry.path, args)
meta = os.path.join(buildpath, 'meta')
if os.path.exists(meta):
valid_dir = True
pack_app(meta)
if not valid_dir:
print('Directory {} doesn\'t contain anything to build, skipping'.format(buildpath))
pack_app(meta)
if not valid_dir:
print('Directory {} doesn\'t contain anything to build, skipping'.format(buildpath))
parser = argparse.ArgumentParser(description='VM application builder and packager')
group = parser.add_mutually_exclusive_group()
group.add_argument('-f', '--force', action='store_true', help='Force rebuild already built package')
group.add_argument('-s', '--scratch', action='store_true', help='Build container for testing purposes, i.e. without cleanup on failure and packaging')
group.add_argument('-r', '--remove-image', action='store_true', help='Delete image (including scratch) from build repository')
group.add_argument('-e', '--remove-app', action='store_true', help='Delete application from build repository')
parser.add_argument('buildarg', help='Either specific "lxcfile" or "meta" file or a directory containing at least one of them')
args = parser.parse_args()
if hasattr(args, 'buildarg'):
main(args)
else:
parser.print_usage()

View File

@ -20,7 +20,7 @@ setup-interfaces
ifup eth0
# Download and launch the setup script
wget repo.spotter.cz/vm.sh
wget https://repo.spotter.cz/vm.sh
sh vm.sh
```

View File

@ -1,3 +1,3 @@
http://dl-cdn.alpinelinux.org/alpine/v3.9/main
http://dl-cdn.alpinelinux.org/alpine/v3.9/community
@vm http://repo.spotter.cz/alpine/v3.9/apk
@vm http://repo.build.vm/alpine/v3.9/apk

View File

@ -1,3 +1,3 @@
http://dl-cdn.alpinelinux.org/alpine/v3.9/main
http://dl-cdn.alpinelinux.org/alpine/v3.9/community
@vm http://repo.spotter.cz/alpine/v3.9/apk
@vm https://repo.spotter.cz/alpine/v3.9/apk