Merge pull request #21 from peachcloud/package-filter
Add ability to just build one package at a time
This commit is contained in:
commit
75275bc5ca
11
README.md
11
README.md
|
@ -1,6 +1,6 @@
|
|||
# peach-package-builder
|
||||
|
||||
![Generic badge](https://img.shields.io/badge/version-0.3.4-<COLOR>.svg)
|
||||
![Generic badge](https://img.shields.io/badge/version-0.3.5-<COLOR>.svg)
|
||||
|
||||
Scripts for building debian packages for PeachCloud microservices.
|
||||
|
||||
|
@ -61,7 +61,7 @@ The script currently performs the following actions:
|
|||
- Adds packages to Freight cache
|
||||
|
||||
```
|
||||
python3 -d peach_package_builder/build_packages.py
|
||||
python3 peach_package_builder/build_packages.py -d
|
||||
```
|
||||
|
||||
The -d flag ensures that all packages are built from the latest version of the default branch currently on GitHub.
|
||||
|
@ -69,11 +69,8 @@ Without the -d flag, whatever version of the code is locally stored will be used
|
|||
|
||||
Freight supports the ability to have multiple versions of a package in a single Debian package archive. If a particular version of a package already exists in the Freight library, it will not be readded or overwritten.
|
||||
|
||||
You can also just build the rust packages by running:
|
||||
```python3 -d peach_package_builder/build_rust_packages.py```
|
||||
|
||||
Or just build peach-config by running:
|
||||
```python3 -d peach_package_builder/build_peach_config.py```
|
||||
You can also just build a single package by running (e.g. peach-web, peach-config, etc.):
|
||||
```python3 peach_package_builder/build_packages.py -d -p package-name```
|
||||
|
||||
|
||||
## Build peach-go-sbot package
|
||||
|
|
|
@ -4,12 +4,16 @@ from peach_package_builder.build_rust_packages import build_rust_packages
|
|||
from peach_package_builder.build_peach_config import build_peach_config
|
||||
|
||||
|
||||
def build_packages(default_branch=False):
|
||||
def build_packages(default_branch=False, package=None):
|
||||
"""
|
||||
builds all PeachCloud microservices as .deb files and adds them to the freight repo
|
||||
:param default_branch: checks out main git branch if True
|
||||
:param package: if provided, only builds this package
|
||||
"""
|
||||
build_rust_packages(default_branch=default_branch)
|
||||
build_peach_config(default_branch=default_branch)
|
||||
build_rust_packages(default_branch=default_branch, package=package)
|
||||
# only build peach-config if no package argument was provided or if peach-config is what is being built
|
||||
if not package or package == 'peach-config':
|
||||
build_peach_config(default_branch=default_branch)
|
||||
print("[ MICROSERVICE PACKAGE ARCHIVE UPDATED ]")
|
||||
|
||||
|
||||
|
@ -21,5 +25,10 @@ if __name__ == '__main__':
|
|||
help="Ensure default branch for all repos for build",
|
||||
action="store_true"
|
||||
)
|
||||
parser.add_argument(
|
||||
"-p",
|
||||
"--package",
|
||||
help="Ensure default branch for all repos for build",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
build_packages(default_branch=args.default)
|
||||
build_packages(default_branch=args.default, package=args.package)
|
|
@ -20,12 +20,19 @@ def add_debs_dir_to_freight():
|
|||
update_freight_cache()
|
||||
|
||||
|
||||
def build_rust_packages(default_branch=False):
|
||||
def build_rust_packages(default_branch=False, package=None):
|
||||
"""
|
||||
builds all PeachCloud microservices written in rust and copies them to MICROSERVICES_DEB_DIR
|
||||
:param default_branch: checks out main git branch if True
|
||||
:param package: if provided, only builds this package
|
||||
"""
|
||||
print("[ BUILDING AND UPDATING RUST MICROSERVICE PACKAGES ]")
|
||||
for service in SERVICES:
|
||||
# if package argument was provided, then only build that one package, otherwise build all packages
|
||||
if package:
|
||||
services = filter(lambda s: s["name"] == package, SERVICES)
|
||||
else:
|
||||
services = SERVICES
|
||||
for service in services:
|
||||
service_name = service["name"]
|
||||
service_path = os.path.join(MICROSERVICES_SRC_DIR, service_name)
|
||||
print("[ BUILIDING SERVICE {} ]".format(service_name))
|
||||
|
@ -46,8 +53,12 @@ def build_rust_packages(default_branch=False):
|
|||
cwd=service_path).decode("utf-8").strip()
|
||||
subprocess.call(["cp", debian_package_path, MICROSERVICES_DEB_DIR])
|
||||
|
||||
# this function adds all .deb files in MICROSERVICES_DEB_DIR to freight
|
||||
add_debs_dir_to_freight()
|
||||
# add deb to freight
|
||||
package_name = os.path.basename(debian_package_path)
|
||||
add_deb_to_freight(package_name=package_name, package_path=debian_package_path)
|
||||
|
||||
# update freight cache
|
||||
update_freight_cache()
|
||||
|
||||
|
||||
def build_packages(default_branch=False):
|
||||
|
|
|
@ -31,4 +31,5 @@ SERVICES = [
|
|||
{"name": "peach-probe", "repo_url": "https://github.com/peachcloud/peach-probe.git"},
|
||||
{"name": "peach-dyndns-updater", "repo_url": "https://github.com/peachcloud/peach-dyndns-updater.git"},
|
||||
{"name": "peach-web", "repo_url": "https://github.com/peachcloud/peach-web.git"},
|
||||
{"name": "peach-tbot", "repo_url": "https://github.com/peachcloud/peach-tbot.git"},
|
||||
]
|
Loading…
Reference in New Issue