build: Generate the PKGBUILD file during `scons release`

This is better than needing to update it manually...

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
Bryan Schumaker 2012-06-02 12:39:58 -04:00
parent faadd138c4
commit f64bf65b37
3 changed files with 25 additions and 7 deletions

2
.gitignore vendored
View File

@ -7,3 +7,5 @@ ocarina.bin
bin/
lib/
include/version.h
PKGBUILD
!PKGBUILD.tmpl

View File

@ -1,6 +1,6 @@
# Maintainer: Bryan Schumaker <bjschuma@gmail.com>
pkgname=ocarina
pkgver=5.8
pkgver=
pkgrel=1
pkgdesc="A simple GTK and gstreamer based music player."
url="http://www.ocarinaproject.net/"
@ -12,8 +12,8 @@ makedepends=('scons')
conflicts=()
replaces=()
backup=()
source=("http://ocarinaproject.net/wp-content/uploads/2012/05/${pkgname}-${pkgver}.tar.gz")
md5sums=('b2aecf434035823fa1d3c759d2ff4b41')
source=("http://ocarinaproject.net/wp-content/uploads/YEAR/MONTH/${pkgname}-${pkgver}.tar.gz")
md5sums=
build() {
cd "${srcdir}/${pkgname}-${pkgver}"

View File

@ -71,9 +71,25 @@ env.Command("uninstall", None, Delete(FindInstalledFiles()))
# Clean up the build directory
clean = Clean(ocarina, ["include/version.h", "bin/", "lib/"])
# Create a tarball
def git_archive(target, source, env):
# Create a tarball and a PKGBUILD script
def prepare_release(target, source, env):
import datetime
ocarina="ocarina-%s" % config.version
os.popen("git archive --prefix=%s/ -o %s.tar.gz HEAD" % (ocarina, ocarina))
print "md5sum:", os.popen("md5sum %s.tar.gz" % ocarina).read()
env.Command("archive", None, [git_archive])
md5 = os.popen("md5sum %s.tar.gz | awk '{print $1}'" % ocarina).read().strip()
now = datetime.datetime.now()
year = str(now.year)
month = str(now.month)
f = open("PKGBUILD", "w")
for line in open("PKGBUILD.tmpl"):
line = line.replace("pkgver=", "pkgver=%s.%s" % (config.MAJOR, config.MINOR))
line = line.replace("md5sums=", "md5sums=('%s')" % md5)
line = line.replace("YEAR", year)
line = line.replace("MONTH", month)
f.write(line)
f.close()
env.Command("release", None, [prepare_release])