Merge pull request #300 from brendandixon/egg

Added package building script
This commit is contained in:
brendandixon
2016-07-08 14:38:44 -07:00
committed by GitHub
5 changed files with 97 additions and 30 deletions
-1
View File
@@ -14,4 +14,3 @@
#
# Requires Python 2.4+ and Openssl 1.0+
#
+7 -3
View File
@@ -102,12 +102,14 @@ class Agent(object):
update_handler = get_update_handler()
update_handler.run()
def main():
def main(args=[]):
"""
Parse command line arguments, exit with usage() on error.
Invoke different methods according to different command
"""
command, force, verbose = parse_args(sys.argv[1:])
if len(args) <= 0:
args = sys.argv[1:]
command, force, verbose = parse_args(args)
if command == "version":
version()
elif command == "help":
@@ -178,7 +180,7 @@ def usage():
Show agent usage
"""
print("")
print((("usage: {0} [-verbose] [-force] [-help]"
print((("usage: {0} [-verbose] [-force] [-help] "
"-deprovision[+user]|-register-service|-version|-daemon|-start|"
"-run-exthandlers]"
"").format(sys.argv[0])))
@@ -192,3 +194,5 @@ def start():
devnull = open(os.devnull, 'w')
subprocess.Popen([sys.argv[0], '-daemon'], stdout=devnull, stderr=devnull)
if __name__ == '__main__' :
main()
Executable
+75
View File
@@ -0,0 +1,75 @@
#!/usr/bin/env python
import glob
import os
import os.path
import shutil
import subprocess
import sys
from azurelinuxagent.common.version import AGENT_NAME, AGENT_VERSION, AGENT_LONG_VERSION
from azurelinuxagent.ga.update import AGENT_MANIFEST_FILE
MANIFEST = '''[{{
"name": "{0}",
"version": 1.0,
"handlerManifest": {{
"installCommand": "",
"uninstallCommand": "",
"updateCommand": "",
"enableCommand": "python -u {1} -run-exthandlers",
"disableCommand": "",
"rebootAfterInstall": false,
"reportHeartbeat": false
}}
}}]'''
output_path = os.path.join(os.getcwd(), "eggs")
target_path = os.path.join(output_path, AGENT_LONG_VERSION)
bin_path = os.path.join(target_path, "bin")
egg_path = os.path.join(bin_path, AGENT_LONG_VERSION + ".egg")
manifest_path = os.path.join(target_path, AGENT_MANIFEST_FILE)
pkg_name = os.path.join(output_path, AGENT_LONG_VERSION + ".zip")
def do(*args):
try:
subprocess.check_output(args, stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as e:
print "ERROR: {0}".format(str(e))
print "\t{0}".format(" ".join(args))
print e.output
sys.exit(1)
if os.path.isdir(target_path):
shutil.rmtree(target_path)
elif os.path.isfile(target_path):
os.remove(target_path)
if os.path.isfile(pkg_name):
os.remove(pkg_name)
os.makedirs(bin_path)
print "Created {0} directory".format(target_path)
args = ["python", "setup.py"]
args.append("bdist_egg")
args.append("--dist-dir={0}".format(bin_path))
print "Creating egg {0}".format(egg_path)
do(*args)
egg_name = os.path.join("bin", os.path.basename(glob.glob(os.path.join(bin_path, "*"))[0]))
print "Writing {0}".format(manifest_path)
with open(manifest_path, mode='w') as manifest:
manifest.write(MANIFEST.format(AGENT_NAME, egg_name))
cwd = os.getcwd()
os.chdir(target_path)
print "Creating package {0}".format(pkg_name)
do("zip", "-r", pkg_name, egg_name)
do("zip", "-j", pkg_name, AGENT_MANIFEST_FILE)
os.chdir(cwd)
print "Package {0} successfully created".format(pkg_name)
sys.exit(0)
+15 -12
View File
@@ -168,15 +168,18 @@ class install(_install):
if self.register_service:
get_osutil().register_agent_service()
setuptools.setup(name=AGENT_NAME,
version=AGENT_VERSION,
long_description=AGENT_DESCRIPTION,
author= 'Yue Zhang, Stephen Zarkos, Eric Gable',
author_email = 'walinuxagent@microsoft.com',
platforms = 'Linux',
url='https://github.com/Azure/WALinuxAgent',
license = 'Apache License Version 2.0',
packages=find_packages(exclude=["tests"]),
cmdclass = {
'install': install
})
setuptools.setup(
name=AGENT_NAME,
version=AGENT_VERSION,
long_description=AGENT_DESCRIPTION,
author= 'Yue Zhang, Stephen Zarkos, Eric Gable',
author_email = 'walinuxagent@microsoft.com',
platforms = 'Linux',
url='https://github.com/Azure/WALinuxAgent',
license = 'Apache License Version 2.0',
packages=find_packages(exclude=["tests"]),
py_modules=["__main__"],
cmdclass = {
'install': install
}
)
-14
View File
@@ -1,14 +0,0 @@
[{
"name": "WALinuxAgent",
"version": 1.0,
"handlerManifest": {
"installCommand": "",
"uninstallCommand": "",
"updateCommand": "",
"enableCommand": "python -u bin/WALinuxAgent-2.1.5.egg -run-exthandlers",
"disableCommand": "",
"rebootAfterInstall": false,
"reportHeartbeat": false,
"updateMode": "updatewithinstall"
}
}]