Commit 89a14af6 authored by Romain Courteaud's avatar Romain Courteaud

Support dynamic offset calculation

parent aa9adc87
0.12 (2011-12-24) 0.12 (2011-12-29)
================= =================
* No changes yet. * builder: dynamic offset calculation [Romain Courteaud]
0.11 (2011-12-23) 0.11 (2011-12-23)
================= =================
......
...@@ -2,7 +2,7 @@ from setuptools import setup, find_packages ...@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
import glob import glob
import os import os
version = '0.12-dev' version = '0.12'
name = 'slapos.toolbox' name = 'slapos.toolbox'
long_description = open("README.txt").read() + "\n" + \ long_description = open("README.txt").read() + "\n" + \
open("CHANGES.txt").read() + "\n" open("CHANGES.txt").read() + "\n"
......
...@@ -30,7 +30,7 @@ import sys ...@@ -30,7 +30,7 @@ import sys
from optparse import OptionParser, Option from optparse import OptionParser, Option
from subprocess import call as subprocessCall from subprocess import call as subprocessCall
from stat import S_ISBLK, ST_MODE from stat import S_ISBLK, ST_MODE
from tempfile import mkdtemp from tempfile import mkdtemp, mkstemp
import shutil import shutil
import pkg_resources import pkg_resources
...@@ -138,10 +138,23 @@ def run(config): ...@@ -138,10 +138,23 @@ def run(config):
print "Creating temp directory" print "Creating temp directory"
if not dry_run: if not dry_run:
mount_dir_path = mkdtemp() mount_dir_path = mkdtemp()
fdisk_output_path = mkstemp()
else: else:
mount_dir_path = "/tmp/a_generated_directory" mount_dir_path = "/tmp/a_generated_directory"
fdisk_output_path = "/tmp/a_generated_file"
try: try:
_call(['mount', '-o', 'loop,offset=32256', config.system_path, offset = 0
fdisk_output_file = open(fdisk_output_path, 'w')
_call(['sfdisk', '-d', '-uS', config.system_path], stdout=fdisk_output_file)
fdisk_output_file.close()
fdisk_output_file = open(fdisk_output_path, 'r')
for line in fdisk_output_file:
line = line.rstrip().replace(' ', '')
if line.endswith("bootable"):
offset = int(line.split(':')[1].split(',')[0].split('=')[1])
fdisk_output_file.close()
offset = offset * 512
_call(['mount', '-o', 'loop,offset=%i' % offset, config.system_path,
mount_dir_path], dry_run=dry_run) mount_dir_path], dry_run=dry_run)
try: try:
# Create slapos configuration directory if needed # Create slapos configuration directory if needed
......
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