Initial commit
This commit is contained in:
commit
d74153f706
|
@ -0,0 +1,5 @@
|
|||
vn-repo (2.0.2) stable; urgency=low
|
||||
|
||||
* Initial Release.
|
||||
|
||||
-- Juan Ferrer Toribio <juan@verdnatura.es> Wed, 19 Aug 2015 12:00:00 +0200
|
|
@ -0,0 +1 @@
|
|||
9
|
|
@ -0,0 +1,17 @@
|
|||
Source: vn-repo
|
||||
Priority: optional
|
||||
Maintainer: Juan Ferrer Toribio <juan@verdnatura.es>
|
||||
Build-Depends: build-essential, debhelper
|
||||
Standards-Version: 3.9.3
|
||||
Section: misc
|
||||
Homepage: https://www.verdnatura.es
|
||||
Vcs-Git: https://git.verdnatura.es/vn-repo
|
||||
|
||||
Package: vn-repo
|
||||
Architecture: all
|
||||
Depends: reprepro, git, sudo, devscripts
|
||||
Suggests: apache2 | httpd, git, gitweb, gitweb-theme, nodejs
|
||||
Section: vcs
|
||||
Priority: optional
|
||||
Description: Helper to set up a repository
|
||||
Prepares the system to host a Git and APT repository.
|
|
@ -0,0 +1,24 @@
|
|||
Format: http://dep.debian.net/deps/dep5
|
||||
Name: vn-repo
|
||||
Source: https://git.verdnatura.es/vn-repo
|
||||
|
||||
Files: *
|
||||
Copyright: 2011-2015 Juan Ferrer Toribio <juan@verdnatura.es>
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
.
|
||||
On Debian systems, the complete text of the GNU General Public
|
||||
License can be found in "/usr/share/common-licenses/GPL-3".
|
|
@ -0,0 +1,2 @@
|
|||
MAILTO=hostmaster
|
||||
#*/1 * * * * vn-repo (cd && vn-rcheck)
|
|
@ -0,0 +1,6 @@
|
|||
vn-repo.conf etc/apache2/conf-available
|
||||
git-hooks/post-receive usr/bin
|
||||
vn-branch usr/bin
|
||||
vn-deploy usr/bin
|
||||
vn-debuild usr/bin
|
||||
vn-rcheck usr/bin
|
|
@ -0,0 +1,14 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Adds the repository user
|
||||
|
||||
useradd --shell /bin/bash --home-dir /var/cache/reprepro --create-home vn-repo
|
||||
|
||||
# Enables Apache configuration
|
||||
|
||||
if [ -e /usr/share/apache2/apache2-maintscript-helper ]
|
||||
then
|
||||
. /usr/share/apache2/apache2-maintscript-helper
|
||||
apache2_invoke enconf vn-repo.conf
|
||||
fi
|
|
@ -0,0 +1,14 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Removes the repository user
|
||||
|
||||
userdel vn-repo
|
||||
|
||||
# Enables Apache configuration
|
||||
|
||||
if [ -e /usr/share/apache2/apache2-maintscript-helper ]
|
||||
then
|
||||
. /usr/share/apache2/apache2-maintscript-helper
|
||||
apache2_invoke disconf vn-repo.conf
|
||||
fi
|
|
@ -0,0 +1,5 @@
|
|||
#!/usr/bin/make -f
|
||||
|
||||
%:
|
||||
dh $@
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
vn-debuild
|
||||
vn-deploy www1.static www2.static
|
|
@ -0,0 +1,20 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
while read oldrev newrev ref
|
||||
do
|
||||
if [[ ! $ref =~ .*/master$ ]]
|
||||
then
|
||||
continue
|
||||
fi
|
||||
|
||||
myHost=$(hostname)
|
||||
repoDir=$(dirname "$0")/..
|
||||
projectName=$(basename "$(realpath "$repoDir")")
|
||||
|
||||
echo "Ref $ref received. It will be deployed automatically."
|
||||
echo "Host $myHost"
|
||||
|
||||
echo "$projectName" "master" > /tmp/vn-repo.changes
|
||||
#nohup sudo -u vn-repo "vn-branch $projectName" &> /dev/null &
|
||||
done
|
|
@ -0,0 +1,21 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
if [ "$#" -eq "0" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
projectName=$1
|
||||
repoDir="/var/lib/git/$projectName"
|
||||
srcDir="/tmp/vn-repo/$projectName/src"
|
||||
logFile="/var/cache/reprepro/logs/$projectName.out"
|
||||
|
||||
rm -f "$logFile"
|
||||
|
||||
mkdir -p "$srcDir"
|
||||
git --work-tree="$srcDir" --git-dir="$repoDir" checkout -f
|
||||
|
||||
if [ -f "$srcDir/deploy" ]
|
||||
then
|
||||
(cd "$srcDir" && "$srcDir/deploy" >> "$logFile")
|
||||
fi
|
|
@ -0,0 +1,50 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
if [ "$#" -eq "0" ]; then
|
||||
srcDir="$PWD"
|
||||
else
|
||||
srcDir="$1"
|
||||
fi
|
||||
|
||||
buildDir="$srcDir/.."
|
||||
repreproDir="/var/cache/reprepro"
|
||||
codename="stable"
|
||||
|
||||
echo "Building source code."
|
||||
echo " * Directory $buildDir"
|
||||
|
||||
if [ -f "$srcDir/package.json" ]
|
||||
then
|
||||
echo "Installing Node dependencies."
|
||||
(cd "$srcDir" && npm --silent install)
|
||||
fi
|
||||
|
||||
if [ -f "$srcDir/debian/changelog" ]
|
||||
then
|
||||
echo "Cleaning last build."
|
||||
rm -f $buildDir/*.deb
|
||||
rm -f $buildDir/*.changes
|
||||
rm -f $buildDir/*.build
|
||||
(cd "$srcDir" && debian/rules clean)
|
||||
|
||||
echo "Building Debian packages."
|
||||
(cd "$srcDir" && debuild -uc -us -b)
|
||||
|
||||
echo "Adding packages to repository."
|
||||
|
||||
cut -d" " -f1 "$srcDir/debian/files" |
|
||||
while read debFile
|
||||
do
|
||||
if [[ ! "$debFile" =~ .*\.deb$ ]]
|
||||
then
|
||||
continue
|
||||
fi
|
||||
|
||||
echo " * Adding $debFile"
|
||||
reprepro -b "$repreproDir" includedeb $codename "$buildDir/$debFile"
|
||||
done
|
||||
else
|
||||
echo "$0: Invalid source directory: $srcDir"
|
||||
exit 2
|
||||
fi
|
|
@ -0,0 +1,35 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
hosts=$1
|
||||
|
||||
if [ -z "$hosts" ]
|
||||
then
|
||||
echo "Usage: $(basename $0) host1 [host2]..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
packages=""
|
||||
|
||||
cut -d" " -f1 "$srcDir/debian/files" |
|
||||
while read debFile
|
||||
do
|
||||
packageName=$(echo $debFile | cut -d"_" -f1)
|
||||
packages="$packages $packageName"
|
||||
done
|
||||
|
||||
if [ -z "$packages" ]
|
||||
then
|
||||
echo "No packages found to install"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# FIXME: Packages are not upgraded when config files are changed
|
||||
|
||||
echo "Upgrading servers."
|
||||
|
||||
for host in $hosts
|
||||
do
|
||||
echo " * Upgrading $host"
|
||||
ssh root@$host "update-repo vn && apt-get install $packages"
|
||||
done
|
|
@ -0,0 +1,21 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
changesFile="/tmp/vn-repo.changes"
|
||||
|
||||
(
|
||||
flock -n 200 || exit
|
||||
|
||||
if [ -f "$changesFile" ]
|
||||
then
|
||||
while read -r line
|
||||
do
|
||||
projectName=$(echo $line | cut -d" " -f1)
|
||||
branch=$(echo $line | cut -d" " -f2)
|
||||
|
||||
vn-branch $projectName
|
||||
done < "$changesFile"
|
||||
|
||||
rm $changesFile
|
||||
fi
|
||||
) 200> /var/lock/vn-repo.lock
|
|
@ -0,0 +1,8 @@
|
|||
#Alias /apt /var/cache/reprepro/
|
||||
|
||||
<Directory /var/cache/reprepro/>
|
||||
Options Indexes
|
||||
Options +FollowSymLinks
|
||||
AllowOverride None
|
||||
Require all granted
|
||||
</Directory>
|
Reference in New Issue