On Fri, Aug 9, 2013 at 1:29 AM, Dave Reisner <d@falconindy.com> wrote:


On Aug 8, 2013 5:32 PM, "Dominik Heidler" <dheidler@gmail.com> wrote:
>
> Users can set a ccache directory (which must be writeable by
> the user nobody) to be mapped to /build/.ccache (which is the
> directory, that ccache will use in the chroot)
>
> Signed-off-by: Dominik Heidler <dheidler@gmail.com>
> ---
>  makechrootpkg.in | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/makechrootpkg.in b/makechrootpkg.in
> index 1cd08fb..8770378 100644
> --- a/makechrootpkg.in
> +++ b/makechrootpkg.in
> @@ -21,6 +21,7 @@ run_namcap=false
>  temp_chroot=false
>  chrootdir=
>  passeddir=
> +ccachedir=
>  declare -a install_pkgs
>  declare -i ret=0
>
> @@ -58,10 +59,11 @@ usage() {
>         echo "           Default: $copy"
>         echo '-n         Run namcap on the package'
>         echo '-T         Build in a temporary directory'
> +       echo '-C <dir>   The ccache directory to use'
>         exit 1
>  }
>
> -while getopts 'hcur:I:l:nT' arg; do
> +while getopts 'hcur:I:l:C:nT' arg; do
>         case "$arg" in
>                 h) usage ;;
>                 c) clean_first=true ;;
> @@ -71,6 +73,7 @@ while getopts 'hcur:I:l:nT' arg; do
>                 l) copy="$OPTARG" ;;
>                 n) run_namcap=true; makepkg_args="$makepkg_args -i" ;;
>                 T) temp_chroot=true; copy+="-$$" ;;
> +               C) ccachedir="$OPTARG" ;;
>                 *) makepkg_args="$makepkg_args -$arg $OPTARG" ;;
>         esac
>  done
> @@ -84,6 +87,11 @@ chrootdir=$(readlink -e "$passeddir")
>  [[ ! -d $chrootdir ]] && die "No chroot dir defined, or invalid path '%s'" "$passeddir"
>  [[ ! -d $chrootdir/root ]] && die "Missing chroot dir root directory. Try using: mkarchroot %s/root base-devel" "$chrootdir"
>
> +# Canonicalize ccachedir, getting rid of trailing /

This comment is bogus.

> +if [[ "$ccachedir" != "" ]]; then
> +       [[ ! -d $ccachedir ]] && die "Invalid path '%s' given for ccache directory" "$ccachedir"

Just fold these checks together into the same [[ and please use the -n test for the non-empty string. No need to quote in the test, either.

I'll send a new patch.

> +fi
> +
>  # Detect chrootdir filesystem type
>  chroottype=$(stat -f -c %T "$chrootdir")
>
> @@ -349,6 +357,7 @@ download_sources
>  if arch-nspawn "$copydir" \
>         --bind-ro="$PWD:/startdir_host" \
>         --bind-ro="$SRCDEST:/srcdest_host" \
> +       ${ccachedir:+"--bind=$ccachedir:/build/.ccache"} \
>         /chrootbuild
>  then
>         move_products
> --
> 1.8.3.4
>