Portage Continuous Delivery
Portage as a CD system
This is a very simple way to use any system with Portage installed as a Continuous Delivery server.
I think for a testing environment this is a valid solution to consider.
Create a repository of software used in your organization
Those articles from the Gentoo Wiki describe how to create a custom ebuild repository (overlay) pretty well:
Set up your repo with eselect-repository
Install the my-org
repository:
1 |
eselect repository add my-org git https://git.my-org.local/portage/my-org.git |
Sync my-org
:
1 |
emerge --sync my-org |
Install live packages of a your software
First, enable live packages (keywordless) for your my-org
repo:
1 |
echo '*/*::my-org' >> /etc/portage/package.accept_keywords/0000_repo_my-org.conf |
Install some packages from my-org
:
1 |
emerge -av "=mycategory/mysoftware-9999" |
Install smart-live-rebuild
smart-live-rebuild
can automatically update live software packages that use git as their source URL.
Set up cron to run smart-live-rebuild
Refresh your my-org
repository every hour:
1 |
0 */1 * * * emerge --sync my-org |
Refresh the main Gentoo tree every other 6th hour:
1 |
0 */6 * * * emerge --sync gentoo |
Run smart-live-rebuild
every other 3rd hour:
1 |
0 */3 * * * smart-live-rebuild |
Restarting services after update
All-in-one script
You can either restart all services after successful update:
File: /opt/update.sh
1 2 3 4 5 6 7 8 |
#!/bin/sh set -e smart-live-rebuild systemctl restart my-service-1.service systemctl restart my-service-2.service |
Crontab:
1 |
0 */3 * * * /opt/update.sh |
Via ebuilds pkg_ functions
File: my-service-1.ebuild
1 2 3 |
pkg_postinst() { systemctl restart my-service-1.service } |
More about pkg_postinst
: