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:
eselect repository add my-org git https://git.my-org.local/portage/my-org.git
Sync my-org
:
emerge --sync my-org
Install live packages of a your software
First, enable live packages (keywordless) for your my-org
repo:
echo '*/*::my-org' >> /etc/portage/package.accept_keywords/0000_repo_my-org.conf
Install some packages from my-org
:
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:
0 */1 * * * emerge --sync my-org
Refresh the main Gentoo tree every other 6th hour:
0 */6 * * * emerge --sync gentoo
Run smart-live-rebuild
every other 3rd hour:
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
#!/bin/sh
set -e
smart-live-rebuild
systemctl restart my-service-1.service
systemctl restart my-service-2.service
Crontab:
0 */3 * * * /opt/update.sh
Via ebuilds pkg_ functions
File: my-service-1.ebuild
pkg_postinst() {
systemctl restart my-service-1.service
}
More about pkg_postinst
: