/duilder (8acd6afdceefbb056b57e9d09a9943857800df8e) (10344 bytes) (mode 100755) (type blob)
#!/bin/bash
set -e
function duilder_docs()
{
PRJ="${1}"
VER="${2}"
EXPORT_PATH="${3}"
echo "Copying docs to [${EXPORT_PATH}]..."
for f in README License LICENSE Changelog TODO FAQ INSTALL; do
if [ -r "${f}" ]; then
cp -vp "${f}" "${EXPORT_PATH}/"
fi
done
if [ -d "screenshot" ]; then
echo "Copying screenshots..."
mkdir -p "${EXPORT_PATH}"
cp -vp screenshot/* "${EXPORT_PATH}/"
fi
}
function duilder_git()
{
PRJ="${1}"
GIT_DEST="${2}"
EXPORT_GIT="${3}"
EXPORT_PATH="${4}"
GIT_CHANGELOG="${5}"
if [ "${EXPORT_GIT}" != "1" ]; then
exit 0
fi
if [ ! -x /usr/bin/git ]; then
echo "Warning: Git not found!"
exit 0
fi
if [ ! -d .git ]; then
echo "Warning: I cannot find .git directory!"
exit 0
fi
if [ -z "${GIT_DEST}" ]; then
GIT_DEST="${EXPORT_PATH}"
fi
echo "Generate GIT tree for HTTP transport..."
if [ ! -d "${GIT_DEST}/${PRJ}.git" ]; then
git-clone --bare . "${GIT_DEST}/${PRJ}.git"
# Activate post-update hook
chmod a+x "${GIT_DEST}/${PRJ}.git/hooks/post-update"
# add project name and description
echo "${PRJ}" > "${GIT_DEST}/${PRJ}.git/description"
# allow export by git daemon?
#touch "${GIT_DEST}/${PRJ}.git/git-daemon-export-ok
else
# --force?
git-push -v --all "${GIT_DEST}/${PRJ}.git"
git-push -v --tags "${GIT_DEST}/${PRJ}.git"
fi
(cd "${GIT_DEST}/${PRJ}.git" && git-update-server-info)
if [ "${GIT_CHANGELOG}" = "1" ]; then
echo "[*] Generating Changelog from git..."
echo -n > Changelog
# get the list of tags
i=0
number_of_tags=0
for tag in `git-tag -l`; do
if [ "${tag:0:1}" != "v" ]; then
# skip other kind of tags beside versions
continue
fi
tags[${i}]=${tag}
tags_commit[${i}]=`git-show-ref ${tag} | cut -d' ' -f1`
number_of_tags=$[${number_of_tags}+1]
i=$[${i}+1]
done
# get the list of commits, test if is a tag and do the diff
prev=""
git-log --pretty=oneline | cut -f1 | \
while read commit junk; do
# test if it is a tag
tag=""
i=0
while [ "${i}" -lt "${number_of_tags}" ]; do
if [ "${commit}" = "${tags_commit[${i}]}" ]; then
tag="${tags[${i}]}"
break
fi
i=$[${i}+1]
done
if [ -z "${tag}" ]; then
continue
fi
if [ ! -z "${prev}" ]; then
echo "[*] Generating Changelog from ${tag} -> ${prev}..."
echo "[${tag} -> ${prev}]" >> Changelog
echo >> Changelog
git-shortlog ${tag}..${prev} | \
(IFS=""
while read line; do
echo " ${line}"
done) \
>> Changelog
echo >> Changelog
fi
prev=${tag}
done
fi
}
function duilder_srpm()
{
PRJ="${1}"
VER="${2}"
EXPORT_PATH="${3}"
BUILD_SRPM="${4}"
SRPM_DEST="${5}"
SRPM_POST_RUN="${6}"
P="${PRJ}-${VER}"
if [ "${BUILD_SRPM}" != "1" ]; then
exit 0
fi
echo "Building SRPM..."
rpmbuild -ts "${P}.tar.gz"
if [ -d ~/rpmbuild ]; then
PKG="${HOME}/rpmbuild/SRPMS/${P}-1.src.rpm"
else
PKG="/usr/src/redhat/SRPMS/${P}-1.src.rpm"
fi
if [ ! -z "${SRPM_DEST}" ]; then
echo "Copying [${PKG}] to [${SRPM_DEST}]..."
cp -vp "${PKG}" "${SRPM_DEST}/"
fi
echo "Copying to export dir [${EXPORT_PATH}]..."
mkdir -p "${EXPORT_PATH}"
cp -vp "${PKG}" "${EXPORT_PATH}/"
if [ -x "${SRPM_POST_RUN}" ]; then
echo "Running post SRPM build script [${SRPM_POST_RUN}]..."
${SRPM_POST_RUN} "${PKG}"
fi
}
function duilder_tar()
{
PRJ="${1}"
VER="${2}"
EXPORT_PATH="${3}"
EXCLUDE="${4}"
P="${PRJ}-${VER}"
echo "Generating tarball [${P}.tar.gz]..."
ADD_EXCLUDE=""
if [ ! -z "${EXCLUDE}" ]; then
ADD_EXCLUDE="--exclude-from ${EXCLUDE}"
fi
(cd .. && rm -f "${P}" && ln -s "${PRJ}" "${P}")
tar czhf "${P}.tar.gz" \
--exclude-vcs \
--exclude ./Makefile \
--exclude "${P}.tar.gz" \
${ADD_EXCLUDE} \
-C .. "${P}"
echo "Done generating tarball!"
rm -f "../${P}"
echo "Copying source to ${EXPORT_PATH}/..."
mkdir -p "${EXPORT_PATH}"
cp -vp "${P}.tar.gz" "${EXPORT_PATH}/"
}
####################################################################
# Multiplexer
if [ "${1}" = "docs" ]; then
shift
duilder_docs "$@"
exit $?
fi
if [ "${1}" = "tar" ]; then
shift
duilder_tar "$@"
exit $?
fi
if [ "${1}" = "git" ]; then
shift
duilder_git "$@"
exit $?
fi
if [ "${1}" = "srpm" ]; then
shift
duilder_srpm "$@"
exit $?
fi
if [ ! -r duilder.conf ]; then
echo "You must build a duilder.conf file!"
exit 1
fi
###### Main stuff
source ${PWD}/duilder.conf
if [ -z "${PRJ}" ]; then
echo "ERROR: PRJ= parameter is missing."
exit 1
fi
if [ -z "${VER}" ]; then
echo "ERROR: PRJ= parameter is missing."
exit 1
fi
if [ -z "${REV}" ]; then
echo "ERROR: REV= parameter is missing."
exit 1
fi
echo
echo "Duilder builder script"
echo "Copyright Catalin(ux) M BOIE"
echo
echo "PRJ=${PRJ}, VER=${VER}, REV=${REV}"
echo "System: `uname -a`"
ETC="/etc"
BIN="/bin"
USR_BIN="/usr/bin"
USR_SBIN="/usr/sbin"
USR_INCLUDE="/usr/include"
USR_LIB="/usr/lib"
USR_SHARE_DOC="/usr/share/doc/${PRJ}-${VER}"
SBIN="/usr/sbin"
VAR_LOG="/var/log/${PRJ}"
while [ "${1}" != "" ]; do
VAR="`echo ${1} | cut -d'=' -f1`"
VAL="`echo ${1} | cut -d'=' -f2`"
case ${VAR} in
--sysconfdir)
ETC="${VAL}"
;;
--bindir)
USR_BIN="${VAL}"
;;
--sbindir)
USR_SBIN="${VAL}"
;;
--includedir)
USR_INCLUDE="${VAL}"
;;
--libdir)
USR_LIB="${VAL}"
;;
esac
shift
done
# Truncate future sed file
> tmp.sed
DB_SUPPORT=0
echo -n "Searching for PostgreSQL..."
set +e
PG_VERSION="`pg_config --version 2>/dev/null`"
set -e
if [ -z "${PG_VERSION}" ]; then
echo " not found."
PG_FOUND=0
else
echo " found version ${PG_VERSION}."
PG_FOUND=1
PG_INC="-I`pg_config --includedir`"
PG_LIB="-L`pg_config --libdir` -lpq"
echo "s#@PG_VERSION@#${PG_VERSION}#g" >> tmp.sed
echo "s#@PG_INC@#${PG_INC}#g" >> tmp.sed
echo "s#@PG_LIB@#${PG_LIB}#g" >> tmp.sed
DB_SUPPORT=1
echo "s#@DB_SUPPORT@#${DB_SUPPORT}#g" >> tmp.sed
fi
echo "s#@PG_FOUND@#${PG_FOUND}#g" >> tmp.sed
echo -n "Searching for MySQL..."
set +e
MYSQL_VERSION="`mysql_config --version 2>/dev/null`"
set -e
if [ -z "${MYSQL_VERSION}" ]; then
echo " not found."
MYSQL_FOUND=0
else
echo " found version ${MYSQL_VERSION}."
MYSQL_FOUND=1
MYSQL_INC="`mysql_config --include`"
MYSQL_LIB="`mysql_config --libs`"
echo "s#@MYSQL_VERSION@#${MYSQL_VERSION}#g" >> tmp.sed
echo "s#@MYSQL_INC@#${MYSQL_INC}#g" >> tmp.sed
echo "s#@MYSQL_LIB@#${MYSQL_LIB}#g" >> tmp.sed
DB_SUPPORT=1
echo "s#@DB_SUPPORT@#${DB_SUPPORT}#g" >> tmp.sed
fi
echo "s#@MYSQL_FOUND@#${MYSQL_FOUND}#g" >> tmp.sed
echo -n "Searching for epoll..."
set +e
echo -e "#include <sys/epoll.h> \n int main(void) { return epoll_create(64); }" | gcc -x c -pipe - -o /dev/null 2>/dev/null
E="${?}"
set -e
if [ "${E}" != "0" ]; then
echo " not found."
echo "s#@EPOLL_FOUND@#0#g" >> tmp.sed
else
echo " found."
echo "s#@EPOLL_FOUND@#1#g" >> tmp.sed
fi
# generic stuff
echo "s#@PRJ@#${PRJ}#g" >> tmp.sed
echo "s#@VER@#${VER}#g" >> tmp.sed
echo "s#@REV@#${REV}#g" >> tmp.sed
echo "s#@DESCRIPTION@#${DESCRIPTION}#g" >> tmp.sed
echo "s#@ETC@#${ETC}#g" >> tmp.sed
echo "s#@BIN@#${BIN}#g" >> tmp.sed
echo "s#@USR_BIN@#${USR_BIN}#g" >> tmp.sed
echo "s#@SBIN@#${SBIN}#g" >> tmp.sed
echo "s#@USR_SBIN@#${USR_SBIN}#g" >> tmp.sed
echo "s#@VAR_LOG@#${VAR_LOG}#g" >> tmp.sed
echo "s#@USR_INCLUDE@#${USR_INCLUDE}#g" >> tmp.sed
echo "s#@USR_INC@#${USR_INCLUDE}#g" >> tmp.sed
echo "s#@USR_LIB@#${USR_LIB}#g" >> tmp.sed
echo "s#@USR_SHARE_DOC@#${USR_SHARE_DOC}#g" >> tmp.sed
# Export stuff
echo "s#@EXPORT_PATH@#${EXPORT_PATH}#g" >> tmp.sed
if [ -r Makefile.in ]; then
echo "Building Makefile..."
echo -n > Makefile
echo "# duilder header starts #" >> Makefile
echo "export PRJ := ${PRJ}" >> Makefile
echo "export VER := ${VER}" >> Makefile
echo "export REV := ${REV}" >> Makefile
echo "export DESTDIR" >> Makefile
echo >> Makefile
echo "export I_ETC := \$(DESTDIR)${ETC}" >> Makefile
echo "export I_BIN := \$(DESTDIR)${BIN}" >> Makefile
echo "export I_SBIN := \$(DESTDIR)${SBIN}" >> Makefile
echo "export I_USR_BIN := \$(DESTDIR)${USR_BIN}" >> Makefile
echo "export I_USR_SBIN := \$(DESTDIR)${USR_SBIN}" >> Makefile
echo "export I_USR_INCLUDE := \$(DESTDIR)${USR_INCLUDE}" >> Makefile
echo "export I_USR_INC := \$(DESTDIR)${USR_INCLUDE}" >> Makefile
echo "export I_USR_SHARE_DOC := \$(DESTDIR)${USR_SHARE_DOC}" >> Makefile
echo "export I_USR_LIB := \$(DESTDIR)${USR_LIB}" >> Makefile
echo "export I_LIB := \$(DESTDIR)${USR_LIB}" >> Makefile
echo "export I_VAR_LOG := \$(DESTDIR)${VAR_LOG}" >> Makefile
echo >> Makefile
echo "# DB stuff" >> Makefile
echo "export DB_SUPPORT := ${DB_SUPPORT}" >> Makefile
echo "# PG" >> Makefile
echo "export PG_FOUND := ${PG_FOUND}" >> Makefile
echo "export PG_INC := ${PG_INC}" >> Makefile
echo "export PG_LIB := ${PG_LIB}" >> Makefile
echo "# MySQL" >> Makefile
echo "export MYSQL_FOUND := ${MYSQL_FOUND}" >> Makefile
echo "export MYSQL_INC := ${MYSQL_INC}" >> Makefile
echo "export MYSQL_LIB := ${MYSQL_LIB}" >> Makefile
echo >> Makefile
echo "# duilder header ends #" >> Makefile
echo >> Makefile
sed -f tmp.sed Makefile.in >> Makefile
echo >> Makefile
echo "# duilder tail starts #" >> Makefile
echo >> Makefile
echo "# This is to allow exporting only the git tree" >> Makefile
echo "dist_git:" >> Makefile
echo " @./duilder git \"\$(PRJ)\" \"${GIT_DEST}\" \"${EXPORT_GIT}\" \"${EXPORT_PATH}\" \"${GIT_CHANGELOG}\"" >> Makefile
echo >> Makefile
echo ".PHONY: dist" >> Makefile
echo "dist: clean" >> Makefile
echo " @./duilder git \"\$(PRJ)\" \"${GIT_DEST}\" \"${EXPORT_GIT}\" \"${EXPORT_PATH}\" \"${GIT_CHANGELOG}\"" >> Makefile
echo " @./duilder tar \"\$(PRJ)\" \"\$(VER)\" \"${EXPORT_PATH}\" \"${EXCLUDE}\"" >> Makefile
echo " @./duilder srpm \"\$(PRJ)\" \"\$(VER)\" \"${EXPORT_PATH}\" \"${BUILD_SRPM}\" \"${SRPM_DEST}\" \"${SRPM_POST_RUN}\"" >> Makefile
echo " @./duilder docs \"\$(PRJ)\" \"\$(VER)\" \"${EXPORT_PATH}\"" >> Makefile
echo " @rm -f \"\$(PRJ)-\$(VER).tar.gz\"" >> Makefile
echo >> Makefile
fi
if [ -r "${PRJ}.spec.in" ]; then
echo "Generate .spec file..."
sed -f tmp.sed ${PRJ}.spec.in > ${PRJ}.spec
fi
if [ -r config.h.in ]; then
echo "Generate config.h file..."
sed -f tmp.sed config.h.in > config.h
fi
rm -f tmp.sed
if [ "`basename ${0}`" = "duilderx" ]; then
echo "Clone myself to destination as 'duilder'..."
cp -vpf "${0}" ${PWD}/duilder
fi
echo "Done. Run make."
Mode |
Type |
Size |
Ref |
File |
100644 |
blob |
70 |
9964a59b5d89f394cc4250ed6d6ce67a5f0cd196 |
.gitignore |
100644 |
blob |
1945 |
fecf0e7a7e8580485101a179685aedc7e00affbb |
Changelog.pre109 |
100644 |
blob |
30249 |
ceacb607291f1b9d26131f56d979d3e04c22e9b5 |
Conn.c |
100644 |
blob |
1470 |
afedf88dd9c3b275e9c7d83d6572c2fcce60e50b |
Conn.h |
100644 |
blob |
726 |
64b1bad93a84f87c3e93fc24ac5341db691ea578 |
Conn.spec.in |
100644 |
blob |
66 |
68138d781ca754b15e14c687da91ee261b2c41f3 |
Conn_config.h.in |
100644 |
blob |
27985 |
34e68f838096277281cdb368ad1c3ecc5cd04bc1 |
Conn_engine_core.c |
100644 |
blob |
9091 |
94b3b4cf54424d7a6e01f8a441c1c048b79cd595 |
Conn_engine_core.h |
100644 |
blob |
3687 |
8ae607cf9e14a6f9f1d9f17f468294660986e845 |
Conn_engine_epoll.c |
100644 |
blob |
601 |
b7631d5fc5487b502f02679b0d679661f87b4da9 |
Conn_engine_epoll.h |
100644 |
blob |
2677 |
e885b694fc0f55200ee50936966a2e40744ebf9b |
Conn_engine_poll.c |
100644 |
blob |
588 |
b518b20ac383c00b72e96a77a882c6b7ee953f6f |
Conn_engine_poll.h |
100644 |
blob |
30 |
d987fa5df957830331139935d517009e2911b0cf |
INSTALL |
100644 |
blob |
25275 |
92b8903ff3fea7f49ef5c041b67a087bca21c5ec |
LICENSE |
100644 |
blob |
1311 |
3c820df3b36b4bc844c52bc8c7e86f7843b67bb6 |
Makefile.in |
100644 |
blob |
192 |
5b11bdfb23857d8588845465aef993b320596b44 |
README |
100644 |
blob |
2101 |
c1d87e72d02403b09acd37ccc74da2ae122f7dcd |
TODO |
100755 |
blob |
23 |
d33bb6c4ecdce1390ce1db3c79ea3b93e22ea755 |
configure |
040000 |
tree |
- |
d4c9c4a69c5cfa2a84316967185f1661b6817779 |
docs |
100755 |
blob |
10344 |
8acd6afdceefbb056b57e9d09a9943857800df8e |
duilder |
100644 |
blob |
276 |
4163f35b9322fbbf5e9cade154d251b39878c43f |
duilder.conf |
040000 |
tree |
- |
c1f7bd01e5be435012e5a1eabdb1430467572ddd |
examples |
040000 |
tree |
- |
751693d0803f700dd060788cc9383aa24b472267 |
tests |
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"
Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/catalinux/Conn
Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/catalinux/Conn
Clone this repository using git:
git clone git://git.rocketgit.com/user/catalinux/Conn
You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a
merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main