[lxc-devel] [PATCH] lxc-gentoo: keep original uid/gid of files/dirs when installing

Stéphane Graber stgraber at ubuntu.com
Fri Sep 19 21:02:20 UTC 2014


On Thu, Sep 11, 2014 at 05:33:00PM +0900, TAMUKI Shoichi wrote:
> Call tar with --numeric-owner option to use numbers for user/group
> names because the whole uid/gid in rootfs should be consistently
> unchanged as in original stage3 tarball and private portage.
> 
> Signed-off-by: TAMUKI Shoichi <tamuki at linet.gr.jp>

Acked-by: Stéphane Graber <stgraber at ubuntu.com>

> ---
>  templates/lxc-gentoo.in | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/templates/lxc-gentoo.in b/templates/lxc-gentoo.in
> index 37895cf..659fd28 100644
> --- a/templates/lxc-gentoo.in
> +++ b/templates/lxc-gentoo.in
> @@ -166,12 +166,14 @@ cache_stage3()
>          printf " => Got: %s\n" "${stage3_latest_tarball}"
>  
>          printf "Downloading/untarring the actual stage3 tarball...\n"
> -        wget -O - "${stage3_baseurl}/${stage3_latest_tarball}" | tar -xjpf - -C "${partialfs}" \
> +        wget -O - "${stage3_baseurl}/${stage3_latest_tarball}" \
> +            | tar -xjpf - --numeric-owner -C "${partialfs}" \
>              || die 6 "Error: unable to fetch or untar\n"
>          printf " => extracted to: %s\n" "${partialfs}"
>      else
>          printf "Extracting the stage3 tarball...\n"
> -        tar -xpf "${tarball}" -C "${partialfs}" || die 6 "unable to untar ${tarball} to ${partialfs}"
> +        tar -xpf "${tarball}" --numeric-owner -C "${partialfs}" \
> +            || die 6 "unable to untar ${tarball} to ${partialfs}"
>      fi
>  
>      #check if it chroots
> @@ -338,7 +340,9 @@ container_precheck()
>  container_rootfs()
>  {
>      printf "#### container_rootfs(): copying rootfs %s from cache %s ...\n" "${rootfs}" "${cachefs}"
> -    tar -c -f - -C "${cachefs}" . | tar -x -p -f - -C "${rootfs}" || die 1 "Error: cache copy to rootfs failed"
> +    tar -c -f - --numeric-owner -C "${cachefs}" . \
> +        | tar -x -p -f - --numeric-owner -C "${rootfs}" \
> +        || die 1 "Error: cache copy to rootfs failed"
>  
>      printf "chroot test..."
>      chroot "${rootfs}" /bin/true || die 1 "Error: 'chroot %s /bin/true' failed"
> @@ -478,7 +482,9 @@ container_private_portage()
>      #called from container_portage() do not call directly from container_setup
>      printf "# untaring private portage to %s from %s ... \n" "${rootfs}/${portage_container}" "${portage_cache}"
>      mkdir -p "${rootfs}/${portage_container}"
> -    execute_exclusively portage 60 tar -xp --strip-components 1 -C "${rootfs}/${portage_container}" -f "${portage_cache}" \
> +    execute_exclusively portage 60 \
> +        tar -xp --strip-components 1 -C "${rootfs}/${portage_container}" \
> +        -f "${portage_cache}" --numeric-owner \
>          || die 2 "Error: unable to extract the portage tree.\n"
>      store_user_message "container has its own portage tree at ${portage_container}"
>      printf "=> done\n"
> -- 
> 1.9.0
> _______________________________________________
> lxc-devel mailing list
> lxc-devel at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-devel

-- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20140919/edb32470/attachment.sig>


More information about the lxc-devel mailing list