Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

debian package build #6

Merged
merged 12 commits into from Sep 21, 2019
61 changes: 45 additions & 16 deletions packaging/build_deb
@@ -1,25 +1,54 @@
#!/bin/bash -xe
#!/bin/bash
#
# This script is for generating libsxg-*.*.deb by CI.
kumagi marked this conversation as resolved.
Show resolved Hide resolved
# It generates .deb file and copy it to the current directory.
# Execute this shell-script at root directory of libsxg project.
kumagi marked this conversation as resolved.
Show resolved Hide resolved
set -ex

SRCDIR=$(pwd)
WORKDIR=$(mktemp -d)
readonly SRCDIR="${PWD}"
readonly WORKDIR="$(mktemp -d)"
kumagi marked this conversation as resolved.
Show resolved Hide resolved
readonly NAME='libsxg'
readonly VERSION='0.1'
readonly TARNAME="${NAME}-${VERSION}"
readonly TARGET_NAME='libsxg-dev'
readonly ARCHITECTURE="$(dpkg --print-architecture)"

NAME="libsxg"
VERSION="0.1"
TARNAME="${NAME}-${VERSION}"
TARGET_NAME="libsxg-dev"
ARCHITECTURE=$(dpkg --print-architecture)
git archive --format=tar.gz --output="${WORKDIR}/${TARNAME}.tar.gz" -v master \
kumagi marked this conversation as resolved.
Show resolved Hide resolved
kumagi marked this conversation as resolved.
Show resolved Hide resolved
--prefix="${TARNAME}/" 2> /dev/null

echo "Working in ${WORKDIR}"
kumagi marked this conversation as resolved.
Show resolved Hide resolved
git archive --format=tar.gz --output="${TARNAME}.tar.gz" -v HEAD \
--prefix="${TARNAME}/" 2> /dev/null
mv "${TARNAME}.tar.gz" "${WORKDIR}"
pushd "${WORKDIR}"
cd "${WORKDIR}"

tar xf "${TARNAME}.tar.gz"
if [[ $? -ne 0 ]]; then
kumagi marked this conversation as resolved.
Show resolved Hide resolved
echo "Unable to decompress ${TARNAME}.tar.gz" >&2
exit 1
fi

cp "${TARNAME}.tar.gz" "${NAME}_${VERSION}.orig.tar.gz"
cp -r "${SRCDIR}/packaging/debian" "${TARNAME}"
pushd "${TARNAME}"
if [[ $? -ne 0 ]]; then
echo "Unable to copy ${TARNAME}.tar.gz to ${NAME}_${VERSION}.orig.tar.gz" >&2
exit 1
fi
cd "${TARNAME}"

cp -r "${SRCDIR}/packaging/debian" .
kumagi marked this conversation as resolved.
Show resolved Hide resolved
if [[ $? -ne 0 ]]; then
echo "Unable to copy ${SRCDIR}/packaging/debian to ${WORKDIR}/${TARNAME}" >&2
exit 1
fi

debuild --no-tgz-check -uc -us -b
kumagi marked this conversation as resolved.
Show resolved Hide resolved
if [[ $? -ne 0 ]]; then
echo "Failed on debuild" >&2
exit 1
fi

cp "../${TARGET_NAME}_${VERSION}_${ARCHITECTURE}.deb" "${SRCDIR}"
popd
popd
if [[ $? -ne 0 ]]; then
echo "Unable to copy ${TARGET_NAME}_${VERSION}_${ARCHITECTURE}.deb to ${SRCDIR}" >&2
exit 1
fi

rm -rf "${WORKDIR}"
kumagi marked this conversation as resolved.
Show resolved Hide resolved

kumagi marked this conversation as resolved.
Show resolved Hide resolved