2015-10-22 14:39:15 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
DISTGIT_PATH=$(pwd)
|
|
|
|
|
|
|
|
FEDORA_VERSION=rawhide
|
2016-03-02 16:43:18 +00:00
|
|
|
DOCKER_FEDORA_VERSION=master
|
2015-10-22 14:39:15 +00:00
|
|
|
DISTGIT_BRANCH=master
|
2018-09-26 17:09:42 +00:00
|
|
|
REPO_SELINUX_POLICY=${REPO_SELINUX_POLICY:-https://github.com/fedora-selinux/selinux-policy}
|
2018-06-15 13:08:02 +00:00
|
|
|
REPO_SELINUX_POLICY_BRANCH=${REPO_SELINUX_POLICY_BRANCH:-$FEDORA_VERSION}
|
2018-09-26 17:09:42 +00:00
|
|
|
REPO_SELINUX_POLICY_CONTRIB=${REPO_SELINUX_POLICY_CONTRIB:-https://github.com/fedora-selinux/selinux-policy-contrib}
|
2018-06-15 13:08:02 +00:00
|
|
|
REPO_SELINUX_POLICY_CONTRIB_BRANCH=${REPO_SELINUX_POLICY_CONTRIB_BRANCH:-$FEDORA_VERSION}
|
2018-09-26 17:09:42 +00:00
|
|
|
REPO_CONTAINER_SELINUX=${REPO_CONTAINER_SELINUX:-https://github.com/containers/container-selinux}
|
2018-06-15 13:08:02 +00:00
|
|
|
|
|
|
|
# When -l is specified, we use locally created tarballs and don't download them from github
|
|
|
|
DOWNLOAD_DEFAULT_GITHUB_TARBALLS=1
|
|
|
|
if [ "$1" == "-l" ]; then
|
|
|
|
DOWNLOAD_DEFAULT_GITHUB_TARBALLS=0
|
|
|
|
fi
|
2015-10-22 14:39:15 +00:00
|
|
|
|
|
|
|
git checkout $DISTGIT_BRANCH -q
|
|
|
|
|
|
|
|
POLICYSOURCES=`mktemp -d policysources.XXXXXX`
|
|
|
|
pushd $POLICYSOURCES > /dev/null
|
|
|
|
|
2018-06-15 13:08:02 +00:00
|
|
|
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
|
2015-10-22 14:39:15 +00:00
|
|
|
|
|
|
|
pushd selinux-policy > /dev/null
|
2015-10-23 09:06:11 +00:00
|
|
|
# prepare policy patches against upstream commits matching the last upstream merge
|
2018-06-15 13:08:02 +00:00
|
|
|
git checkout $REPO_SELINUX_POLICY_BRANCH
|
2017-12-24 13:31:11 +00:00
|
|
|
BASE_HEAD_ID=$(git rev-parse HEAD)
|
|
|
|
BASE_SHORT_HEAD_ID=$(c=${BASE_HEAD_ID}; echo ${c:0:7})
|
2018-06-15 13:08:02 +00:00
|
|
|
git archive --prefix=selinux-policy-$BASE_HEAD_ID/ --format tgz HEAD > $DISTGIT_PATH/selinux-policy-$BASE_SHORT_HEAD_ID.tar.gz
|
2017-02-15 14:34:56 +00:00
|
|
|
popd > /dev/null
|
|
|
|
|
|
|
|
pushd selinux-policy-contrib > /dev/null
|
|
|
|
# prepare policy patches against upstream commits matching the last upstream merge
|
2018-06-15 13:08:02 +00:00
|
|
|
git checkout $REPO_SELINUX_POLICY_CONTRIB_BRANCH
|
2017-12-24 13:31:11 +00:00
|
|
|
CONTRIB_HEAD_ID=$(git rev-parse HEAD)
|
|
|
|
CONTRIB_SHORT_HEAD_ID=$(c=${CONTRIB_HEAD_ID}; echo ${c:0:7})
|
2018-06-15 13:08:02 +00:00
|
|
|
git archive --prefix=selinux-policy-contrib-$CONTRIB_HEAD_ID/ --format tgz HEAD > $DISTGIT_PATH/selinux-policy-contrib-$CONTRIB_SHORT_HEAD_ID.tar.gz
|
2015-10-22 14:39:15 +00:00
|
|
|
popd > /dev/null
|
|
|
|
|
2016-10-10 13:59:49 +00:00
|
|
|
pushd container-selinux > /dev/null
|
|
|
|
# Actual container-selinux files are in master branch
|
2016-03-08 14:37:39 +00:00
|
|
|
#git checkout -b ${DOCKER_FEDORA_VERSION} -t origin/${DOCKER_FEDORA_VERSION} -q
|
2016-10-10 13:59:49 +00:00
|
|
|
tar -czf container-selinux.tgz container.if container.te container.fc
|
2015-10-22 14:39:15 +00:00
|
|
|
popd > /dev/null
|
|
|
|
|
|
|
|
pushd $DISTGIT_PATH > /dev/null
|
2018-06-15 13:08:02 +00:00
|
|
|
if [ $DOWNLOAD_DEFAULT_GITHUB_TARBALLS == 1 ]; then
|
2018-08-19 14:57:26 +00:00
|
|
|
wget -O selinux-policy-${BASE_SHORT_HEAD_ID}.tar.gz https://github.com/fedora-selinux/selinux-policy/archive/${BASE_HEAD_ID}.tar.gz &> /dev/null
|
|
|
|
wget -O selinux-policy-contrib-${CONTRIB_SHORT_HEAD_ID}.tar.gz https://github.com/fedora-selinux/selinux-policy-contrib/archive/${CONTRIB_HEAD_ID}.tar.gz &> /dev/null
|
2018-06-15 13:08:02 +00:00
|
|
|
fi
|
2016-10-10 13:59:49 +00:00
|
|
|
cp $POLICYSOURCES/container-selinux/container-selinux.tgz .
|
2015-10-22 14:39:15 +00:00
|
|
|
popd > /dev/null
|
|
|
|
|
|
|
|
popd > /dev/null
|
|
|
|
rm -rf $POLICYSOURCES
|
|
|
|
|
2018-06-15 13:08:02 +00:00
|
|
|
# Update commit ids in selinux-policy.spec file
|
|
|
|
sed -i "s/%global commit0 [^ ]*$/%global commit0 $BASE_HEAD_ID/" selinux-policy.spec
|
|
|
|
sed -i "s/%global commit1 [^ ]*$/%global commit1 $CONTRIB_HEAD_ID/" selinux-policy.spec
|
|
|
|
|
|
|
|
# Update sources
|
|
|
|
sha512sum --tag selinux-policy-${BASE_SHORT_HEAD_ID}.tar.gz selinux-policy-contrib-${CONTRIB_SHORT_HEAD_ID}.tar.gz container-selinux.tgz > sources
|
|
|
|
|
2017-12-24 13:31:11 +00:00
|
|
|
echo -e "\nSELinux policy tarballs and container.tgz with container policy files have been created."
|
2018-06-15 13:08:02 +00:00
|
|
|
echo "Commit ids of selinux-policy and selinux-policy-contrib in spec file were changed to:"
|
2017-12-24 13:31:11 +00:00
|
|
|
echo "commit0 " ${BASE_HEAD_ID}
|
|
|
|
echo "commit1 " ${CONTRIB_HEAD_ID}
|