def unpack(destdir):
    """Unpack and Squash image to local filesystem"""

    if not nav:
        sys.exit(1)

    ecode = 0
    try:
        anchore_print("Unpacking images: " + ' '.join(nav.get_images()))
        result = nav.unpack(destdir=destdir)
        if not result:
            anchore_print_err("no images unpacked")
            ecode = 1
        else:
            for imageId in result:
                anchore_print("Unpacked image: " + imageId)
                anchore_print("Unpack directory: "+ result[imageId])
    except:
        anchore_print_err("operation failed")
        ecode = 1

    contexts['anchore_allimages'].clear()
    
    sys.exit(ecode)
Unpack and Squash image to local filesystem