~lool/linaro-image-tools/initrd-do

« back to all changes in this revision

Viewing changes to linaro_image_tools/media_create/rootfs.py

  • Committer: Guilherme Salgado
  • Date: 2011-07-18 16:08:49 UTC
  • mfrom: (376.1.1 bug-789093)
  • Revision ID: guilherme.salgado@linaro.org-20110718160849-q0gijy79iwakeycn
Make sure rootfs.move_contents() doesn't skip files that are not world-readable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
import glob
21
21
import os
 
22
import subprocess
22
23
import tempfile
23
24
 
24
25
from linaro_image_tools import cmd_runner
107
108
        flash_kernel, "UBOOT_PART=%s" % target_boot_dev)
108
109
 
109
110
 
 
111
def _list_files(directory):
 
112
    """List the files and dirs under the given directory.
 
113
 
 
114
    Runs as root because we want to list everything, including stuff that may
 
115
    not be world-readable.
 
116
    """
 
117
    p = cmd_runner.run(
 
118
        ['find', directory, '-maxdepth', '1', '-mindepth', '1'],
 
119
        stdout=subprocess.PIPE, as_root=True)
 
120
    stdout, _ = p.communicate()
 
121
    return stdout.split()
 
122
 
 
123
 
110
124
def move_contents(from_, root_disk):
111
125
    """Move everything under from_ to the given root disk.
112
126
 
113
127
    Uses sudo for moving.
114
128
    """
115
129
    assert os.path.isdir(from_), "%s is not a directory" % from_
116
 
    files = glob.glob(os.path.join(from_, '*'))
 
130
    files = _list_files(from_)
117
131
    mv_cmd = ['mv']
118
132
    mv_cmd.extend(sorted(files))
119
133
    mv_cmd.append(root_disk)