Revision 2187080b snf-image-host/snf-image-update-helper.in

b/snf-image-host/snf-image-update-helper.in
140 140
mount "$root_dev" "$target"
141 141
add_cleanup umount "$root_dev"
142 142

  
143
echo -n "Checking for cached root filesystem in \`$HELPER_CACHE_DIR'..."
144
if [ "$NO_CACHE" == "yes" ]; then
145
    echo "don't use cache (option -r applied)"
146
    do_multistrap "$target" "$HELPER_CACHE_DIR/root.tar" "$HELPER_CACHE_DIR/packages"
147
elif [ -f "$HELPER_CACHE_DIR/root.tar" ]; then
148
    echo "found"
149

  
150
    missing_pkgs="no"
151
    echo -n "Checking if needed packages are present..."
152
    if [ ! -f "$HELPER_CACHE_DIR/packages" ]; then
153
        missing_pkgs="yes"
154
        echo "packages file: \`$HELPER_CACHE_DIR/packages' does not exist"
155
    else
156
        extra_pkgs=$(grep ^packages= "$MULTISTRAP_CONFIG" | cut -d= -f2 | tr  '\n' ' ')
157
        for pkg in $extra_pkgs; do
158
            if ! grep "^$pkg\$" "$HELPER_CACHE_DIR/packages" > /dev/null; then
159
		missing_pkgs="yes"
160
                echo "$pkg is missing."
161
                break
162
            fi
163
        done
164
        if [ "$missing_pkgs" == "no" ]; then
165
            echo "done"
166
        fi
167
    fi
168
    if [ "$missing_pkgs" == "yes" ]; then
169
            do_multistrap "$target" "$HELPER_CACHE_DIR/root.tar" "$HELPER_CACHE_DIR/packages"
170
    fi
143
do_multistrap "$target"
171 144

  
172
    test "$missing_pkgs" == "no" && while [[ 1 ]]; do
173
        echo -n "Use the cached file [Y/n]? "
174
        if [ "x$NO_PROMPT" = "xyes" ]; then
175
            echo "y";
176
            break;
177
        fi
178

  
179
        read answer
180
    
181
        if [ -z "$answer" -o "$(tr [A-Z] [a-z] <<< "$answer")" = "y" ]; then
182
            break;
183
        elif [ "$(tr [A-Z] [a-z] <<< "$answer" )" = "n" ]; then
184
            do_multistrap "$target" "$HELPER_CACHE_DIR/root.tar" "$HELPER_CACHE_DIR/packages"
185
            break;
186
        fi
187
    done
188

  
189
else
190
    echo "not found"
191
    do_multistrap "$target" "$HELPER_CACHE_DIR/root.tar" "$HELPER_CACHE_DIR/packages"
192
fi
193

  
194
tar xf "$HELPER_CACHE_DIR/root.tar" -C "$target"
145
# Save the package list
146
chroot "$target" dpkg-query -W  > "$HELPER_DIR/packages"
195 147

  
196 148
echo -n "Configuring the helper image..."
197 149
echo snf-image-helper > "$target/etc/hostname"
......
228 180
rm "$target/vmlinuz" "$target/initrd.img"
229 181

  
230 182

  
231
pkg_installed=$(grep snf-image-helper "$HELPER_CACHE_DIR/packages" > /dev/null && echo yes)
183
pkg_installed=$(grep snf-image-helper "$HELPER_DIR/packages" > /dev/null && echo yes)
232 184

  
233 185
if [ ! -r "$HELPER_PKG" -a -z "$pkg_installed" ]; then
234 186
    log_error "ERROR:"
......
243 195
    pkg_name=$(basename "$HELPER_PKG")
244 196
    add_cleanup rm "$target/tmp/$pkg_name"
245 197
    chroot "$target" dpkg -i "/tmp/$pkg_name" 2>&1 | sed -e 's/^/DPKG: /g'
198

  
199
    # Recreate package list
200
    chroot "$target" dpkg-query -W  > "$HELPER_DIR/packages"
246 201
else
247 202
    echo "snf-image-helper pkg was installed from the apt repository."
248 203
fi

Also available in: Unified diff