コード例 #1
0
ファイル: deb.py プロジェクト: soukicz/nginx-amplify-agent
def build():
    full_package_name = "nginx-amplify-agent"
    pkg_root = os.path.expanduser('~') + '/agent-pkg-root'
    pkg_final = os.path.expanduser('~') + '/agent-package'

    # get version and build
    version, bld = get_version_and_build()

    # get architecture
    arch = shell_call("dpkg-architecture -c 'echo ${DEB_BUILD_ARCH}'").split(
        '\n')[0]

    # get codename
    shell_call("lsb_release -c")  # checks that lsb_release is installed
    codename = shell_call("lsb_release -c | awk '{print $2}'").split('\n')[0]

    # install pip
    install_pip()

    try:
        # delete previous build
        shell_call('rm -rf %s' % pkg_root)
        shell_call('rm -rf %s && mkdir %s' % (pkg_final, pkg_final))

        # install all dependencies
        install_pip_deps()

        # sed build to control
        shell_call(
            "sed -i 's/^Version: .*$/Version: %s-%s~%s/' packages/deb/DEBIAN/control"
            % (version, bld, codename))
        shell_call(
            "sed -i 's/^Architecture: .*$/Architecture: %s/' packages/deb/DEBIAN/control"
            % arch)

        # sed first line of changelog
        changelog_first_line = '%s (%s-%s~%s) unstable; urgency=low' % (
            full_package_name, version, bld, codename)
        change_first_line('packages/deb/DEBIAN/changelog',
                          changelog_first_line)

        # create python package
        shell_call(
            'python setup.py install --install-layout=deb --prefix=/usr --root=%s'
            % pkg_root)

        # copy debian files to pkg-root
        shell_call('cp -r packages/deb/DEBIAN %s/' % pkg_root)

        # create deb package
        package_file = '%s_%s-%s~%s_%s.deb' % (full_package_name, version, bld,
                                               codename, arch)
        shell_call('fakeroot dpkg --build %s %s/%s' %
                   (pkg_root, pkg_final, package_file))

        # clean
        shell_call('rm -r build', important=False)
        shell_call('rm -r *.egg-*', important=False)
    except:
        print(traceback.format_exc())
コード例 #2
0
ファイル: rpm.py プロジェクト: ncheikh/nginx-amplify-agent
def build():
    full_name = "nginx-amplify-agent"
    rpm_topdir = os.path.expanduser('~') + '/rpmbuild'
    rpm_sources = rpm_topdir + '/SOURCES'

    # get version and build
    version, bld = get_version_and_build()

    # get arch
    arch = shell_call('uname -m').split('\n')[0]

    # install pip
    install_pip()

    try:
        # delete previous build
        shell_call('rm -rf %s' % rpm_sources)

        # create default rpmbuild dir
        try:
            os.makedirs(rpm_sources)
        except:
            pass

        # create a weird setup file
        if arch.endswith('_64'):
            """
            [install]
            install-purelib=$base/lib64/python
            """
            shell_call("echo '[install]' > setup.cfg")
            shell_call(
                "echo 'install-purelib=$base/lib64/python' >> setup.cfg")

        # install all dependencies
        install_pip_deps()

        # remove weird file
        shell_call('rm -rf setup.cfg', important=False)

        # create python package
        shell_call('python setup.py sdist --formats=gztar')

        # copy gz file to rpmbuild/SOURCES/
        shell_call('cp -r dist/*.gz %s/' % rpm_sources)

        # create rpm package
        shell_call(
            'rpmbuild -D "_topdir %s" -bb packages/rpm/%s.spec --define "amplify_version %s" --define "amplify_release %s"'
            % (rpm_topdir, full_name, version, bld))

        # clean
        shell_call('rm -r dist', important=False)
        shell_call('rm -r *.egg-*', important=False)
    except:
        print(traceback.format_exc())
コード例 #3
0
ファイル: rpm.py プロジェクト: heartshare/nginx-amplify-agent
def build():
    full_name = "nginx-amplify-agent"
    rpm_sources = os.path.expanduser('~') + '/rpmbuild/SOURCES'

    # get version and build
    version, bld = get_version_and_build()

    # get arch
    arch = shell_call('uname -m').split('\n')[0]

    # install pip
    install_pip()

    try:
        # delete previous build
        shell_call('rm -rf %s' % rpm_sources)

        # create default rpmbuild dir
        try:
            os.makedirs(rpm_sources)
        except:
            pass

        # create a weird setup file
        if arch.endswith('_64'):
            """
            [install]
            install-purelib=$base/lib64/python
            """
            shell_call("echo '[install]' > setup.cfg")
            shell_call("echo 'install-purelib=$base/lib64/python' >> setup.cfg")

        # install all dependencies
        install_pip_deps()

        # remove weird file
        shell_call('rm -rf setup.cfg', important=False)

        # create python package
        shell_call('python setup.py sdist --formats=gztar')

        # copy gz file to rpmbuild/SOURCES/
        shell_call('cp -r dist/*.gz %s/' % rpm_sources)

        # create rpm package
        shell_call(
            'rpmbuild -bb packages/rpm/%s.spec --define "amplify_version %s" --define "amplify_release %s"' % (
                full_name, version, bld
            )
        )

        # clean
        shell_call('rm -r dist', important=False)
        shell_call('rm -r *.egg-*', important=False)
    except:
        print traceback.format_exc()
コード例 #4
0
ファイル: deb.py プロジェクト: zevs00807/nginx-amplify-agent
def build(package=None):
    """
    Builds a deb package

    :param package: str full package name
    """
    pkg_root = os.path.expanduser('~') + '/agent-pkg-root'
    pkg_final = os.path.expanduser('~') + '/agent-package'

    # get version and build
    version, bld = get_version_and_build()

    # get codename
    codename = shell_call("lsb_release -cs").rstrip('\n')

    # install pip
    install_pip()

    try:
        # delete previous build
        shell_call('rm -rf %s' % pkg_root)
        shell_call('rm -rf %s && mkdir %s' % (pkg_final, pkg_final))

        # install all dependencies
        install_pip_deps(package=package)

        # create python package
        shell_call('cp packages/%s/setup.py ./' % package)
        shell_call(
            'python setup.py install --install-layout=deb --prefix=/usr --root=%s/%s-%s/debian/%s'
            % (pkg_root, package, version, package))

        # copy debian files to pkg-root
        shell_call('cp -r packages/%s/deb/debian %s/%s-%s/' %
                   (package, pkg_root, package, version))

        # sed first line of changelog
        changelog_first_line = '%s (%s-%s~%s) %s; urgency=low' % (
            package, version, bld, codename, codename)
        change_first_line(
            '%s/%s-%s/debian/changelog' % (pkg_root, package, version),
            changelog_first_line)

        # create deb package
        shell_call('cd %s/%s-%s && debuild -us -uc' %
                   (pkg_root, package, version),
                   terminal=True)
        shell_call('cp %s/*.deb %s/' % (pkg_root, pkg_final))

        # clean
        shell_call('rm -r build', important=False)
        shell_call('rm -r *.egg-*', important=False)
        shell_call('rm setup.py', important=False)
    except:
        print(traceback.format_exc())
コード例 #5
0
ファイル: deb.py プロジェクト: Ferrisbane/nginx-amplify-agent
def build():
    full_package_name = "nginx-amplify-agent"
    pkg_root = os.path.expanduser('~') + '/agent-pkg-root'
    pkg_final = os.path.expanduser('~') + '/agent-package'

    # get version and build
    version, bld = get_version_and_build()

    # get architecture
    arch = shell_call("dpkg-architecture -c 'echo ${DEB_BUILD_ARCH}'").split('\n')[0]

    # get codename
    shell_call("lsb_release -c")  # checks that lsb_release is installed
    codename = shell_call("lsb_release -c | awk '{print $2}'").split('\n')[0]

    # install pip
    install_pip()

    try:
        # delete previous build
        shell_call('rm -rf %s' % pkg_root)
        shell_call('rm -rf %s && mkdir %s' % (pkg_final, pkg_final))

        # install all dependencies
        install_pip_deps()

        # sed build to control
        shell_call("sed -i 's/^Version: .*$/Version: %s-%s~%s/' packages/deb/DEBIAN/control" % (version, bld, codename))
        shell_call("sed -i 's/^Architecture: .*$/Architecture: %s/' packages/deb/DEBIAN/control" % arch)

        # sed first line of changelog
        changelog_first_line = '%s (%s-%s~%s) unstable; urgency=low' % (full_package_name, version, bld, codename)
        change_first_line('packages/deb/DEBIAN/changelog', changelog_first_line)

        # create python package
        shell_call('python setup.py install --install-layout=deb --prefix=/usr --root=%s' % pkg_root)

        # copy debian files to pkg-root
        shell_call('cp -r packages/deb/DEBIAN %s/' % pkg_root)

        # create deb package
        package_file = '%s_%s-%s~%s_%s.deb' % (full_package_name, version, bld, codename, arch)
        shell_call('fakeroot dpkg --build %s %s/%s' % (pkg_root, pkg_final, package_file))

        # clean
        shell_call('rm -r build', important=False)
        shell_call('rm -r *.egg-*', important=False)
    except:
        print(traceback.format_exc())
コード例 #6
0
def build(package=None):
    """
    Builds a rpm package for amazon linux

    :param package: str full package name
    """
    rpm_topdir = os.path.expanduser('~') + '/rpmbuild'
    rpm_sources = rpm_topdir + '/SOURCES'
    python = '/usr/bin/python2.7'

    # get version and build
    version, bld = get_version_and_build()

    # get arch
    arch = shell_call('uname -m').split('\n')[0]

    # install pip
    install_pip(python=python)

    try:
        # delete previous build
        shell_call('rm -rf %s' % rpm_sources)

        # create default rpmbuild dir
        try:
            os.makedirs(rpm_sources)
        except:
            pass

        # create a weird setup file (just like with any other rpm)
        if arch.endswith('_64'):
            """
            [install]
            install-purelib=$base/lib64/python
            """
            shell_call("echo '[install]' > setup.cfg")
            shell_call(
                "echo 'install-purelib=$base/lib64/python' >> setup.cfg")

        # install all dependencies
        install_pip_deps(package=package)

        # remove weird file
        shell_call('rm -rf setup.cfg', important=False)

        # provide a new one - to create a package that will work with the strange amazon linux rpm
        shell_call("echo '[install]' > setup.cfg")
        shell_call(
            "echo 'install_lib = /usr/lib/python2.7/dist-packages' >> setup.cfg"
        )

        # create python package
        shell_call('cp packages/%s/setup.py ./' % package)
        shell_call('%s setup.py sdist --formats=gztar' % python)

        # copy gz file to rpmbuild/SOURCES/
        shell_call('cp -r dist/*.gz %s/' % rpm_sources)

        # create rpm package
        shell_call(
            'rpmbuild -D "_topdir %s" -bb packages/%s/rpm/%s.spec --define "amplify_version %s" --define "amplify_release %s"'
            % (rpm_topdir, package, package, version, bld))

        # clean
        shell_call('rm -r dist', important=False)
        shell_call('rm -r *.egg-*', important=False)
        shell_call('rm -rf setup.cfg', important=False)
        shell_call('rm setup.py', important=False)
    except:
        print(traceback.format_exc())