~smoser/maas-images/trunk.img2squash-fixes

« back to all changes in this revision

Viewing changes to bin/img2squashfs

  • Committer: Scott Moser
  • Date: 2018-09-19 20:59:56 UTC
  • Revision ID: smoser@ubuntu.com-20180919205956-9lzu4w25t4ud49rt
img2squashfs: fix when 'image' was a directory.

This fixes img2squashfs for both '--format=dir' and --format=auto
(the default) when input is a directory.

Now the following works:
 img2squashfs my-dir/ /tmp/my-squashfs

Show diffs side-by-side

added added

removed removed

Lines of Context:
91
91
    [ "$fmt" != "auto" ] && _RET="$fmt" && return 0
92
92
    if [ -d "$input" ]; then
93
93
        debug 1 "${input} is a directory";
94
 
        _RET="$dir"
 
94
        _RET="dir"
95
95
        return
96
96
    fi
97
97
    fout=$(LANG=C file "$input") ||
127
127
 
128
128
get_usable_input() {
129
129
    # given 'input' in format 'fmt' return:
130
 
    #  _RET_fmt: the format of _RET_PATH. either
 
130
    #  _RET_fmt: the format of _RET_path. either
131
131
    #     fs-image : a mountable filesystem image.
132
132
    #     dir : a directory
133
133
    #  _RET_path: full path to a file in tempd
151
151
            return;;
152
152
        squashfs-image)
153
153
            _RET_fmt="squashfs-image"
154
 
            _RET_PATH="${tempd}/fs-image"
 
154
            _RET_path="${tempd}/fs-image"
155
155
            ln -s "$(readlink -f "$input")" "${tempd}/fs-image"
156
156
            return;;
157
157
        root-tar)
169
169
            ;;
170
170
        dir)
171
171
            _RET_fmt="dir"
172
 
            _RET_PATH="${tempd}/fs-dir"
 
172
            _RET_path="${tempd}/fs-dir"
173
173
            ln -s "$(readlink -f "$input")" "${tempd}/fs-dir"
174
174
            return;;
175
175
        *)
270
270
    elif [ -f "$tpath" ]; then
271
271
        fsimage2squashfs "$tpath" "$output" "$owner" || return
272
272
    elif [ -d "$tpath" ]; then
273
 
        dir2squashfs "$tpath" "$output" || return
 
273
        dir2squashfs "$tpath/" "$output" || return
274
274
    else
275
275
        error "failed. path='$tpath' cfmt=${cfmt}"
276
276
        return 1