Skip to content
Snippets Groups Projects
Commit 07e374f0 authored by Seblu's avatar Seblu
Browse files

Fix bad deferencing in directory in /data of image

parent a4191c84
No related branches found
No related tags found
No related merge requests found
...@@ -40,7 +40,7 @@ def build(options): ...@@ -40,7 +40,7 @@ def build(options):
for d in ("", "parser", "setup", "data"): for d in ("", "parser", "setup", "data"):
rp = os.path.join(options.path, d) rp = os.path.join(options.path, d)
if not os.path.exists(rp): if not os.path.exists(rp):
error("Missing directory: %s" % rp) error("Missing directory: %s" % d)
if not os.path.isdir(rp): if not os.path.isdir(rp):
error("Not a directory: %s" % rp) error("Not a directory: %s" % rp)
if not os.access(rp, os.R_OK|os.X_OK): if not os.access(rp, os.R_OK|os.X_OK):
......
...@@ -73,3 +73,5 @@ try: ...@@ -73,3 +73,5 @@ try:
pkg.run_setup({"args": args}) pkg.run_setup({"args": args})
except Exception as e: except Exception as e:
error(e) error(e)
except KeyboardInterrupt:
warn("Keyboard Interrupted")
...@@ -11,7 +11,6 @@ import stat ...@@ -11,7 +11,6 @@ import stat
import datetime import datetime
import time import time
import json import json
import hashlib
import StringIO import StringIO
import ConfigParser import ConfigParser
import subprocess import subprocess
...@@ -19,10 +18,10 @@ import json ...@@ -19,10 +18,10 @@ import json
import tarfile import tarfile
import re import re
import installsystems.template import installsystems.template
import installsystems.tools as istools
from installsystems.printer import * from installsystems.printer import *
from installsystems.tarball import Tarball from installsystems.tarball import Tarball
class Image(object): class Image(object):
'''Abstract class of images''' '''Abstract class of images'''
...@@ -185,15 +184,17 @@ class SourceImage(Image): ...@@ -185,15 +184,17 @@ class SourceImage(Image):
def create_data_tarball(self, tar_path, data_path): def create_data_tarball(self, tar_path, data_path):
'''Create a data tarball''' '''Create a data tarball'''
dname = os.path.basename(data_path) dname = os.path.basename(data_path)
# not derefence for directory. Verbatim copy.
ddref = False if os.path.isdir(data_path) else True
try: try:
# opening file # opening file
if self.pbzip2_path: if self.pbzip2_path:
tb = open(tar_path, mode="w") tb = open(tar_path, mode="w")
p = subprocess.Popen(self.pbzip2_path, shell=False, close_fds=True, p = subprocess.Popen(self.pbzip2_path, shell=False, close_fds=True,
stdin=subprocess.PIPE, stdout=tb.fileno()) stdin=subprocess.PIPE, stdout=tb.fileno())
tarball = Tarball.open(mode="w|", dereference=True, fileobj=p.stdin) tarball = Tarball.open(mode="w|", dereference=ddref, fileobj=p.stdin)
else: else:
tarball = Tarball.open(tar_path, "w:bz2", dereference=True) tarball = Tarball.open(tar_path, "w:bz2", dereference=ddref)
tarball.add(data_path, arcname=dname, recursive=True) tarball.add(data_path, arcname=dname, recursive=True)
# closing tarball file # closing tarball file
tarball.close() tarball.close()
......
...@@ -7,15 +7,15 @@ InstallSystems Generic Tools Library ...@@ -7,15 +7,15 @@ InstallSystems Generic Tools Library
''' '''
import os import os
from installsystems.image import Image import hashlib
def md5sum(self, path): def md5sum(path):
'''Compute md5 of a file''' '''Compute md5 of a file'''
m = hashlib.md5() m = hashlib.md5()
m.update(open(path, "r").read()) m.update(open(path, "r").read())
return m.hexdigest() return m.hexdigest()
def cp(self, source, destination): def cp(source, destination):
'''Copy a source to destination. Take care of path type''' '''Copy a source to destination. Take care of path type'''
stype = path_type(source) stype = path_type(source)
dtype = path_type(destination) dtype = path_type(destination)
......
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