mksquashfs: squashfs 이미지에 전체 절대 디렉토리 경로를 포함하는 방법은 무엇입니까?

mksquashfs: squashfs 이미지에 전체 절대 디렉토리 경로를 포함하는 방법은 무엇입니까?

예를 들어 여러 디렉터리에서 squashfs 이미지를 만들 때:

  • /쓰레기통/
  • /usr/빈/
  • /usr/로컬/빈/
  • /일부/기타/무작위/폴더/
  • /다른/긴/경로/

명령어를 사용하면...

mksquashfs /bin /usr/bin /usr/local/bin /some/other/random/folder /another/long/path MyNewImage.squashfs

다음과 같은 최상위 폴더가 포함된 이미지를 제공합니다.

  • 쓰레기통/
  • bin_1/
  • bin_2/
  • 폴더/
  • 길/

내 이미지에 원본 파일 시스템의 전체 경로가 포함되기를 원합니다.

  • 쓰레기통/
  • 사용자/빈/
  • 사용자/로컬/빈/
  • 일부/기타/무작위/폴더/
  • 또 다른/긴/도로/

이미지를 생성하기 전에 원본 파일을 복사하거나 이동하지 않고 쉽게 수행할 수 있는 방법이 있습니까?

답변1

@meuh의 답변을 바탕으로 (이해하기가 약간 어렵습니다):

mksquashfs / MyNewImage.squashfs -wildcards -e \
  !(bin|usr|some|another) \
  usr/!(bin|local) \
  usr/local/!(bin) \
  some/!(other) \
  some/other/!(random) \
  some/other/random/!(folder) \
  another/!(long) \
  another/long/!(path)

또한 더 이해하기 쉽고 간결한 가능성을 갖게 되어 기쁘게 생각하며 이에 대한 기능 요청을 제출했습니다.https://github.com/plougher/squashfs-tools/issues/80.

고쳐 쓰다

-no-strip최신 버전에서는 이 옵션을 사용할 수 있습니다 .

mksquashfs /bin /usr/bin /usr/local/bin \
    /some/other/random/folder /another/long/path \
    MyNewImage.squashfs -no-strip

답변2

아마도 그렇지 않을 것이다간단한 방법, 그러나 확장된 와일드카드 제외 구문을 사용하면 이 작업을 수행할 수 있습니다. 이것은 매뉴얼 페이지에 문서화되어 있지 않을 수도 있지만읽어보기 파일. 그러나 구문 세부 사항은 매뉴얼 페이지를 확인해야 합니다 fnmatch(3).

!(somedir)기본적으로 제외 로 사용할 수 있습니다아니요제외하면 해당 디렉토리만 포함됩니다. 다음과 같은 예제 트리가 있다고 가정합니다./tmp

$ mkdir -p a/b   d/e   d/e2
$ touch    a/b/c d/e/f d/e2/f2

a이러한 전체 경로 이름을 유지 하면서 복사하기를 원합니다 d/e. 당신은 그것을 사용할 수 있습니다

$ echo '!(a)' >exclude
$ mksquashfs /tmp mysq -ef exclude -wildcards
$ echo -e '!(d)/\nd/!(e)' >exclude
$ mksquashfs /tmp mysq -ef exclude -wildcards

파일 시스템을 나열하면 unsquashfs -l mysq출력이 생성됩니다.

squashfs-root/a
squashfs-root/a/b
squashfs-root/a/b/c
squashfs-root/d
squashfs-root/d/e
squashfs-root/d/e/f

매번 소스 디렉토리는 이지만 /tmp처음에는 디렉토리를 제외한 모든 것을 제외 a하고 두 번째에는 d디렉토리 및 를 제외한 모든 것을 제외합니다 d/e. 이는 각 줄에서 유지하려는 경로 외에 다른 디렉토리 단계를 제외하는 다중 레벨 제외 파일을 사용합니다.


더 간단한 해결책은 필요한 디렉토리 계층 구조를 어딘가에 생성하고 mount -bind최종 디렉토리를 실제 디렉토리로 생성하는 것입니다. 예를 들어,

$ mkdir -p a/usr/local/bin a/some/other/bin
$ sudo mount -o bind /usr/local/bin a/usr/local/bin
$ sudo mount -o bind /some/other/bin a/some/other/bin
$ mksquashfs a ~/mysq
$ sudo umount a/usr/local/bin a/some/other/bin

답변3

남자 mksquashfs:

   -keep-as-directory
       if  one source directory is specified, create a root directory con‐
       taining that directory, rather than the contents of the directory.

관련 정보