for key, value in properties.items():
os.environ['SNF_IMAGE_PROPERTY_' + key] = value
- output = StringIO(subprocess.check_output(['bash', '-c', 'set']))
+ p = subprocess.Popen(['bash', '-c', 'set'], stdout=subprocess.PIPE)
+ output = StringIO(p.communicate()[0]);
for line in iter(output):
if line.startswith('SNF_IMAGE_PROPERTY_'):
- outfh.write(line)
+ outfh.write('export ' + line)
infh.close()
outfh.close()
if [ -n "$SNF_IMAGE_PROPERTIES" ]; then
properties=$(mktemp --tmpdir properties.XXXXXX)
add_cleanup rm "$properties"
- echo "SNF_IMAGE_PROPERTIES" |
- "@scriptsdir@/snf-decode-properties.py" > "$properties"
+ echo "$SNF_IMAGE_PROPERTIES" |
+ "@scriptsdir@/decode-properties.py" "$properties"
source "$properties"
else
log_error "SNF_IMAGE_PROPERTIES variable is missing"
new_pend=$(get_last_free_sector "$SNF_IMAGE_DEV")
-#Extend the partition
+if [ -z "$new_pend" ] ; then
+ # Nothing to do
+ exit 0
+fi
+
+# Extend the partition
$PARTED -s -m "$SNF_IMAGE_DEV" rm "$id"
$PARTED -s -m "$SNF_IMAGE_DEV" mkpart primary "$ptype" "$pstart" "$new_pend"
-#inform the kernel about the changes
+# Inform the kernel about the changes
partprobe "$SNF_IMAGE_DEV"
exit 0