Improve make-rhat-patches.sh for local development
make-rhat-patches.sh had everything hard coded and didn't update spec file so it was hard to use for local selinux-policy development. This patch doesn't change default behavior, but makes this script configurable using environmental variables and one option. Usage: If you want to change location of repositories set the following variables: REPO_SELINUX_POLICY selinux-policy repository REPO_SELINUX_POLICY_BRANCH selinux-policy repository branch REPO_SELINUX_POLICY_CONTRIB selinux-policy repository REPO_SELINUX_POLICY_CONTRIB_BRANCH selinux-policy-contrib repository branch REPO_CONTAINER_SELINUX container-selinux repository If you want to use locally created tarball (and don't download tarballs from github), use '-l' option. Example: export REPO_SELINUX_POLICY=~/devel/local/selinux-policy.git export REPO_SELINUX_POLICY_BRANCH=WIP-my-new-fix export REPO_SELINUX_POLICY_CONTRIB=~/devel/local/selinux-policy-contrib.git export REPO_SELINUX_POLICY_CONTRIB_BRANCH=WIP-some-contrib-fix export REPO_CONTAINER_SELINUX=~/devel/local/container-selinux.git ./make-rhat-patches.sh -l
This commit is contained in:
parent
f4debe939a
commit
b719841045
@ -5,28 +5,41 @@ DISTGIT_PATH=$(pwd)
|
|||||||
FEDORA_VERSION=rawhide
|
FEDORA_VERSION=rawhide
|
||||||
DOCKER_FEDORA_VERSION=master
|
DOCKER_FEDORA_VERSION=master
|
||||||
DISTGIT_BRANCH=master
|
DISTGIT_BRANCH=master
|
||||||
|
REPO_SELINUX_POLICY=${REPO_SELINUX_POLICY:-git@github.com:fedora-selinux/selinux-policy.git}
|
||||||
|
REPO_SELINUX_POLICY_BRANCH=${REPO_SELINUX_POLICY_BRANCH:-$FEDORA_VERSION}
|
||||||
|
REPO_SELINUX_POLICY_CONTRIB=${REPO_SELINUX_POLICY_CONTRIB:-git@github.com:fedora-selinux/selinux-policy-contrib.git}
|
||||||
|
REPO_SELINUX_POLICY_CONTRIB_BRANCH=${REPO_SELINUX_POLICY_CONTRIB_BRANCH:-$FEDORA_VERSION}
|
||||||
|
REPO_CONTAINER_SELINUX=${REPO_CONTAINER_SELINUX:-git@github.com:projectatomic/container-selinux.git}
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
git checkout $DISTGIT_BRANCH -q
|
git checkout $DISTGIT_BRANCH -q
|
||||||
|
|
||||||
POLICYSOURCES=`mktemp -d policysources.XXXXXX`
|
POLICYSOURCES=`mktemp -d policysources.XXXXXX`
|
||||||
pushd $POLICYSOURCES > /dev/null
|
pushd $POLICYSOURCES > /dev/null
|
||||||
|
|
||||||
git clone git@github.com:fedora-selinux/selinux-policy.git -q
|
git clone -q $REPO_SELINUX_POLICY selinux-policy
|
||||||
git clone git@github.com:fedora-selinux/selinux-policy-contrib.git -q
|
git clone -q $REPO_SELINUX_POLICY_CONTRIB selinux-policy-contrib
|
||||||
git clone git@github.com:projectatomic/container-selinux.git -q
|
git clone -q $REPO_CONTAINER_SELINUX container-selinux
|
||||||
|
|
||||||
pushd selinux-policy > /dev/null
|
pushd selinux-policy > /dev/null
|
||||||
# prepare policy patches against upstream commits matching the last upstream merge
|
# prepare policy patches against upstream commits matching the last upstream merge
|
||||||
git checkout $FEDORA_VERSION
|
git checkout $REPO_SELINUX_POLICY_BRANCH
|
||||||
BASE_HEAD_ID=$(git rev-parse HEAD)
|
BASE_HEAD_ID=$(git rev-parse HEAD)
|
||||||
BASE_SHORT_HEAD_ID=$(c=${BASE_HEAD_ID}; echo ${c:0:7})
|
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
|
||||||
popd > /dev/null
|
popd > /dev/null
|
||||||
|
|
||||||
pushd selinux-policy-contrib > /dev/null
|
pushd selinux-policy-contrib > /dev/null
|
||||||
# prepare policy patches against upstream commits matching the last upstream merge
|
# prepare policy patches against upstream commits matching the last upstream merge
|
||||||
git checkout $FEDORA_VERSION
|
git checkout $REPO_SELINUX_POLICY_CONTRIB_BRANCH
|
||||||
CONTRIB_HEAD_ID=$(git rev-parse HEAD)
|
CONTRIB_HEAD_ID=$(git rev-parse HEAD)
|
||||||
CONTRIB_SHORT_HEAD_ID=$(c=${CONTRIB_HEAD_ID}; echo ${c:0:7})
|
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
|
||||||
popd > /dev/null
|
popd > /dev/null
|
||||||
|
|
||||||
pushd container-selinux > /dev/null
|
pushd container-selinux > /dev/null
|
||||||
@ -36,15 +49,24 @@ tar -czf container-selinux.tgz container.if container.te container.fc
|
|||||||
popd > /dev/null
|
popd > /dev/null
|
||||||
|
|
||||||
pushd $DISTGIT_PATH > /dev/null
|
pushd $DISTGIT_PATH > /dev/null
|
||||||
wget -nc https://github.com/fedora-selinux/selinux-policy/archive/${BASE_HEAD_ID}/selinux-policy-${BASE_SHORT_HEAD_ID}.tar.gz &> /dev/null
|
if [ $DOWNLOAD_DEFAULT_GITHUB_TARBALLS == 1 ]; then
|
||||||
wget -nc https://github.com/fedora-selinux/selinux-policy-contrib/archive/${CONTRIB_HEAD_ID}/selinux-policy-contrib-${CONTRIB_SHORT_HEAD_ID}.tar.gz &> /dev/null
|
wget -O selinux-policy-${BASE_SHORT_HEAD_ID}.tar.gz https://github.com/fedora-selinux/selinux-policy/archive/${BASE_HEAD_ID}/selinux-policy-${BASE_SHORT_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}/selinux-policy-contrib-${CONTRIB_SHORT_HEAD_ID}.tar.gz &> /dev/null
|
||||||
|
fi
|
||||||
cp $POLICYSOURCES/container-selinux/container-selinux.tgz .
|
cp $POLICYSOURCES/container-selinux/container-selinux.tgz .
|
||||||
popd > /dev/null
|
popd > /dev/null
|
||||||
|
|
||||||
popd > /dev/null
|
popd > /dev/null
|
||||||
rm -rf $POLICYSOURCES
|
rm -rf $POLICYSOURCES
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
echo -e "\nSELinux policy tarballs and container.tgz with container policy files have been created."
|
echo -e "\nSELinux policy tarballs and container.tgz with container policy files have been created."
|
||||||
echo "Replace commit ids of selinux-policy and selinux-policy-contrib in spec file to:"
|
echo "Commit ids of selinux-policy and selinux-policy-contrib in spec file were changed to:"
|
||||||
echo "commit0 " ${BASE_HEAD_ID}
|
echo "commit0 " ${BASE_HEAD_ID}
|
||||||
echo "commit1 " ${CONTRIB_HEAD_ID}
|
echo "commit1 " ${CONTRIB_HEAD_ID}
|
||||||
|
Loading…
Reference in New Issue
Block a user