diff --git a/tools/clean-staging b/tools/clean-staging new file mode 100755 index 0000000000000000000000000000000000000000..8b3b20ccad177e244f0c20c0497e48d5ec9c55ce --- /dev/null +++ b/tools/clean-staging @@ -0,0 +1,37 @@ +#!/usr/bin/env python + +import os +import json +from subprocess import Popen, PIPE, check_call +from installsystems.printer import arrow + +def get_image_list(repo): + p = Popen(['is', '--no-color', '--quiet', '--repo-search', '', + 'list', '-j', '%s/*' % repo], stdout=PIPE) + stdout, stderr = p.communicate() + if p.returncode != 0: + exit('Unable to get %s list' % repo) + img = json.loads(stdout) + d = {} + for k,v in img.items(): + d[v['md5']] = k + return d + + +arrow('Getting staging images list') +staging_imgs=get_image_list('staging') +arrow('Getting stable images list') +stable_imgs=get_image_list('stable') +arrow('Getting testing images list') +testing_imgs=get_image_list('testing') + +official=set(stable_imgs) | set(testing_imgs) +to_remove=set(staging_imgs) & official + +arrow('Removing staging images in stable or testing') +for md5 in to_remove: + name=staging_imgs[md5] + arrow('%s (%s)' % (name, md5), 1) + check_call(['is', 'del', '-f', name]) + +# vim:set ts=2 sw=2 ft=python noet: diff --git a/tools/clean-testing b/tools/clean-testing new file mode 100755 index 0000000000000000000000000000000000000000..046c8eddd57d440469f9d6fbe50c64ab3e96b387 --- /dev/null +++ b/tools/clean-testing @@ -0,0 +1,34 @@ +#!/usr/bin/env python + +import os +import json +from subprocess import Popen, PIPE, check_call +from installsystems.printer import arrow + +def get_image_list(repo): + p = Popen(['is', '--no-color', '-q', 'list', '-j', '%s/*' % repo], stdout=PIPE) + stdout, stderr = p.communicate() + if p.returncode != 0: + exit('Unable to get %s list' % repo) + img = json.loads(stdout) + d = {} + for k,v in img.items(): + d[v['md5']] = k + return d + + +arrow('Getting stable images list') +stable_imgs=get_image_list('stable') +arrow('Getting testing images list') +testing_imgs=get_image_list('testing') + +official=set(stable_imgs) +to_remove=set(testing_imgs) & official + +arrow('Removing testing images in stable') +for md5 in to_remove: + name=testing_imgs[md5] + arrow('%s (%s)' % (name, md5), 1) + check_call(['is', 'del', '-f', name]) + +# vim:set ts=2 sw=2 ft=python noet: diff --git a/tools/new-image b/tools/new-image new file mode 100755 index 0000000000000000000000000000000000000000..7cf0060c8d8ed210a69fa04542f0349ef29c1979 --- /dev/null +++ b/tools/new-image @@ -0,0 +1,40 @@ +#!/bin/bash +# A seblu script + +usage() { + echo "usage: ${0##*/} image_name" >&2 + exit 1 +} + +image_path='/root/images' +image_name="$1" + +cd "$image_path" + +# check image already exists +[[ -d "$image_name" ]] && echo "Image $image_name already exists" >&2 && exit 2 + +# create image +is new "$image_name" + +cd "$image_name" + +# customize description +sed -ri "s/\s*name\s*=.*/name = $image_name/" description +sed -ri "s/\s*version\s*=.*/version = 0/" description + +# create git +git init + +# add gitignore +cat > .gitignore << EOF +*.isimage +*.isdata +payload +EOF + +git add .gitignore +git add description changelog +git ci -m 'Initial commit' + +# vim:set ts=2 sw=2 ft=sh et: diff --git a/tools/staging b/tools/staging new file mode 100755 index 0000000000000000000000000000000000000000..8797681db9e7e2cade990125fb3a8b6792dc75a3 --- /dev/null +++ b/tools/staging @@ -0,0 +1,29 @@ +#!/bin/bash + +usage() { + echo "usage: $0 [build_options]" >&2 +} + +repo=$(basename $0) +(( $# > 0 )) && build_options=("$@") || build_options=('-f') + +[[ ! -r description ]] && echo 'Invalid source image' >&2 && usage && exit 2 + +imgname=$(sed -rn 's/^[[:space:]]*name[[:space:]]*=[[:space:]]*([^[:space:]]+)[[:space:]]*/\1/p' description) +imgver=$(sed -rn 's/^[[:space:]]*version[[:space:]]*=[[:space:]]*([^[:space:]]+)[[:space:]]*/\1/p' description) + +echo "Building image $imgname v$imgver and pushing it on repo $repo" + +# build new version +is build "${build_options[@]}" || exit 1 + +# is v5 doesn't return != 0 if ctrl+c is pressed, we check manually +[[ -f "$imgname-$imgver.isimage" ]] || exit 1 + +# delete old version +is del -fp "$repo/$imgname:$imgver" + +# add new version +is add "$repo" "$imgname-$imgver.isimage" + +# vim:set ts=2 sw=2 ft=sh noet: