tm-compressed-images-one-2.0.patch

patch for ONE 2.0 - Alexandre Joseph, 08/16/2010 03:45 PM

Download (3.22 KB)

View differences:

src/tm_mad/nfs/tm_clone.sh
44 44
exec_and_log "chmod a+w $DST_DIR"
45 45

  
46 46
case $SRC in
47
http://*)
47
http*.tar.gz|http*.tgz)
48
    log "Downloading tar.gz archive $SRC"
49
    exec_and_log "download_extract $SRC $DST_PATH.tar.gz $DST_PATH"
50
    ;;
51

  
52
http*.bz2)
53
    log "Downloading tar.bz2 archive $SRC"
54
    exec_and_log "download_extract $SRC $DST_PATH.tar.bz2 $DST_PATH"
55
    ;;
56

  
57
http*.xz)
58
    log "Downloading tar.xz archive $SRC"
59
    exec_and_log "download_extract $SRC $DST_PATH.tar.xz $DST_PATH"
60
    ;;
61

  
62
http*)
48 63
    log "Downloading $SRC"
49
    exec_and_log "$WGET -O $DST_PATH $SRC"
64
    exec_and_log "curl -k -o $DST_PATH $SRC"
50 65
    ;;
51 66

  
52 67
*)
src/tm_mad/ssh/tm_clone.sh
43 43
exec_and_log "$SSH $DST_HOST mkdir -p $DST_DIR"
44 44

  
45 45
case $SRC in
46
http://*)
46
http*.tar.gz|http*.tgz)
47
    log "Downloading tar.gz archive $SRC"
48
    exec_and_log "download_extract $SRC $DST_PATH.tar.gz $DST_PATH $DST_HOST"
49
    ;;
50

  
51
http*.bz2)
52
    log "Downloading tar.bz2 archive $SRC"
53
    exec_and_log "download_extract $SRC $DST_PATH.tar.bz2 $DST_PATH $DST_HOST"
54
    ;;
55

  
56
http*.xz)
57
    log "Downloading tar.xz archive $SRC"
58
    exec_and_log "download_extract $SRC $DST_PATH.tar.xz $DST_PATH $DST_HOST"
59
    ;;
60

  
61
http*)
47 62
    log "Downloading $SRC"
48
    exec_and_log "$SSH $DST_HOST $WGET -O $DST_PATH $SRC"
63
    exec_and_log "ssh $DST_HOST curl -k -o $DST_PATH $SRC"
49 64
    ;;
50 65

  
51 66
*)
52 67
    log "Cloning $SRC"
53
    exec_and_log "$SCP $SRC $DST"
68
    exec_and_log "scp $SRC $DST"
54 69
    ;;
55 70
esac
56 71

  
57
exec_and_log "$SSH $DST_HOST chmod a+rw $DST_PATH"
72
exec_and_log "ssh $DST_HOST chmod a+w $DST_PATH"
58 73

  
src/tm_mad/tm_common.sh
164 164
    fi
165 165
}
166 166

  
167
function download_extract
168
{
169
    URL=$1
170
    ARCHIVE=$2
171
    FILENAME=$3
172
    HOST=$4
173

  
174
    if [ "x$HOST" != "x" ]; then
175
        SSH_CMD="ssh $HOST"
176
    fi
177

  
178
    $SSH_CMD curl -k -o $ARCHIVE $URL
179

  
180
    extract_tar $ARCHIVE $FILENAME $HOST
181

  
182
    $SSH_CMD rm -rf $ARCHIVE
183
}
184

  
185
function file_ends_with
186
{
187
    FILE=$1
188
    EXTENSION=$2
189

  
190
    if [ "x$(echo $FILE | grep -E $EXTENSION)" != "x" ]; then
191
        echo 0
192
    else
193
        echo 1
194
    fi
195
}
196

  
197
function extract_tar
198
{
199
    ARCHIVE=$1
200
    OUTPUT=$2
201
    HOST=$3
202

  
203
    if [ $(file_ends_with $ARCHIVE '.tar.gz') = 0 ]; then
204
        FORMAT=z
205
    elif [ $(file_ends_with $ARCHIVE '.tar.bz2') = 0 ]; then
206
        FORMAT=j
207
    elif [ $(file_ends_with $ARCHIVE '.tar.xz') = 0 ]; then
208
        FORMAT=J
209
    fi
210
    
211
    TAR_CMD="tar -x${FORMAT}f $ARCHIVE"
212

  
213
    if [ "x$HOST" != "x" ]; then
214
    SSH_CMD="ssh $HOST"
215
    fi
216

  
217
    if [ "x$OUTPUT" != "x" ]; then
218
        if [ "x$HOST" != "x" ]; then
219
            $SSH_CMD "$TAR_CMD -O > $OUTPUT"
220
        else
221
            $TAR_CMD -O > $OUTPUT
222
        fi
223
    else
224
        $SSH_CMD $TAR_CMD 
225
    fi
226
}
227