mirror of
https://github.com/jellyfin/jellyfin-build.git
synced 2024-11-26 23:50:33 +00:00
Add remaining build elements
This commit is contained in:
parent
c1d7448871
commit
c92a26dff6
12
build.py
12
build.py
@ -7,6 +7,8 @@ import os, sys, argparse, json
|
||||
import manifest
|
||||
import build_plugin
|
||||
import build_server
|
||||
import build_ffmpeg
|
||||
import build_client
|
||||
|
||||
cwd = os.getcwd()
|
||||
|
||||
@ -117,6 +119,10 @@ def build_project(project):
|
||||
# Extract our name and type
|
||||
project_name = project['name']
|
||||
project_type = project['type']
|
||||
if not args.package:
|
||||
package = 'all'
|
||||
else:
|
||||
package = args.package
|
||||
print("-> Building project '{name}'".format(name=project_name))
|
||||
# Build the project
|
||||
if project['type'] == 'plugin':
|
||||
@ -124,11 +130,11 @@ def build_project(project):
|
||||
if result:
|
||||
updated_plugin = True
|
||||
elif project['type'] == 'client':
|
||||
result = build_client.build_client(project)
|
||||
result = build_client.build_client(project, package)
|
||||
elif project['type'] == 'server':
|
||||
result = build_server.build_server(project, args.package)
|
||||
result = build_server.build_server(project, package)
|
||||
elif project['type'] == 'ffmpeg':
|
||||
result = build_ffmpeg.build_ffmpeg(project)
|
||||
result = build_ffmpeg.build_ffmpeg(project, package)
|
||||
elif project['type'] == 'meta':
|
||||
# Meta projects have no build component
|
||||
pass
|
||||
|
12
build.yaml.ffmpeg.sample
Normal file
12
build.yaml.ffmpeg.sample
Normal file
@ -0,0 +1,12 @@
|
||||
---
|
||||
# We just wrap `build` so this is really it
|
||||
name: "jellyfin-ffmpeg"
|
||||
version: "4.0.3-4"
|
||||
packages:
|
||||
- stretch-amd64
|
||||
- stretch-armhf
|
||||
- buster-amd64
|
||||
- buster-armhf
|
||||
- xenial-amd64
|
||||
- bionic-amd64
|
||||
- cosmic-amd64
|
91
build_client.py
Normal file
91
build_client.py
Normal file
@ -0,0 +1,91 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import os, sys, yaml, json, subprocess, datetime
|
||||
|
||||
import manifest
|
||||
|
||||
cwd = os.getcwd()
|
||||
|
||||
def run_os_command(command, environment=None, shell=False):
|
||||
if shell:
|
||||
cmd = command
|
||||
else:
|
||||
cmd = command.split()
|
||||
|
||||
try:
|
||||
command_output = subprocess.run(
|
||||
cmd,
|
||||
env=environment,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
shell=shell
|
||||
)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
print(command_output)
|
||||
|
||||
return command_output.stdout.decode('utf8'), command_output.stderr.decode('utf8'), command_output.returncode
|
||||
|
||||
def build_client(project, package):
|
||||
# Extract our name and type
|
||||
project_name = project['name']
|
||||
project_type = project['type']
|
||||
|
||||
# Set out the directories
|
||||
type_dir = "{}/projects/{}".format(cwd, project_type)
|
||||
project_dir = "{}/projects/{}/{}".format(cwd, project_type, project_name)
|
||||
|
||||
# Check if a build configuration exists and load it
|
||||
manifest_file = '{}/build.yaml'.format(project_dir)
|
||||
if not os.path.exists(manifest_file):
|
||||
print("ERROR: Project {} does not contain a valid 'build.yaml' file.".format(project['name']))
|
||||
return False
|
||||
build_cfg = manifest.load_manifest(manifest_file)
|
||||
|
||||
project_version = build_cfg['version']
|
||||
project_packages = build_cfg['packages']
|
||||
|
||||
packages_list = list()
|
||||
if package == 'all':
|
||||
packages_list = project_packages
|
||||
else:
|
||||
if package in project_packages:
|
||||
packages_list.append(package)
|
||||
else:
|
||||
print('ERROR: Package type {} is not valid. Valid packages are:'.format(package))
|
||||
print('\n > '.join(project_packages))
|
||||
return False
|
||||
|
||||
# move into the project directory
|
||||
revdir = os.getcwd()
|
||||
# Build each package type
|
||||
for package in packages_list:
|
||||
os.chdir(project_dir)
|
||||
|
||||
# We wrap `build` so we expect it to be sane and like what we send it
|
||||
subprocess.call('./build -r {}'.format(package), shell=True)
|
||||
|
||||
# Move back to the previous directory
|
||||
os.chdir(revdir)
|
||||
|
||||
# Collect artifacts
|
||||
src_dir = "{}/bin".format(type_dir)
|
||||
target_dir = "./bin/{}".format(project_name)
|
||||
# Make the type dir if it doesn't exist
|
||||
if not os.path.isdir(target_dir):
|
||||
os.makedirs(target_dir)
|
||||
# Clean out the old target dir
|
||||
stdout, stderr, retcode = run_os_command("rm -rf {}/{}".format(target_dir, package))
|
||||
if retcode:
|
||||
print('Could not remove old archive: {}'.format(stderr))
|
||||
return False
|
||||
# Move the artifacts
|
||||
stdout, stderr, retcode = run_os_command("mv {}/* {}/".format(src_dir, target_dir), shell=True)
|
||||
if retcode:
|
||||
print('Could not move archive: {}'.format(stderr))
|
||||
return False
|
||||
|
||||
# Remove build junk
|
||||
run_os_command("rm -rf {}".format(src_dir))
|
||||
|
||||
return True
|
89
build_ffmpeg.py
Normal file
89
build_ffmpeg.py
Normal file
@ -0,0 +1,89 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import os, sys, yaml, json, subprocess, datetime
|
||||
|
||||
import manifest
|
||||
|
||||
cwd = os.getcwd()
|
||||
|
||||
def run_os_command(command, environment=None, shell=False):
|
||||
if shell:
|
||||
cmd = command
|
||||
else:
|
||||
cmd = command.split()
|
||||
|
||||
try:
|
||||
command_output = subprocess.run(
|
||||
cmd,
|
||||
env=environment,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
shell=shell
|
||||
)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
print(command_output)
|
||||
|
||||
return command_output.stdout.decode('utf8'), command_output.stderr.decode('utf8'), command_output.returncode
|
||||
|
||||
def build_ffmpeg(project, package):
|
||||
# Extract our name and type
|
||||
project_name = project['name']
|
||||
project_type = project['type']
|
||||
|
||||
# Set out the directories
|
||||
type_dir = "{}/projects/{}".format(cwd, project_type)
|
||||
project_dir = "{}/projects/{}/{}".format(cwd, project_type, project_name)
|
||||
|
||||
# Check if a build configuration exists and load it
|
||||
manifest_file = '{}/build.yaml'.format(project_dir)
|
||||
if not os.path.exists(manifest_file):
|
||||
print("ERROR: Project {} does not contain a valid 'build.yaml' file.".format(project['name']))
|
||||
return False
|
||||
build_cfg = manifest.load_manifest(manifest_file)
|
||||
|
||||
project_version = build_cfg['version']
|
||||
project_packages = build_cfg['packages']
|
||||
|
||||
packages_list = list()
|
||||
if package == 'all':
|
||||
packages_list = project_packages
|
||||
else:
|
||||
if package in project_packages:
|
||||
packages_list.append(package)
|
||||
else:
|
||||
print('ERROR: Package type {} is not valid. Valid packages are:'.format(package))
|
||||
print('\n > '.join(project_packages))
|
||||
return False
|
||||
|
||||
# move into the project directory
|
||||
revdir = os.getcwd()
|
||||
# Build each package type
|
||||
for package in packages_list:
|
||||
os.chdir(project_dir)
|
||||
|
||||
# Get release and architecture
|
||||
release, architecture = package.split('-')
|
||||
|
||||
# We wrap `build` so we expect it to be sane and like what we send it
|
||||
subprocess.call('./build {} {}'.format(release, architecture), shell=True)
|
||||
|
||||
# Move back to the previous directory
|
||||
os.chdir(revdir)
|
||||
|
||||
# Collect artifacts
|
||||
src_dir = "{}/bin".format(type_dir)
|
||||
target_dir = "./bin/{}".format(project_name)
|
||||
# Make the type dir if it doesn't exist
|
||||
if not os.path.isdir(target_dir):
|
||||
os.makedirs(target_dir)
|
||||
# Move the artifacts
|
||||
stdout, stderr, retcode = run_os_command("mv {}/* {}/".format(src_dir, target_dir), shell=True)
|
||||
if retcode:
|
||||
print('Could not move archive: {}'.format(stderr))
|
||||
return False
|
||||
|
||||
# Remove build junk
|
||||
run_os_command("rm -rf {}".format(src_dir))
|
||||
|
||||
return True
|
@ -6,13 +6,19 @@ import manifest
|
||||
|
||||
cwd = os.getcwd()
|
||||
|
||||
def run_os_command(command, environment=None):
|
||||
def run_os_command(command, environment=None, shell=False):
|
||||
if shell:
|
||||
cmd = command
|
||||
else:
|
||||
cmd = command.split()
|
||||
|
||||
try:
|
||||
command_output = subprocess.run(
|
||||
command.split(),
|
||||
cmd,
|
||||
env=environment,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
shell=shell
|
||||
)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
@ -6,13 +6,19 @@ import manifest
|
||||
|
||||
cwd = os.getcwd()
|
||||
|
||||
def run_os_command(command, environment=None):
|
||||
def run_os_command(command, environment=None, shell=False):
|
||||
if shell:
|
||||
cmd = command
|
||||
else:
|
||||
cmd = command.split()
|
||||
|
||||
try:
|
||||
command_output = subprocess.run(
|
||||
command.split(),
|
||||
cmd,
|
||||
env=environment,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
shell=shell
|
||||
)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
Loading…
Reference in New Issue
Block a user