123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- import glob
- import os
- import shutil
- import subprocess
- import sys
- from distutils.cmd import Command
- from setuptools import setup
- from lvc.variables import (
- __version__
- )
- if sys.version < '2.7':
- raise RuntimeError('LVC requires Python 2.7')
- def icon_data_files():
- sizes = [16, 22, 32, 48]
- data_files = []
- for size in sizes:
- d = os.path.join("icons", "hicolor", "%sx%s" % (size, size), "apps")
- source = os.path.join(SETUP_DIR, d, "librevideoconverter.png")
- dest = os.path.join("/usr/share/", d)
- data_files.append((dest, [source]))
- return data_files
- def application_data_files():
- return [
- ('/usr/share/applications',
- [os.path.join(SETUP_DIR, 'librevideoconverter.desktop')]),
- ]
- def data_files():
- return application_data_files() + icon_data_files()
- class sdist_deb(Command):
- description = ("Build a debian source package.")
- user_options = [
- ('dist-dir=', 'd',
- "directory to put the source distribution archive(s) in "
- "[default: dist]"),
- ]
- def initialize_options(self):
- self.dist_dir = None
- def finalize_options(self):
- if self.dist_dir is None:
- self.dist_dir = 'dist'
- self.dist_dir = os.path.abspath(self.dist_dir)
- def run(self):
- self.run_command("sdist")
- self.setup_dirs()
- for debian_dir in glob.glob(os.path.join(
- SETUP_DIR, 'debian-*')):
- self.build_for_release(debian_dir)
- os.chdir(self.orig_dir)
- print('')
- print("debian source build complete")
- print("files are in %s" % self.work_dir)
- def build_for_release(self, debian_dir):
- os.chdir(self.work_dir)
- source_tree = os.path.join(
- self.work_dir,
- 'librevideoconverter-%s' % __version__)
- if os.path.exists(source_tree):
- shutil.rmtree(source_tree)
- self.extract_tarball()
- self.copy_debian_directory(debian_dir)
- os.chdir('librevideoconverter-%s' % __version__)
- subprocess.check_call(['dpkg-buildpackage', '-S'])
- def setup_dirs(self):
- self.orig_dir = os.getcwd()
- self.work_dir = os.path.join(self.dist_dir, 'deb')
- if os.path.exists(self.work_dir):
- shutil.rmtree(self.work_dir)
- os.makedirs(self.work_dir)
- def extract_tarball(self):
- tarball = os.path.join(
- self.dist_dir,
- "librevideoconverter-%s.tar.gz" % __version__)
- subprocess.check_call(["tar", "zxf", tarball])
- shutil.copyfile(
- tarball,
- "librevideoconverter_%s.orig.tar.gz" % __version__)
- def copy_debian_directory(self, debian_dir):
- dest = os.path.join(
- self.work_dir,
- 'librevideoconverter-%s/debian' % __version__)
- shutil.copytree(debian_dir, dest)
- setup(
- cmdclass={
- 'sdist_deb': sdist_deb,
- },
- data_files=data_files(),
- scripts=['scripts/libre-video-converter.py'],
- **SETUP_ARGS
- )
|