a/trunk/wharfie/lib/makefile.py b/trunk/wharfie/lib/makefile.py
...
...
23
#
23
#
24
################################################################################
24
################################################################################
25
# We use templates, which are checking their execution context,
25
# We use templates, which are checking their execution context,
26
# to be sure, that target commands are really only executed
26
# to be sure, that target commands are really only executed
27
# in the change root of the image.
27
# in the change root of the image.
28
templateTrgCmd = "#!/bin/bash\n[ -f ../Wharfile ] && exit 2;\n%s\n"
28
templateTrgCmd = "#!/bin/bash\n[ -f ../Wharfile ] && exit 2;\n%s\nexit \$$?\n"
29
templateHostCmd = "#!/bin/bash\n[ ! -f ../Wharfile ] && exit 2;\n%s"
29
templateHostCmd = "#!/bin/bash\n[ ! -f ../Wharfile ] && exit 2;\n%s\nexit \$$?\n"
30
30
31
archiveName = 'rootfs.tar';
31
archiveName = 'rootfs.tar';
32
makeTargets = list();
32
makeTargets = list();
33
environment = list();
33
environment = list();
34
finalTarget = list();
34
finalTarget = list();
...
...
37
# Write a Makefile
37
# Write a Makefile
38
#
38
#
39
def write_makefile(filename, dry_run, installpath='.'):
39
def write_makefile(filename, dry_run, installpath='.'):
40
    f = open(filename, 'w');
40
    f = open(filename, 'w');
41
    # write header
41
    # write header
42
    f.write("ifneq (VERBOSE,y)\n")
42
    f.write("ifneq (${VERBOSE},y)\n")
43
    f.write("Q=@\n")
43
    f.write("Q=@\n")
44
    f.write("endif\n")
44
    f.write("endif\n")
45
    f.write("\n")
45
    f.write("\n")
46
    f.write("OUTPUT_FILE=%s\n" % archiveName)
46
    f.write("OUTPUT_FILE=%s\n" % archiveName)
47
    f.write("%s: %s\n" % (archiveName, "".join(finalTarget)));
47
    f.write("%s: %s\n" % (archiveName, "".join(finalTarget)));
...
...
80
        # start command here ...
80
        # start command here ...
81
        f.write("\t${Q}${SUDO} bash -c \"");
81
        f.write("\t${Q}${SUDO} bash -c \"");
82
        
82
        
83
        f.write("cd $$(basename $@ .tar); tar -xf ../$<; "); 
83
        f.write("cd $$(basename $@ .tar); tar -xf ../$<; "); 
84
        if not dry_run:
84
        if not dry_run:
85
            f.write("[ -f .trg.sh ] && chroot . ./.trg.sh; rm -f ./.trg.sh; ");
85
            f.write("if [ -f .trg.sh ]; then chroot . ./.trg.sh || exit 1; fi; rm -f ./.trg.sh;");
86
            f.write("[ -f .hst.sh ] && ./.hst.sh; rm -f ./.hst.sh; ");
86
            f.write("if [ -f .hst.sh ]; then ./.hst.sh || exit 1; fi; rm -f ./.hst.sh;");
87
        if not 'temporary' in target or not target['temporary']:
87
        if not 'temporary' in target or not target['temporary']:
88
            f.write("tar -cf '../$@' .;");
88
            f.write("tar -cf '../$@' .;");
89
        f.write("\"\n");
89
        f.write("\"\n");
90
        # ... end command
90
        # ... end command
91
            
91