| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
# |
| 4 |
# prerequisite: |
| 5 |
# # yum install rpm-build rpmdevtools libchewing-devel |
| 6 |
# $ rpmdev-setuptree |
| 7 |
# |
| 8 |
# build: |
| 9 |
# $ cd <src>/ |
| 10 |
# $ ./distro/fedora/gen-rpm |
| 11 |
# |
| 12 |
# files located at ~/rpmbuild/{,S}RPMS |
| 13 |
# |
| 14 |
# install: |
| 15 |
# # rpm -ivh hime-[0gq]* |
| 16 |
# $ imsettings-switch hime |
| 17 |
# |
| 18 |
|
| 19 |
[ ! -e distro/fedora ] && exec echo Please execute '"[1m[32mdistro/fedora/gen-rpm[0m"' under hime directory, thanks. |
| 20 |
|
| 21 |
VERSION_FILE=ChangeLog |
| 22 |
SPEC_FILE=hime-fedora.spec |
| 23 |
DISTRODIR=distro/fedora |
| 24 |
DISTROROOT=`basename ${DISTRODIR}` |
| 25 |
SRCDIR=`rpm --eval "%{_sourcedir}"` |
| 26 |
SPECDIR=`rpm --eval "%{_specdir}"` |
| 27 |
GIT_DIR_NAME="${PWD##*/}" |
| 28 |
|
| 29 |
rm -fr ${DISTROROOT} |
| 30 |
cp -r ${DISTRODIR} ${DISTROROOT} |
| 31 |
echo "building ${SPEC_FILE} ..." |
| 32 |
if [ -d '.git' ] ; then |
| 33 |
VERSION=`head -n 1 ${VERSION_FILE}`+`date +git%Y%m%d` |
| 34 |
TAR_NAME=hime-${VERSION} |
| 35 |
git archive --format=tar --prefix=${TAR_NAME}/ HEAD | xz > ${SRCDIR}/${TAR_NAME}.tar.xz |
| 36 |
else |
| 37 |
VERSION=`head -n 1 ${VERSION_FILE}` |
| 38 |
XZ_OPT=${XZ_OPT-"-5e"} |
| 39 |
TAR_NAME=hime-${VERSION} |
| 40 |
cd .. |
| 41 |
cp -r $GIT_DIR_NAME $TAR_NAME |
| 42 |
tar --owner=0 --group=0 -Jcf "$TAR_NAME".tar.xz $TAR_NAME --exclude=.git |
| 43 |
cp ${TAR_NAME}.tar.xz ${SRCDIR}/${TAR_NAME}.tar.xz |
| 44 |
cd ${GIT_DIR_NAME} |
| 45 |
fi |
| 46 |
|
| 47 |
cd ${DISTROROOT} |
| 48 |
[ -f ${SPEC_FILE} ] && rm -f ${SPEC_FILE} |
| 49 |
sed -e "s/__hime_version__/${VERSION}/" < "${SPEC_FILE}.in" > ${SPEC_FILE} |
| 50 |
cp -f ${SPEC_FILE} ${SPECDIR}/${SPEC_FILE} |
| 51 |
cp -f hime.conf ${SRCDIR} |
| 52 |
rpmbuild -ba ${SPEC_FILE} |