"ccache"
],
"buildcmd": [
- "AUTOBUILD_CONFIGURE_EXTRA=--enable-ccache\\ --disable-libx265_static\\ --disable-libx265\\ --enable-hdhomerun_static ./Autobuild.sh -t ${TARGET} -j ${PARALLEL} -w ${WORKDIR}"
+ "AUTOBUILD_CONFIGURE_EXTRA=--enable-ccache\\ --disable-libx265_static\\ --disable-libx265\\ --enable-hdhomerun_static ./Autobuild.sh -t ${TARGET} -j ${PARALLEL} -w ${WORKDIR}",
+ "support/bintray.py publish filelist.txt"
]
},
"precise-i386": {
"ccache"
],
"buildcmd": [
- "AUTOBUILD_CONFIGURE_EXTRA=--enable-ccache\\ --disable-libx265_static\\ --disable-libx265\\ --enable-hdhomerun_static ./Autobuild.sh -t ${TARGET} -j ${PARALLEL} -w ${WORKDIR}"
+ "AUTOBUILD_CONFIGURE_EXTRA=--enable-ccache\\ --disable-libx265_static\\ --disable-libx265\\ --enable-hdhomerun_static ./Autobuild.sh -t ${TARGET} -j ${PARALLEL} -w ${WORKDIR}",
+ "support/bintray.py publish filelist.txt"
]
},
"trusty-amd64": {
"ccache"
],
"buildcmd": [
- "AUTOBUILD_CONFIGURE_EXTRA=--enable-ccache\\ --enable-ffmpeg_static\\ --enable-hdhomerun_static ./Autobuild.sh -t ${TARGET} -j ${PARALLEL} -w ${WORKDIR}"
+ "AUTOBUILD_CONFIGURE_EXTRA=--enable-ccache\\ --enable-ffmpeg_static\\ --enable-hdhomerun_static ./Autobuild.sh -t ${TARGET} -j ${PARALLEL} -w ${WORKDIR}",
+ "support/bintray.py publish filelist.txt"
]
},
"trusty-i386": {
"ccache"
],
"buildcmd": [
- "AUTOBUILD_CONFIGURE_EXTRA=--enable-ccache\\ --enable-ffmpeg_static\\ --enable-hdhomerun_static ./Autobuild.sh -t ${TARGET} -j ${PARALLEL} -w ${WORKDIR}"
+ "AUTOBUILD_CONFIGURE_EXTRA=--enable-ccache\\ --enable-ffmpeg_static\\ --enable-hdhomerun_static ./Autobuild.sh -t ${TARGET} -j ${PARALLEL} -w ${WORKDIR}",
+ "support/bintray.py publish filelist.txt"
]
},
"xenial-amd64": {
"ccache"
],
"buildcmd": [
- "AUTOBUILD_CONFIGURE_EXTRA=--enable-ccache\\ --enable-ffmpeg_static\\ --enable-hdhomerun_static ./Autobuild.sh -t ${TARGET} -j ${PARALLEL} -w ${WORKDIR}"
+ "AUTOBUILD_CONFIGURE_EXTRA=--enable-ccache\\ --enable-ffmpeg_static\\ --enable-hdhomerun_static ./Autobuild.sh -t ${TARGET} -j ${PARALLEL} -w ${WORKDIR}",
+ "support/bintray.py publish filelist.txt"
]
},
"xenial-i386": {
"ccache"
],
"buildcmd": [
- "AUTOBUILD_CONFIGURE_EXTRA=--enable-ccache\\ --enable-ffmpeg_static\\ --enable-hdhomerun_static ./Autobuild.sh -t ${TARGET} -j ${PARALLEL} -w ${WORKDIR}"
+ "AUTOBUILD_CONFIGURE_EXTRA=--enable-ccache\\ --enable-ffmpeg_static\\ --enable-hdhomerun_static ./Autobuild.sh -t ${TARGET} -j ${PARALLEL} -w ${WORKDIR}",
+ "support/bintray.py publish filelist.txt"
]
},
"jessie-i386": {
"ccache"
],
"buildcmd": [
- "AUTOBUILD_CONFIGURE_EXTRA=--enable-ccache\\ --enable-ffmpeg_static\\ --enable-hdhomerun_static ./Autobuild.sh -t ${TARGET} -j ${PARALLEL} -w ${WORKDIR}"
+ "AUTOBUILD_CONFIGURE_EXTRA=--enable-ccache\\ --enable-ffmpeg_static\\ --enable-hdhomerun_static ./Autobuild.sh -t ${TARGET} -j ${PARALLEL} -w ${WORKDIR}",
+ "support/bintray.py publish filelist.txt"
]
},
"jessie-amd64": {
"ccache"
],
"buildcmd": [
- "AUTOBUILD_CONFIGURE_EXTRA=--enable-ccache\\ --enable-ffmpeg_static\\ --enable-hdhomerun_static ./Autobuild.sh -t ${TARGET} -j ${PARALLEL} -w ${WORKDIR}"
+ "AUTOBUILD_CONFIGURE_EXTRA=--enable-ccache\\ --enable-ffmpeg_static\\ --enable-hdhomerun_static ./Autobuild.sh -t ${TARGET} -j ${PARALLEL} -w ${WORKDIR}",
+ "support/bintray.py publish filelist.txt"
]
},
"xenial-armhf": {
"ccache"
],
"buildcmd": [
- "AUTOBUILD_CONFIGURE_EXTRA=--enable-ccache\\ --enable-hdhomerun_static\\ --disable-ffmpeg_static ./Autobuild.sh -t ${TARGET} -j ${PARALLEL} -w ${WORKDIR}"
+ "AUTOBUILD_CONFIGURE_EXTRA=--enable-ccache\\ --enable-hdhomerun_static\\ --disable-ffmpeg_static ./Autobuild.sh -t ${TARGET} -j ${PARALLEL} -w ${WORKDIR}",
+ "support/bintray.py publish filelist.txt"
]
},
"xenial-arm64": {
"ccache"
],
"buildcmd": [
- "AUTOBUILD_CONFIGURE_EXTRA=--enable-ccache\\ --enable-hdhomerun_static\\ --disable-ffmpeg_static ./Autobuild.sh -t ${TARGET} -j ${PARALLEL} -w ${WORKDIR}"
+ "AUTOBUILD_CONFIGURE_EXTRA=--enable-ccache\\ --enable-hdhomerun_static\\ --disable-ffmpeg_static ./Autobuild.sh -t ${TARGET} -j ${PARALLEL} -w ${WORKDIR}",
+ "support/bintray.py publish filelist.txt"
]
},
"fedora24-x86_64": {
"ccache"
],
"buildcmd": [
- "./configure --disable-dvbscan && make -C rpm build-doozer"
+ "./configure --disable-dvbscan && make -C rpm build-doozer",
+ "support/bintray.py publish filelist.txt"
]
},
"centos7-x86_64": {
"ccache"
],
"buildcmd": [
- "./configure --disable-dvbscan && make -C rpm build-doozer"
+ "./configure --disable-dvbscan && make -C rpm build-doozer",
+ "support/bintray.py publish filelist.txt"
]
}
}
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-include $(dir $(lastword $(MAKEFILE_LIST)))../.config.mk
+TOPDIR := $(realpath $(dir $(lastword $(MAKEFILE_LIST))))
+
+include $(TOPDIR)/../.config.mk
SPEC ?= tvheadend.spec.in
REF = $(COMMIT1)
COMMITR = $(COMMIT1)
endif
+DEFINES = --define '_topdir $(TOPDIR)'
tvheadend.spec: $(SPEC)
@sed -e 's/@VERSION@/$(VERSION)/g' \
-e 's/@COMMIT@/$(COMMITR)/g' \
$< > $@
-~/rpmbuild/SOURCES:
- mkdir -p $(foreach f,BUILD RPMS SOURCES SPECS SRPMS,~/rpmbuild/$(f))
+SOURCES:
+ mkdir -p $(foreach f,BUILD RPMS SOURCES SPECS SRPMS,$(f))
.PHONY: srpm
-srpm: ~/rpmbuild/SOURCES tvheadend.spec
- spectool --get-files --sourcedir tvheadend.spec
- rpmbuild -bs tvheadend.spec
+srpm: SOURCES tvheadend.spec
+ spectool --get-files -C SOURCES tvheadend.spec
+ rpmbuild $(DEFINES) -bs tvheadend.spec
.PHONY: build
-build: ~/rpmbuild/SOURCES tvheadend.spec
- spectool --get-files --sourcedir tvheadend.spec
- rpmbuild --build-root=/project/repo/rpmbuild -ba tvheadend.spec
+build: SOURCES tvheadend.spec
+ spectool --get-files -C SOURCES tvheadend.spec
+ rpmbuild $(DEFINES) -ba tvheadend.spec
.PHONY: build-doozer
build-doozer: build
- @for a in /project//repo/rpmbuild/RPMS/$$(uname -m)/tvheadend-$(VERSION)-$(RELEASE)*.rpm \
- /project//repo/rpmbuild/RPMS/$$(uname -m)/tvheadend-debuginfo-$(VERSION)-$(RELEASE)*.rpm; do \
+ @rm -f ../filelist.txt
+ @for a in RPMS/$$(uname -m)/tvheadend-$(VERSION)-$(RELEASE)*.rpm \
+ RPMS/$$(uname -m)/tvheadend-debuginfo-$(VERSION)-$(RELEASE)*.rpm; do \
name=$$(basename $$a); \
- echo "doozer-versioned-artifact:$$a:rpm:application/x-rpm:$$name"; \
+ echo "doozer-versioned-artifact:rpm/$$a:rpm:application/x-rpm:$$name"; \
+ echo "rpm/$$a" >> ../filelist.txt; \
done
if key in os.environ: return os.environ[key]
return None
+DEBUG=False
+
BINTRAY_API='https://bintray.com/api/v1'
BINTRAY_USER=env('BINTRAY_USER')
BINTRAY_PASS=env('BINTRAY_PASS')
+BINTRAY_ORG='tvheadend'
+BINTRAY_PACKAGE='tvheadend'
+
+PACKAGE_DESC='Tvheadend is a TV streaming server and recorder for Linux, FreeBSD and Android'
class Response(object):
def __init__(self, response):
a = '%s:%s' % (BINTRAY_USER, BINTRAY_PASS)
self._auth = b'Basic ' + base64.b64encode(a.encode('utf-8'))
- def put(self, data, binary=None):
+ def opener(self):
+ if DEBUG:
+ return urllib.build_opener(urllib.HTTPSHandler(debuglevel=1))
+ else:
+ return urllib.build_opener()
+
+ def _push(self, data, binary=None, method='PUT'):
content_type = 'application/json'
- if binary: content_type = 'application/binary'
- opener = urllib.build_opener()
+ if binary:
+ content_type = 'application/binary'
+ else:
+ data = json.dumps(data)
+ opener = self.opener()
path = self._path
if path[0] != '/': path = '/' + path
request = urllib.Request(BINTRAY_API + path, data=data)
request.add_header('Content-Type', content_type)
request.add_header('Authorization', self._auth)
- request.get_method = lambda: 'PUT'
+ request.get_method = lambda: method
try:
r = Response(opener.open(request))
except urllib.HTTPError as e:
r = Response(e)
return r
+ def put(self, data, binary=None):
+ return self._push(data, binary)
+
+ def post(self, data):
+ return self._push(data, method='POST')
+
def error(lvl, msg, *args):
sys.stderr.write(msg % args + '\n')
sys.exit(lvl)
+def info(msg, *args):
+ print('BINTRAY: ' + msg % args)
+
def do_upload(*args):
- if len(args) < 2:
- error(1, 'upload [url] [file]')
+ if len(args) < 2: error(1, 'upload [url] [file]')
bpath, file = args[0], args[1]
data = open(file, "br").read()
- b = Bintray(bpath)
- resp = b.put(data, binary=1)
+ resp = Bintray(bpath).put(data, binary=1)
if resp.code != 200 and resp.code != 201:
error(10, 'HTTP ERROR "%s" %s %s' % (resp.url, resp.code, resp.reason))
+def get_ver(version):
+ if version.find('-'):
+ version, _ = version.split('-', 1)
+ try:
+ major, minor, rest = version.split('.', 2)
+ except:
+ major, minor = version.split('.', 1)
+ rest = ''
+ return (major, minor, rest)
+
+def get_path(version):
+ major, minor, rest = get_ver(version)
+ if int(major) >= 4 and int(minor) & 1 == 0:
+ return '%d.%d' % (major, minor)
+ return 't'
+
+def get_component(version):
+ major, minor, rest = get_ver(version)
+ if int(major) >= 4 and int(minor) & 1 == 0:
+ if rest.find('~') > 0:
+ return 'stable'
+ return 'release'
+ return 'unstable'
+
+def get_repo(filename, hint=None):
+ if hint: return hint
+ name, ext = os.path.splitext(filename)
+ if ext == '.deb':
+ return 'deb'
+ if ext == '.rpm':
+ if name.find('.centos') > 0:
+ return 'centos'
+ elif name.find('.fc') > 0:
+ return 'fedora'
+ elif name.find('.el') > 0:
+ return 'rhel'
+
+def get_bintray_params(filename, hint=None):
+ filename = filename.strip()
+ basename = os.path.basename(filename)
+ name, ext = os.path.splitext(basename)
+ args = type('',(object,),{})()
+ args.org = BINTRAY_ORG
+ args.repo = get_repo(basename, hint)
+ args.package = BINTRAY_PACKAGE
+ extra = []
+ if args.repo == 'deb':
+ debbase, debarch = name.rsplit('_', 1)
+ debname, debversion = debbase.split('_', 1)
+ debversion, debdistro = debversion.rsplit('~', 1)
+ args.version = debversion
+ args.path = 'pool/' + get_path(debversion) + '/' + args.package
+ extra.append('deb_component=' + get_component(debversion))
+ extra.append('deb_distribution=' + debdistro)
+ extra.append('deb_architecture=' + debarch)
+ else:
+ rpmbase, rpmarch = name.rsplit('.', 1)
+ rpmname, rpmversion = rpmbase.rsplit('-', 1)
+ if rpmversion.find('~') > 0:
+ rpmname, rpmversion2 = rpmname.rsplit('-', 1)
+ rpmversion = rpmversion2 + '-' + rpmversion
+ rpmver1, rpmver2 = rpmversion.split('-', 1)
+ rpmversion, rpmdist = rpmver2.split('.', 1)
+ rpmversion = rpmver1 + '-' + rpmversion
+ args.version = rpmversion
+ args.path = 'linux/' + get_path(rpmversion) + \
+ '/' + rpmdist + '/' + rpmarch
+ extra = ';'.join(extra)
+ if extra: extra = ';' + extra
+ return (basename, args, extra)
+
+def do_publish(*args):
+ if len(args) < 1: error(1, 'upload [file with the file list]')
+ if not DEBUG:
+ branches = os.popen('git branch --contains HEAD').readlines()
+ ok = 0
+ for b in branches:
+ if b[0] == '*':
+ b = b[1:]
+ b = b.strip()
+ if b == 'master' or b.startswith('release/'):
+ ok = 1
+ break
+ if not ok:
+ info('BINTRAY upload - invalid branches\n%s', branches)
+ sys.exit(0)
+ files = open(args[0]).readlines()
+ args = None
+ for file in files:
+ try:
+ basename, args, extra = get_bintray_params(file)
+ hint = args.repo
+ break
+ except:
+ pass
+ bpath = '/packages/tvheadend/%s/tvheadend/versions' % args.repo
+ data = { 'name': args.version, 'desc': PACKAGE_DESC }
+ resp = Bintray(bpath).post(data)
+ if resp.code != 200 and resp.code != 201 and resp.code != 409:
+ error(10, 'Version %s/%s: HTTP ERROR %s %s' %
+ (args.repo, args.version, resp.code, resp.reason))
+ else:
+ info('Version %s/%s created' % (args.repo, args.version))
+ for file in files:
+ file = file.strip()
+ basename, args, extra = get_bintray_params(file, hint)
+ bpath = '/content/%s/%s/%s/%s/%s/%s%s;publish=1' % \
+ (args.org, args.repo, args.package, args.version,
+ args.path, basename, extra)
+ data = open(file, 'rb').read()
+ resp = Bintray(bpath).put(data, binary=1)
+ if resp.code != 200 and resp.code != 201:
+ error(10, 'File %s: HTTP ERROR "%s" %s' %
+ (file, resp.code, resp.reason))
+ else:
+ info('File %s: uploaded', file)
+
def do_unknown(*args):
r = 'Please, specify a valid command:\n'
for n in globals():
error(1, r[:-1])
def main(argv):
+ global DEBUG
if not BINTRAY_USER or not BINTRAY_PASS:
error(2, 'No credentals')
+ if argv[1] == '--debug':
+ DEBUG=1
+ argv.pop(0)
cmd = 'do_' + (len(argv) > 1 and argv[1] or 'unknown')
if cmd in globals():
globals()[cmd](*argv[2:])