make-rhat-patches: Use shallow clone

The selinux-policy repos are quite big - use --depth=1 to fetch only the
latest commit of the requested branch, to save network traffic and time.

A possible downside of this is that one can no longer pass a commit ID
via REPO_SELINUX_POLICY_*BRANCH, but that's unlikely to be useful in
practice.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
This commit is contained in:
Ondrej Mosnacek 2020-10-05 21:04:36 +02:00 committed by zpytela
parent d9d5631b8d
commit e042be0581

View File

@ -23,14 +23,15 @@ git checkout $DISTGIT_BRANCH -q
POLICYSOURCES=`mktemp -d --tmpdir policysources.XXXXXX`
pushd $POLICYSOURCES > /dev/null
git clone -q $REPO_SELINUX_POLICY selinux-policy
git clone -q $REPO_SELINUX_POLICY_CONTRIB selinux-policy-contrib
git clone -q $REPO_CONTAINER_SELINUX container-selinux
git clone -q $REPO_MACRO_EXPANDER macro-expander
git clone --depth=1 -q $REPO_SELINUX_POLICY selinux-policy \
-b $REPO_SELINUX_POLICY_BRANCH
git clone --depth=1 -q $REPO_SELINUX_POLICY_CONTRIB selinux-policy-contrib \
-b $REPO_SELINUX_POLICY_CONTRIB_BRANCH
git clone --depth=1 -q $REPO_CONTAINER_SELINUX container-selinux
git clone --depth=1 -q $REPO_MACRO_EXPANDER macro-expander
pushd selinux-policy > /dev/null
# prepare policy patches against upstream commits matching the last upstream merge
git checkout $REPO_SELINUX_POLICY_BRANCH
BASE_HEAD_ID=$(git rev-parse HEAD)
BASE_SHORT_HEAD_ID=$(c=${BASE_HEAD_ID}; echo ${c:0:7})
git archive --prefix=selinux-policy-$BASE_HEAD_ID/ --format tgz HEAD > $DISTGIT_PATH/selinux-policy-$BASE_SHORT_HEAD_ID.tar.gz
@ -38,7 +39,6 @@ popd > /dev/null
pushd selinux-policy-contrib > /dev/null
# prepare policy patches against upstream commits matching the last upstream merge
git checkout $REPO_SELINUX_POLICY_CONTRIB_BRANCH
CONTRIB_HEAD_ID=$(git rev-parse HEAD)
CONTRIB_SHORT_HEAD_ID=$(c=${CONTRIB_HEAD_ID}; echo ${c:0:7})
git archive --prefix=selinux-policy-contrib-$CONTRIB_HEAD_ID/ --format tgz HEAD > $DISTGIT_PATH/selinux-policy-contrib-$CONTRIB_SHORT_HEAD_ID.tar.gz