Last active
January 25, 2023 10:54
-
-
Save netsensei/c72146a910f7848bbed65b895000caa3 to your computer and use it in GitHub Desktop.
Create an RPM package from a .spec file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
DIR=$1 | |
if [[ ! -d $DIR ]];then | |
echo "${DIR} does not exist." | |
exit 1 | |
fi | |
BASENAME=$(basename $DIR) | |
UPDIR=$(cd $DIR/.. && pwd) | |
SPECFILE="${DIR}/${BASENAME}.spec" | |
if [[ ! -e $SPECFILE ]];then | |
echo "${SPECFILE} does not exist." | |
fi | |
if [[ ! -d "${HOME}/rpmbuild" ]];then | |
mkdir -p ${HOME}/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS} | |
fi | |
if [ -d $DIR/.git ]; then | |
cd $DIR | |
git ls-tree --name-only -r HEAD | while read line; do echo "${BASENAME}/$line"; done | tar -zcvf ${BASENAME}.tar.gz --directory=${UPDIR} -T - | |
else | |
cd $DIR | |
find * | while read line; do echo "${BASENAME}/$line"; done | tar --exclude ${BASENAME}.tar.gz -zcvf ${BASENAME}.tar.gz --directory=${UPDIR} -T - | |
fi | |
mv ${BASENAME}.tar.gz ${HOME}/rpmbuild/SOURCES && | |
cp ${DIR}/${BASENAME}.spec ${HOME}/rpmbuild/SPECS && | |
cd ${HOME}/rpmbuild/SPECS && | |
QA_RPATHS=$[ 0x0001|0x0010|0x0002 ] rpmbuild -vv -bb ${BASENAME}.spec |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment