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