diff --git a/debian/changelog b/debian/changelog index 81d9bd3..f8ef966 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,5 +1,5 @@ -quicktile (0.4.0gtk3-1) UNRELEASED; urgency=medium +quicktile (0.4-1) UNRELEASED; urgency=medium * First Debian package. - -- Stéphane Gourichon Wed, 01 Jan 2020 17:57:34 +0100 + -- Stéphane Gourichon Tue, 11 Feb 2020 18:04:27 +0100 diff --git a/debian/control b/debian/control index b14539f..d8a0469 100644 --- a/debian/control +++ b/debian/control @@ -15,7 +15,10 @@ Build-Depends: debhelper (>= 9), python3-dbus, gir1.2-gtk-3.0, gir1.2-wnck-3.0, - gir1.2-glib-2.0 + gir1.2-glib-2.0, + python3-sphinx, + python3-sphinx-autodoc-typehints, + python3-sphinxcontrib.autoprogram Standards-Version: 4.4.0 Package: quicktile diff --git a/debian/docs b/debian/docs index d1b9b51..2d2dae2 100644 --- a/debian/docs +++ b/debian/docs @@ -1 +1,2 @@ -quicktile +docs/_build/html +README.rst diff --git a/debian/manpages b/debian/manpages new file mode 100644 index 0000000..531aa29 --- /dev/null +++ b/debian/manpages @@ -0,0 +1 @@ +docs/_build/man/quicktile.1 diff --git a/debian/rules b/debian/rules index 1e9c5e1..bebcf8d 100755 --- a/debian/rules +++ b/debian/rules @@ -23,3 +23,11 @@ include /usr/share/dpkg/default.mk override_dh_auto_install: dh_auto_install install -D quicktile.desktop debian/quicktile/etc/xdg/autostart/quicktile.desktop + +override_dh_installdocs: + ( cd docs ; env PATH=$$HOME/.local/bin/:$$PATH make html ; ) + dh_installdocs + +override_dh_installman: + ( cd docs ; env PATH=$$HOME/.local/bin/:$$PATH make man ; ) + dh_installman diff --git a/recompile_local_debian_package.sh b/recompile_local_debian_package.sh old mode 100644 new mode 100755 index 6910e7d..599f0de --- a/recompile_local_debian_package.sh +++ b/recompile_local_debian_package.sh @@ -5,8 +5,8 @@ cat < ======================================================================== -Let's go! - EOF set -euo pipefail -cd "$(dirname "$(readlink -f "$0")" )" +cd "$(dirname "$0" )" +PKGDIR="$PWD" -dpkg-checkbuilddeps -echo -e "* dpkg-checkbuilddeps\tPASSED" +# necessary for install_package_if_missing and build_locally +BECOMEROOT="" +if [[ "$(id -u)" != "0" ]] ; then BECOMEROOT="sudo" ; fi -PKGDIR="$PWD" +APT_COMMAND_LINE="apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends -y" -TMPDIR=$( mktemp -d ) && echo "* Will work in temp dir $TMPDIR" +function install_package_if_missing() +{ + local PKGTOINSTALL + PKGTOINSTALL=() + for PKGNAME + do + if ! dpkg-query -W -f'${Status}' "$PKGNAME" 2>/dev/null | grep -q "ok installed" + then + PKGTOINSTALL+=( "$PKGNAME" ) + echo "Scheduling to install $PKGNAME" + fi + done -CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) && echo "* Current git branch $CURRENT_BRANCH" + if [[ "${#PKGTOINSTALL[@]}" = "0" ]] + then + return 0 + fi -NAMEFORTAR="$( head -n 1 debian/changelog | sed -n 's/^\([^ ]*\)* (\([^-]*\)-[0-9]*).*$/\1_\2/p' )" -DIRNAMEFORDEB=${NAMEFORTAR//_/-} + echo will install "${#PKGTOINSTALL[@]}" + printf "* %s\n" "${PKGTOINSTALL[@]}" -if [[ -z "$NAMEFORTAR" ]] -then - echo >&2 "Cannot figure out tar archive name from first line of debian/changelog. Aborting" - head -n 1 debian/changelog - exit 1 -fi + if [[ -z "${DID_APT_GET_UPDATE:-}" ]] + then + ${BECOMEROOT:-} apt-get update + fi -if output=$(git status --porcelain) && [ -z "$output" ]; then - echo "Working directory clean" -else - echo >&2 "WARNING: uncommitted changes. Consider aborting." - git status - echo >&2 "WARNING: uncommitted changes. Consider aborting." - echo >&2 "Waiting for 10 second." - sleep 10 -fi + # shellcheck disable=SC2086 + # APT_COMMAND_LINE intentionally contains space-separated arguments + ${BECOMEROOT:-} $APT_COMMAND_LINE install "${PKGTOINSTALL[@]}" +} + +function build_locally() +{ + TMPDIR=$( mktemp -d ) && echo "* Will work in temp dir $TMPDIR" + + if + [[ "${no_cleanup:-}" == "rue" ]] + then + # shellcheck disable=SC2064 + # TMPDIR is indeed intended to be expanded at the time this line is executed, not at trap time. + trap "echo rm -rf ${TMPDIR:?}" EXIT + fi + + install_package_if_missing dpkg-dev git + + pwd + + if dpkg-checkbuilddeps 2>/dev/null + then + echo -e "* dpkg-checkbuilddeps\tPASSED" + else + echo -e "* dpkg-checkbuilddeps asks for more packages" + install_package_if_missing equivs devscripts + ( cd "$TMPDIR" ; \ + mk-build-deps -i -t "$APT_COMMAND_LINE" \ + "$PKGDIR/debian/control" \ + -s "${BECOMEROOT:-}" ; + ) + echo -e "* dpkg-checkbuilddeps\tPASSED" + fi + + if [[ "${1:-}" == "deps_only" ]] +# if [[ "${local_install_deps_only:-}" == "true" ]] + then + echo "Install-only pass, returning now." + return 0 + fi + + CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) && echo "* Current git branch $CURRENT_BRANCH" + + NAMEFORTAR="$( head -n 1 debian/changelog | sed -n 's/^\([^ ]*\)* (\([^)]*\)).*$/\1_\2/p' )" + DIRNAMEFORDEB=${NAMEFORTAR//_/-} + + if [[ -z "$NAMEFORTAR" ]] + then + echo >&2 "Cannot figure out tar archive name from first line of debian/changelog. Aborting" + head -n 1 debian/changelog + exit 1 + fi + + if output=$(git status --porcelain) && [ -z "$output" ]; then + echo "Working directory clean" + else + echo >&2 "WARNING: uncommitted changes. Consider aborting." + git status + echo >&2 "WARNING: uncommitted changes. Consider aborting." + echo >&2 "Waiting for 10 second." + #sleep 10 + fi + + GITREV=$( git describe ) + + cd "$TMPDIR" + git clone "$PKGDIR" "${DIRNAMEFORDEB}" + + tar zcf "${NAMEFORTAR}.orig.tar.gz" "${DIRNAMEFORDEB}" + cd "${DIRNAMEFORDEB}" -GITREV=$( git describe ) + dpkg-checkbuilddeps + debuild -us -uc -cd "$TMPDIR" -git clone "$PKGDIR" "${DIRNAMEFORDEB}" + . /etc/os-release ; DISTRO_ID="${ID}-${VERSION_ID}" -tar zcvf ${NAMEFORTAR}.orig.tar.gz "${DIRNAMEFORDEB}" -cd "${DIRNAMEFORDEB}" + OUTDIR="$PKGDIR/../compiled_packages/${DISTRO_ID}/${NAMEFORTAR}" #_$( date +%Yy%mm%dd_%Hh%Mm%Ss )" -dpkg-checkbuilddeps -debuild -us -uc + mkdir -p "$OUTDIR" -. /etc/os-release ; DISTRO_ID="${ID}-${VERSION_ID}" + echo "generated from git commit $GITREV" >"${OUTDIR}/${NAMEFORTAR}.gitversion" -OUTDIR="$PKGDIR/../compiled_packages/${DISTRO_ID}/${NAMEFORTAR}" #_$( date +%Yy%mm%dd_%Hh%Mm%Ss )" + cd .. -mkdir -p "$OUTDIR" + cp -v "${NAMEFORTAR}"?* "$OUTDIR" -echo "generated from git commit $GITREV" >"${OUTDIR}/${NAMEFORTAR}.gitversion" + echo + echo ================================================================ + echo "Artifacts available in $OUTDIR:" + echo "OUTDIR=$OUTDIR" + echo ================================================================ -cd .. + cd "$OUTDIR" + + ls -al +} + +function build_in_docker() +{ + OSIMAGE="$1" + + # By default, files generated in Docker have same owner as user inside docker. + # So, let's make sure there is a matching user inside the docker container. + + docker run -it -v "$PKGDIR/..":/up "$OSIMAGE" \ + bash -c " +cd /up/*/debian/source ; cd ../.. +bash recompile_local_debian_package.sh --install-deps-only +USER=$(id -un) ; userdel \"\$USER\" +GID=$(id -g) ; groupadd -f -g \$GID $(id -gn) +useradd -u $(id -u) --gid stephane -l -m \"\$USER\" -s /bin/bash +grep -H stephane /etc/*passwd +grep -H stephane /etc/*group +set -xv ; su - \$USER -- \$PWD/recompile_local_debian_package.sh --local +" +} + +function usage() +{ + cat < + +In practice, Debian hosts can create Debian packages, Ubuntu hosts can create Ubuntu and Debian package. + +------------------------------------------------------------------------ +EOF +} + +if [[ "$#" == 0 ]] +then + echo -e >&2 "No argument provided. Exiting.\n" + usage + exit 1 +fi -cp -v "${NAMEFORTAR}"?* "$OUTDIR" +while [[ "$#" -gt 0 ]] +do + ARG="$1" + shift -echo -echo ================================================================ -echo "Artifacts available in $OUTDIR:" -echo "OUTDIR=$OUTDIR" -echo ================================================================ + case "$ARG" in + --no-cleanup) + # Generic code for option handling + ARGSHORT="${ARG#--}" + ARGSHORT="${ARGSHORT//-/_}" + declare -n ARGVAR="${ARGSHORT}" + VALUE=true + echo "Seeing option: $ARG to $VALUE" -cd "$OUTDIR" + # The line below actually sets a variable named from the + # option, e.g. "ARGVAR=$VALUE" does "no_cleanup=true" due + # to the feature "nameref attribute" of bash, enabled by + # "declare -n" above. + # + # Therefore: + # + # shellcheck disable=SC2034 + ARGVAR=$VALUE + unset ARGVAR + ;; + --install-deps-only) + build_locally deps_only + ;; + --local) + build_locally + ;; + --docker) + OSIMAGE="${1:-}" + if [[ -z "$OSIMAGE" ]] + then + . /etc/os-release ; DISTRO_ID="${ID}:${VERSION_ID}" + echo -e >&2 "--docker argument needs a parameter.\n" \ + "Please provide a docker base image name for the target OS of your \n" \ + "build package.\nExample: --docker ${ID}:${VERSION_ID}" + exit 1 + fi + shift + build_in_docker "$OSIMAGE" + ;; + *) + echo >&2 "Error: unknown option $ARG" + usage + exit 1 + esac +done -ls -al +exit 0