Skip to content
Snippets Groups Projects
Commit cbb93d35 authored by Sebastien Luttringer's avatar Sebastien Luttringer
Browse files

add tools used on Smartjog builder and repository

parent c4e3e978
No related branches found
No related tags found
No related merge requests found
#!/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:
#!/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:
#!/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:
#!/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:
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment