From ba5bc7654818d046383a4a90d0c2f2cca70ce4e6 Mon Sep 17 00:00:00 2001 From: Gaetan Delannay Date: Tue, 11 Dec 2012 22:50:21 +0100 Subject: [PATCH] [bin] Added a script for creating a local Debian repository. --- bin/createdebrepo.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 bin/createdebrepo.py diff --git a/bin/createdebrepo.py b/bin/createdebrepo.py new file mode 100755 index 0000000..5b0a526 --- /dev/null +++ b/bin/createdebrepo.py @@ -0,0 +1,36 @@ +#!/usr/bin/python + +'''This script can be created on a Linux machine for creating a local Debian +(binary) repository.''' + +import os, os.path + +# Packages apache2 and dpkg-dev must be installed on the machine for enabling +# the Debian repository. +repoFolder = '/var/www/debianrepo' + +# Create the repo folder if it does not exist +binaryFolder = os.path.join(repoFolder, 'binary') +if not os.path.exists(binaryFolder): + os.makedirs(binaryFolder) + +# Create the script that will allow to recompute indexes when packages are +# added or updated into the repository. +refreshScript = '''#!/bin/bash +cd %s +echo "(Re-)building indexes for binary packages..." +dpkg-scanpackages binary /dev/null | gzip -9c > binary/Packages.gz +echo "Done." +''' % repoFolder + +curdir = os.getcwd() +os.chdir(repoFolder) +scriptName = os.path.join(repoFolder, 'refresh.sh') +if not os.path.exists(scriptName): + f = file(scriptName, 'w') + f.write(refreshScript) + f.close() +os.system('chmod -R 755 %s' % repoFolder) +os.chdir(curdir) +print 'Repository created.' +