commit aba1fd0f7e6e87048d3f27527ae2eaf052ab9467 Author: Juan Ferrer Toribio Date: Wed May 3 13:47:34 2017 +0200 Initial commit diff --git a/aclocal/dev-tools.m4 b/aclocal/dev-tools.m4 new file mode 100644 index 0000000..6791a88 --- /dev/null +++ b/aclocal/dev-tools.m4 @@ -0,0 +1,68 @@ +dnl +dnl Copyright (C) 2012 - Juan Ferrer Toribio +dnl +dnl This program is free software: you can redistribute it and/or modify +dnl it under the terms of the GNU General Public License as published by +dnl the Free Software Foundation, either version 3 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with this program. If not, see . +dnl + +# serial 3 dev-tools + +AC_DEFUN([VN_BUILD_OPTIONS], +[ + case $CFLAGS in + *-W*) ;; + *)CFLAGS+=" -Wall ";; + esac + + # Check for debug mode + AC_MSG_CHECKING([whether to build with debug information...]) + AC_ARG_ENABLE([debug], + [AS_HELP_STRING([--enable-debug], + [Enable debug data generation [default = no]])], + [ENABLE_DEBUG="$enableval"], + [ENABLE_DEBUG=no]) + AC_MSG_RESULT([$ENABLE_DEBUG]) + + case $CFLAGS in + *-g*) ;; + *) + if test x"$ENABLE_DEBUG" = x"yes"; then + CFLAGS+=" -ggdb " + fi + ;; + esac + + # Check if the package must be configured to be installed + AC_MSG_CHECKING([whether to configure to install...]) + AC_ARG_ENABLE([install], + [AS_HELP_STRING([--enable-install], + [Enable install configuration [default = yes]])], + [ENABLE_INSTALL="$enableval"], + [ENABLE_INSTALL=yes]) + AC_MSG_RESULT([$installit]) + AM_CONDITIONAL(ENABLE_INSTALL, [test x"$ENABLE_INSTALL" = x"yes"]) + + case $CFLAGS in + *-O*) ;; + *) + if test x"$ENABLE_INSTALL" = x"yes"; then + CFLAGS+=" -O3" + fi + ;; + esac + + AC_SUBST([ENABLE_DEBUG]) + AC_SUBST([ENABLE_INSTALL]) + AC_SUBST([CFLAGS]) +]) + diff --git a/bin/dev-autoclean b/bin/dev-autoclean new file mode 100755 index 0000000..ea35659 --- /dev/null +++ b/bin/dev-autoclean @@ -0,0 +1,23 @@ +#!/bin/bash + +dir=$1 + +if [ -z "$dir" ] +then + echo "Usage: $0 source_directory" + exit 1 +fi + +if [ ! -r $dir/configure.ac ] +then + echo "$0: Invalid source directory: $dir" + exit 2 +fi + +rm -rf $dir/build +rm -rf $dir/configure +rm -rf $dir/gtk-doc.make +rm -rf $dir/aclocal.m4 +rm -rf $dir/autom4te.cache +rm -rf $dir/po/Makefile.in.in +rm -rf `find $dir -name Makefile.in` diff --git a/bin/dev-debuild b/bin/dev-debuild new file mode 100755 index 0000000..d515c09 --- /dev/null +++ b/bin/dev-debuild @@ -0,0 +1,118 @@ +#!/bin/bash + +usage () +{ + echo "Usage: $0 [-c codename] [-f] [-k] source_directory" + exit 1 +} + +. /usr/share/dev-tools/load-config + +forceDebuild=0 + +while getopts ":c:fk" option +do + case $option in + f) + forceDebuild=1 + ;; + k) + keep=1 + ;; + \?|:) + usage + ;; + esac +done + +shift $(($OPTIND - 1)) + +dir=$1 + +if [ ! $dir ] +then + usage +fi + +if [ -r $dir/debian/rules ] +then + packageDir=$dir/.. + + if [ "$forceDebuild" -eq "0" ] + then + if [ -r $dir/debian/files ] + then + cut -d" " -f1 $dir/debian/files | + while read package + do + if [ -z "$package" ] + then + continue + fi + + if [ ! -r $packageDir/$package ] + then + forceDebuild=1 + break + fi + done + else + forceDebuild=1 + fi + fi + + if [ "$forceDebuild" -ne "0" ] + then + (cd $dir && debuild -uc -us -b) + + if [ "$?" -ne "0" ] + then + echo "$0: Error while generating debian packages" + exit 3 + fi + fi + + cut -d" " -f1 $dir/debian/files | + while read package + do + if [[ ! $package =~ .*\.deb$ ]] + then + continue + fi + + /usr/bin/dev-upload -c $codename $packageDir/$package + + if [ "$keep" -eq "0" ] + then + rm -f $packageDir/$package + fi + done + + if [ "$keep" -eq "0" ] + then + rm -f $packageDir/*.build + rm -f $packageDir/*.changes + + (cd $dir && fakeroot debian/rules clean) + fi +elif [ -r $dir/DEBIAN/control ] +then + tmpDir=$dir/.. + + fakeroot dpkg -b $dir $tmpDir + package=`ls $tmpDir/*.deb` + + if [ "$?" -eq "0" ] + then + /usr/bin/dev-upload -c $codename $package + + if [ "$keep" -eq "0" ] + then + rm -f $package + fi + fi +else + echo "$0: Invalid source directory: $dir" + exit 2 +fi + diff --git a/bin/dev-mkconfig b/bin/dev-mkconfig new file mode 100755 index 0000000..1550015 --- /dev/null +++ b/bin/dev-mkconfig @@ -0,0 +1,16 @@ +#!/bin/bash + +configDir=$HOME/.config/dev-tools +configFile=$configDir/config +configTemplate=/usr/share/dev-tools/config.template + +if [ ! -d $configDir ] +then + mkdir -p $configDir +fi + +if [ ! -r $configFile ] +then + cp $configTemplate $configFile + echo "Configuration generated: $configFile" +fi diff --git a/bin/dev-upload b/bin/dev-upload new file mode 100755 index 0000000..613e280 --- /dev/null +++ b/bin/dev-upload @@ -0,0 +1,67 @@ +#!/bin/bash + +# Checking the input arguments. + +usage () +{ + echo "Usage: $0 [-c codename] packages" + exit 1 +} + +. /usr/share/dev-tools/load-config + +while getopts ":c:" option +do + case $option in + \?|:) + usage + ;; + esac +done + +shift $(($OPTIND - 1)) + +if [ ! $1 ] +then + usage +fi + +# Checking that all files exist. + +for package in $@ +do + if [ ! -r $package ] + then + echo "$0: File doesn't exists: $package" + exit 2 + fi +done + +# Checking that SSH key file exists. + +if [ ! -r $sshKeyFile ] +then + echo "$0: Can't find the SSH key file: $sshKeyFile" + exit 3 +fi + +# Uploading and adding the packages to the repository. + +for package in $@ +do + dest=/tmp/`basename $package` + + scp -i $sshKeyFile $package $sshUser@$sshHost:$dest + + if [ "$?" -eq "0" ] + then + ssh $sshHost -n -i $sshKeyFile -l $sshUser \ + "reprepro -b $repoDir includedeb $codename $dest; rm -f $dest" + else + echo "An error occurred uploading the package $package" + exit 4 + fi +done + +#echo "Press any key to continue..." +#read -n 0 -ers diff --git a/copyright.txt b/copyright.txt new file mode 100755 index 0000000..7b19ad2 --- /dev/null +++ b/copyright.txt @@ -0,0 +1,17 @@ +Copyright (C) 2017 - Juan Ferrer Toribio + +This package is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . + +On Debian systems, the complete text of the GNU General Public +License can be found in "/usr/share/common-licenses/GPL-3". diff --git a/data/config.template b/data/config.template new file mode 100644 index 0000000..466bc12 --- /dev/null +++ b/data/config.template @@ -0,0 +1,20 @@ +#!/bin/bash + +# The respository hostname to access via SSH +sshHost=localhost + +# The SSH user to access to the repository +sshUser=$USER + +# Location of the SSH private key used for authentication +sshKeyFile=$HOME/.ssh/id_rsa + +# The directory where repository is allocated on the remote host +repoDir=/var/cache/reprepro + +# The default codename if none is specified +codename=stable + +# Whether to keep generated files +keep=0 + diff --git a/data/load-config b/data/load-config new file mode 100755 index 0000000..552dfba --- /dev/null +++ b/data/load-config @@ -0,0 +1,43 @@ +#!/bin/bash + +. /usr/bin/dev-mkconfig + +. $configFile + +while getopts ":c:" option +do + case $option in + c) + codename=$OPTARG + ;; + esac +done + +OPTIND=1 + +# Setting default values for undefined variables. + +if [ -z "$sshHost" ] +then + sshHost=localhost +fi +if [ -z "$sshUser" ] +then + sshUser=$USER +fi +if [ -z "$sshKeyFile" ] +then + sshKeyFile=$HOME/.ssh/id_rsa +fi +if [ -z "$repoDir" ] +then + repoDir=/var/cache/reprepro +fi +if [ -z "$codename" ] +then + codename=testing +fi +if [ -z "$keep" ] +then + keep=0 +fi diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..bf30316 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +dev-tools (2.0.2) stable; urgency=low + + * Initial Release. + + -- Juan Ferrer Toribio Wed, 19 Aug 2015 12:00:00 +0200 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..f11c82a --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +9 \ No newline at end of file diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..77d3504 --- /dev/null +++ b/debian/control @@ -0,0 +1,16 @@ +Source: dev-tools +Priority: optional +Maintainer: Juan Ferrer Toribio +Build-Depends: build-essential, debhelper +Standards-Version: 3.9.3 +Section: misc +Homepage: http://verdnatura.es +Vcs-Git: git://git.verdnatura.es/var/git/dev-tools + +Package: dev-tools +Architecture: all +Depends: coreutils, openssh-client, devscripts +Section: misc +Priority: optional +Description: Tools for developers of Debian packages + Tools and scripts for developers of Debian packages. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..fb8cb07 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,24 @@ +Format: http://dep.debian.net/deps/dep5 +Name: dev-tools +Source: git://git.verdnatura.es/var/git/dev-tools + +Files: * +Copyright: 2011-2015 Juan Ferrer Toribio +License: GPL-3.0+ + +License: GPL-3.0+ + This package is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + . + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + . + You should have received a copy of the GNU General Public License + along with this program. If not, see . + . + On Debian systems, the complete text of the GNU General Public + License can be found in "/usr/share/common-licenses/GPL-3". diff --git a/debian/install b/debian/install new file mode 100644 index 0000000..06ec2a2 --- /dev/null +++ b/debian/install @@ -0,0 +1,4 @@ +bin/* usr/bin +git-hooks/* usr/bin +data/* usr/share/dev-tools +aclocal/* usr/share/aclocal diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..abde6ef --- /dev/null +++ b/debian/rules @@ -0,0 +1,5 @@ +#!/usr/bin/make -f + +%: + dh $@ + diff --git a/git-hooks/hook-debuild b/git-hooks/hook-debuild new file mode 100755 index 0000000..43c212e --- /dev/null +++ b/git-hooks/hook-debuild @@ -0,0 +1,46 @@ +#!/bin/bash + +repreproDir="/var/cache/reprepro" +codename="stable" + +while read oldrev newrev ref +do + if [[ ! $ref =~ .*/master$ ]] + then + echo "Ref $ref received. Doing nothing." + continue + fi + + echo "Master ref received. Deploying master branch to production." + + buildDir="/tmp/git-deploy/$newrev" + srcDir="$buildDir/src" + + echo "Exporting to a temporary directory." + + rm -rf "$buildDir" + mkdir -p "$srcDir" + git --work-tree="$srcDir" --git-dir="$PWD" checkout -f + + echo "Building Debian packages." + + (cd $srcDir && debuild -uc -us -b) + + echo "Uploading Debian packages." + + cut -d" " -f1 $srcDir/debian/files | + while read debFile + do + if [[ ! $debFile =~ .*\.deb$ ]] + then + continue + fi + + echo "Uploading $debFile." + reprepro -b $repreproDir includedeb $codename "$buildDir/$debFile" + done + + echo "Cleaning temporary directory." + + rm -rf "$buildDir" +done