parent
044b8da55a
commit
5fc7d033f9
288 changed files with 13040 additions and 1 deletions
303
bots/images/scripts/lib/atomic.install
Executable file
303
bots/images/scripts/lib/atomic.install
Executable file
|
|
@ -0,0 +1,303 @@
|
|||
#!/usr/bin/python2
|
||||
|
||||
# This file is part of Cockpit.
|
||||
#
|
||||
# Copyright (C) 2015 Red Hat, Inc.
|
||||
#
|
||||
# Cockpit is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published by
|
||||
# the Free Software Foundation; either version 2.1 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Cockpit is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with Cockpit; If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import subprocess
|
||||
import os
|
||||
import sys
|
||||
import shutil
|
||||
try:
|
||||
from urllib.request import URLopener
|
||||
except ImportError:
|
||||
from urllib import URLopener # Python 2
|
||||
import argparse
|
||||
import json
|
||||
|
||||
BASEDIR = os.path.dirname(__file__)
|
||||
|
||||
class AtomicCockpitInstaller:
|
||||
branch = None
|
||||
checkout_location = "/var/local-tree"
|
||||
repo_location = "/var/local-repo"
|
||||
rpm_location = "/usr/share/rpm"
|
||||
key_id = "95A8BA1754D0E95E2B3A98A7EE15015654780CBD"
|
||||
port = 12345
|
||||
|
||||
# Support installing random packages if needed.
|
||||
external_packages = {}
|
||||
|
||||
# Temporarily force cockpit-system instead of cockpit-shell
|
||||
packages_force_install = [ "cockpit-system",
|
||||
"cockpit-docker",
|
||||
"cockpit-kdump",
|
||||
"cockpit-networkmanager",
|
||||
"cockpit-sosreport" ]
|
||||
|
||||
def __init__(self, rpms=None, extra_rpms=None, verbose=False):
|
||||
self.verbose = verbose
|
||||
self.rpms = rpms
|
||||
self.extra_rpms = extra_rpms
|
||||
status = json.loads(subprocess.check_output(["rpm-ostree", "status", "--json"], universal_newlines=True))
|
||||
origin = None
|
||||
for deployment in status.get("deployments", []):
|
||||
if deployment.get("booted"):
|
||||
origin = deployment["origin"]
|
||||
|
||||
if not origin:
|
||||
raise Exception("Couldn't find origin")
|
||||
|
||||
self.branch = origin.split(":", 1)[-1]
|
||||
|
||||
def setup_dirs(self):
|
||||
if self.verbose:
|
||||
print("setting up new ostree repo")
|
||||
|
||||
try:
|
||||
shutil.rmtree(self.repo_location)
|
||||
except:
|
||||
pass
|
||||
|
||||
os.makedirs(self.repo_location)
|
||||
subprocess.check_call(["ostree", "init", "--repo", self.repo_location,
|
||||
"--mode", "archive-z2"])
|
||||
|
||||
if not os.path.exists(self.checkout_location):
|
||||
if self.verbose:
|
||||
print("cloning current branch")
|
||||
|
||||
subprocess.check_call(["ostree", "checkout", self.branch,
|
||||
self.checkout_location])
|
||||
|
||||
# move /usr/etc to /etc, makes rpm installs easier
|
||||
subprocess.check_call(["mv", os.path.join(self.checkout_location, "usr", "etc"),
|
||||
os.path.join(self.checkout_location, "etc")])
|
||||
|
||||
def switch_to_local_tree(self):
|
||||
if self.verbose:
|
||||
print("install new ostree commit")
|
||||
|
||||
# Not an error if this fails
|
||||
subprocess.call(["ostree", "remote", "delete", "local"])
|
||||
|
||||
subprocess.check_call(["ostree", "remote", "add", "local",
|
||||
"file://{}".format(self.repo_location),
|
||||
"--no-gpg-verify"])
|
||||
|
||||
# HACK: https://github.com/candlepin/subscription-manager/issues/1404
|
||||
subprocess.call(["systemctl", "disable", "rhsmcertd"])
|
||||
subprocess.call(["systemctl", "stop", "rhsmcertd"])
|
||||
|
||||
status = subprocess.check_output(["rpm-ostree", "status"])
|
||||
if b"local:" in status:
|
||||
subprocess.check_call(["rpm-ostree", "upgrade"])
|
||||
else:
|
||||
try:
|
||||
subprocess.check_call(["setenforce", "0"])
|
||||
subprocess.check_call(["rpm-ostree", "rebase",
|
||||
"local:{0}".format(self.branch)])
|
||||
except:
|
||||
os.system("sysctl kernel.core_pattern")
|
||||
os.system("coredumpctl || true")
|
||||
raise
|
||||
finally:
|
||||
subprocess.check_call(["setenforce", "1"])
|
||||
|
||||
def commit_to_repo(self):
|
||||
if self.verbose:
|
||||
print("commit package changes to our repo")
|
||||
|
||||
# move etc back to /usr/etc
|
||||
subprocess.check_call(["mv", os.path.join(self.checkout_location, "etc"),
|
||||
os.path.join(self.checkout_location, "usr", "etc")])
|
||||
|
||||
subprocess.check_call(["ostree", "commit", "-s", "cockpit-tree",
|
||||
"--repo", self.repo_location,
|
||||
"-b", self.branch,
|
||||
"--add-metadata-string", "version=cockpit-base.1",
|
||||
"--tree=dir={0}".format(self.checkout_location),
|
||||
"--gpg-sign={0}".format(self.key_id),
|
||||
"--gpg-homedir={0}".format(BASEDIR)])
|
||||
|
||||
def install_packages(self, packages, deps=True, replace=False):
|
||||
args = ["rpm", "-U", "--root", self.checkout_location,
|
||||
"--dbpath", self.rpm_location]
|
||||
|
||||
if replace:
|
||||
args.extend(["--replacepkgs", "--replacefiles"])
|
||||
|
||||
if not deps:
|
||||
args.append("--nodeps")
|
||||
|
||||
for package in packages:
|
||||
args.append(os.path.abspath(os.path.join(os.getcwd(), package)))
|
||||
|
||||
subprocess.check_call(args)
|
||||
|
||||
def remove_packages(self, packages):
|
||||
args = ["rpm", "-e", "--root", self.checkout_location,
|
||||
"--dbpath", self.rpm_location]
|
||||
args.extend(packages)
|
||||
subprocess.check_call(args)
|
||||
|
||||
def package_basename(self, package):
|
||||
""" only accept package with the name 'cockpit-%s-*' and return 'cockpit-%s' or None"""
|
||||
basename = "-".join(package.split("-")[:2])
|
||||
if basename.startswith("cockpit-"):
|
||||
return basename
|
||||
else:
|
||||
return None
|
||||
|
||||
def update_container(self):
|
||||
""" Install the latest cockpit RPMs in our container"""
|
||||
rpm_args = []
|
||||
for package in self.rpms:
|
||||
if 'cockpit-ws' in package or 'cockpit-dashboard' in package or 'cockpit-bridge' in package:
|
||||
rpm_args.append("/host" + package)
|
||||
extra_args = []
|
||||
for package in self.extra_rpms:
|
||||
extra_args.append("/host" + package)
|
||||
|
||||
if rpm_args:
|
||||
subprocess.check_call(["docker", "run", "--name", "build-cockpit",
|
||||
"-d", "--privileged", "-v", "/:/host",
|
||||
"cockpit/ws", "sleep", "1d"])
|
||||
if self.verbose:
|
||||
print("updating cockpit-ws container")
|
||||
|
||||
if extra_args:
|
||||
subprocess.check_call(["docker", "exec", "build-cockpit",
|
||||
"rpm", "--install", "--verbose", "--force"] + extra_args)
|
||||
|
||||
subprocess.check_call(["docker", "exec", "build-cockpit",
|
||||
"rpm", "--freshen", "--verbose", "--force"] + rpm_args)
|
||||
|
||||
# if we update the RPMs, also update the scripts, to keep them in sync
|
||||
subprocess.check_call(["docker", "exec", "build-cockpit", "sh", "-exc",
|
||||
"cp /host/var/tmp/containers/ws/atomic-* /container/"])
|
||||
|
||||
subprocess.check_call(["docker", "commit", "build-cockpit",
|
||||
"cockpit/ws"])
|
||||
subprocess.check_call(["docker", "kill", "build-cockpit"])
|
||||
subprocess.check_call(["docker", "rm", "build-cockpit"])
|
||||
|
||||
def package_basenames(self, package_names):
|
||||
""" convert a list of package names to a list of their basenames """
|
||||
return list(filter(lambda s: s is not None, map(self.package_basename, package_names)))
|
||||
|
||||
def get_installed_cockpit_packages(self):
|
||||
""" get list installed cockpit packages """
|
||||
packages = subprocess.check_output("rpm -qa | grep cockpit", shell=True, universal_newlines=True)
|
||||
|
||||
if self.verbose:
|
||||
print("installed packages: {0}".format(packages))
|
||||
|
||||
installed_packages = packages.strip().split("\n")
|
||||
return installed_packages
|
||||
|
||||
def clean_network(self):
|
||||
if self.verbose:
|
||||
print("clean network configuration:")
|
||||
subprocess.check_call(["rm", "-rf", "/var/lib/NetworkManager"])
|
||||
subprocess.check_call(["rm", "-rf", "/var/lib/dhcp"])
|
||||
|
||||
def run(self):
|
||||
# Delete previous deployment if it's present
|
||||
output = subprocess.check_output(["ostree", "admin", "status"])
|
||||
if output.count(b"origin refspec") != 1:
|
||||
subprocess.check_call(["ostree", "admin", "undeploy", "1"])
|
||||
|
||||
self.setup_dirs()
|
||||
|
||||
installed_packages = self.get_installed_cockpit_packages()
|
||||
self.remove_packages(installed_packages)
|
||||
|
||||
packages_to_install = self.package_basenames(installed_packages)
|
||||
for p in self.packages_force_install:
|
||||
if not p in packages_to_install:
|
||||
if self.verbose:
|
||||
print("adding package %s (forced)" % (p))
|
||||
packages_to_install.append(p)
|
||||
|
||||
packages_to_install = list(filter(lambda p: any(os.path.split(p)[1].startswith(base) for base in packages_to_install), self.rpms))
|
||||
|
||||
if self.verbose:
|
||||
print("packages to install:")
|
||||
print(packages_to_install)
|
||||
|
||||
if self.external_packages:
|
||||
names = self.external_packages.keys()
|
||||
if self.verbose:
|
||||
print("external packages to install:")
|
||||
print(list(names))
|
||||
|
||||
downloader = URLopener()
|
||||
for name, url in self.external_packages.items():
|
||||
downloader.retrieve(url, name)
|
||||
|
||||
self.install_packages(names, replace=True)
|
||||
|
||||
for name in names:
|
||||
os.remove(name)
|
||||
|
||||
self.install_packages(packages_to_install)
|
||||
no_deps = [x for x in self.rpms \
|
||||
if os.path.split(x)[-1].startswith("cockpit-tests") or
|
||||
os.path.split(x)[-1].startswith("cockpit-machines")]
|
||||
self.install_packages(no_deps, deps=False, replace=True)
|
||||
|
||||
# If firewalld is installed, we need to poke a hole for cockpit, so
|
||||
# that we can run firewall tests on it (change firewall-cmd to
|
||||
# --add-service=cockpit once all supported atomics ship with the
|
||||
# service file)
|
||||
if subprocess.call(["systemctl", "enable", "--now", "firewalld"]) == 0:
|
||||
subprocess.call(["firewall-cmd", "--permanent", "--add-port=9090/tcp"])
|
||||
|
||||
self.commit_to_repo()
|
||||
self.switch_to_local_tree()
|
||||
self.update_container()
|
||||
self.clean_network()
|
||||
|
||||
parser = argparse.ArgumentParser(description='Install Cockpit in Atomic')
|
||||
parser.add_argument('-v', '--verbose', action='store_true', help='Display verbose progress details')
|
||||
parser.add_argument('-q', '--quick', action='store_true', help='Build faster')
|
||||
parser.add_argument('--build', action='store_true', help='Build')
|
||||
parser.add_argument('--install', action='store_true', help='Install')
|
||||
parser.add_argument('--extra', action='append', default=[], help='Extra packages to install inside the container')
|
||||
parser.add_argument('--skip', action='append', default=[], help='Packes to skip during installation')
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.build:
|
||||
sys.stderr.write("Can't build on Atomic\n")
|
||||
sys.exit(1)
|
||||
|
||||
if args.install:
|
||||
os.chdir("build-results")
|
||||
# Force skip cockpit-dashboard
|
||||
if args.skip:
|
||||
skip = list(args.skip)
|
||||
else:
|
||||
skip = []
|
||||
skip.append("cockpit-dashboard")
|
||||
|
||||
rpms = [os.path.abspath(f) for f in os.listdir(".")
|
||||
if (f.endswith(".rpm") and not f.endswith(".src.rpm")
|
||||
and not any(f.startswith(s) for s in args.skip))]
|
||||
cockpit_installer = AtomicCockpitInstaller(rpms=rpms, extra_rpms=args.extra, verbose=args.verbose)
|
||||
cockpit_installer.run()
|
||||
|
||||
# vim: ft=python
|
||||
78
bots/images/scripts/lib/atomic.setup
Executable file
78
bots/images/scripts/lib/atomic.setup
Executable file
|
|
@ -0,0 +1,78 @@
|
|||
#!/bin/bash
|
||||
|
||||
# This file is part of Cockpit.
|
||||
#
|
||||
# Copyright (C) 2015 Red Hat, Inc.
|
||||
#
|
||||
# Cockpit is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published by
|
||||
# the Free Software Foundation; either version 2.1 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Cockpit is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with Cockpit; If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
set -ex
|
||||
|
||||
# The docker pool should grow automatically as needed, but we grow it
|
||||
# explicitly here anyway. This is hopefully more reliable.
|
||||
# Newer Fedora versions configure docker to use the root LV
|
||||
# HACK: docker falls over regularly, print its log if it does
|
||||
systemctl start docker || journalctl -u docker
|
||||
lvresize atomicos/root -l+60%FREE -r
|
||||
if lvs atomicos/docker-pool 2>/dev/null; then
|
||||
lvresize atomicos/docker-pool -l+100%FREE
|
||||
elif lvs atomicos/docker-root-lv; then
|
||||
lvresize atomicos/docker-root-lv -l+100%FREE
|
||||
fi
|
||||
|
||||
# docker images that we need for integration testing
|
||||
/var/lib/testvm/docker-images.setup
|
||||
|
||||
# Download the libssh RPM plus dependencies which we'll use for
|
||||
# package overlay. The only way to do this is via a container
|
||||
. /etc/os-release
|
||||
REPO="updates"
|
||||
if [ "$ID" = "rhel" ]; then
|
||||
subscription-manager repos --enable rhel-7-server-extras-rpms
|
||||
REPO="rhel-7-server-extras-rpms"
|
||||
ID="rhel7"
|
||||
fi
|
||||
docker run --rm --volume=/etc/yum.repos.d:/etc/yum.repos.d:z --volume=/root/rpms:/tmp/rpms:rw,z "$ID:$VERSION_ID" /bin/sh -cex "yum install -y findutils createrepo yum-utils && (cd /tmp/; yumdownloader --enablerepo=$REPO libssh) && find /tmp -name '*.$(uname -m).*rpm' | while read rpm; do mv -v \$rpm /tmp/rpms; done; createrepo /tmp/rpms"
|
||||
rm -f /etc/yum.repos.d/*
|
||||
cat >/etc/yum.repos.d/deps.repo <<EOF
|
||||
[deps]
|
||||
baseurl=file:///root/rpms
|
||||
enabled=1
|
||||
EOF
|
||||
|
||||
# fully upgrade host. Anything past this point can't touch /etc
|
||||
# Upgrade host if there is a valid upgrade available (we might be on a RC)
|
||||
if rpm-ostree upgrade --check; then
|
||||
atomic host upgrade
|
||||
# HACK - Find a better way to compute the ref.
|
||||
# https://lists.projectatomic.io/projectatomic-archives/atomic-devel/2016-July/msg00015.html
|
||||
|
||||
checkout=$(atomic host status --json | python -c 'import json; import sys; j = json.loads(sys.stdin.readline()); print j["deployments"][0]["origin"]')
|
||||
else
|
||||
checkout=$(atomic host status --json | python -c 'import json; import sys; j = json.loads(sys.stdin.readline()); print [x for x in j["deployments"] if x["booted"]][0]["checksum"]')
|
||||
fi
|
||||
|
||||
# Checkout the just upgraded os branch since we'll use it every time
|
||||
# we build a new tree.
|
||||
|
||||
ostree checkout "$checkout" /var/local-tree
|
||||
|
||||
# reduce image size
|
||||
/var/lib/testvm/zero-disk.setup
|
||||
|
||||
# Prevent SSH from hanging for a long time when no external network access
|
||||
echo 'UseDNS no' >> /etc/ssh/sshd_config
|
||||
|
||||
# Final tweaks
|
||||
rm -rf /var/log/journal/*
|
||||
5
bots/images/scripts/lib/base/Dockerfile
Normal file
5
bots/images/scripts/lib/base/Dockerfile
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
FROM fedora:30
|
||||
|
||||
ADD setup.sh /setup.sh
|
||||
|
||||
RUN /setup.sh
|
||||
5
bots/images/scripts/lib/base/README.md
Normal file
5
bots/images/scripts/lib/base/README.md
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
Cockpit Base
|
||||
===========================
|
||||
|
||||
Simple base container that installs cockpit-ws dependencies. Used in testing
|
||||
and development to speed up container build times.
|
||||
26
bots/images/scripts/lib/base/setup.sh
Executable file
26
bots/images/scripts/lib/base/setup.sh
Executable file
|
|
@ -0,0 +1,26 @@
|
|||
#! /bin/sh
|
||||
|
||||
upgrade() {
|
||||
# https://bugzilla.redhat.com/show_bug.cgi?id=1483553
|
||||
dnf -v -y update 2>err.txt
|
||||
ecode=$?
|
||||
if [ $ecode -ne 0 ] ; then
|
||||
grep -q -F -e "BDB1539 Build signature doesn't match environment" err.txt
|
||||
if [ $? -eq 0 ]; then
|
||||
set -eu
|
||||
rpm --rebuilddb
|
||||
dnf -v -y update
|
||||
else
|
||||
cat err.txt
|
||||
exit ${ecode}
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
upgrade
|
||||
|
||||
set -eu
|
||||
|
||||
dnf install -y sed findutils glib-networking json-glib libssh openssl python3
|
||||
|
||||
dnf clean all
|
||||
16
bots/images/scripts/lib/build-deps.sh
Executable file
16
bots/images/scripts/lib/build-deps.sh
Executable file
|
|
@ -0,0 +1,16 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -eu
|
||||
|
||||
# Download cockpit.spec, replace `npm-version` macro and then query all build requires
|
||||
curl -s https://raw.githubusercontent.com/cockpit-project/cockpit/master/tools/cockpit.spec |
|
||||
sed 's/%{npm-version:.*}/0/' |
|
||||
sed '/Recommends:/d' |
|
||||
rpmspec -D "$1" --buildrequires --query /dev/stdin |
|
||||
sed 's/.*/"&"/' |
|
||||
tr '\n' ' '
|
||||
|
||||
# support for backbranches
|
||||
if [ "$1" = "rhel 7" ] || [ "$1" = "centos 7" ]; then
|
||||
echo "golang-bin golang-src"
|
||||
fi
|
||||
35
bots/images/scripts/lib/containers.install
Executable file
35
bots/images/scripts/lib/containers.install
Executable file
|
|
@ -0,0 +1,35 @@
|
|||
#!/bin/bash
|
||||
# This file is part of Cockpit.
|
||||
#
|
||||
# Copyright (C) 2016 Red Hat, Inc.
|
||||
#
|
||||
# Cockpit is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published by
|
||||
# the Free Software Foundation; either version 2.1 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Cockpit is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with Cockpit; If not, see <http://www.gnu.org/licenses/>.
|
||||
set -ex
|
||||
|
||||
# HACK: docker falls over regularly, print its log if it does
|
||||
systemctl start docker || journalctl -u docker
|
||||
|
||||
for NAME in bastion
|
||||
do
|
||||
mkdir -p "/var/tmp/containers/$NAME/rpms"
|
||||
cp -f /var/tmp/build-results/*.rpm "/var/tmp/containers/$NAME/rpms/"
|
||||
cd "/var/tmp/containers/$NAME/"
|
||||
sed -i -e "s#FROM .*#FROM cockpit/base#" Dockerfile
|
||||
docker build --build-arg OFFLINE=1 -t "cockpit/$NAME" . 1>&2;
|
||||
rm -r "/var/tmp/containers/$NAME/rpms"
|
||||
done
|
||||
|
||||
journalctl --flush || true
|
||||
journalctl --sync || killall systemd-journald || true
|
||||
rm -rf /var/log/journal/* || true
|
||||
36
bots/images/scripts/lib/debian.bootstrap
Executable file
36
bots/images/scripts/lib/debian.bootstrap
Executable file
|
|
@ -0,0 +1,36 @@
|
|||
#! /bin/bash
|
||||
|
||||
set -ex
|
||||
|
||||
BASE=$(dirname $(dirname $0))
|
||||
|
||||
out=$1
|
||||
arch=$2
|
||||
virt_builder_image="$3"
|
||||
if [ -n "$4" ]; then
|
||||
apt_source="$4"
|
||||
fi
|
||||
|
||||
if [ "$VIRT_BUILDER_NO_CACHE" == "yes" ]; then
|
||||
virt_builder_caching="--no-cache"
|
||||
fi
|
||||
|
||||
# 18.04 virt-builder image has an invalid apt proxy leftover; delete it
|
||||
virt-builder $virt_builder_image \
|
||||
$virt_builder_caching \
|
||||
--output "$out" \
|
||||
--size 8G \
|
||||
--format qcow2 \
|
||||
--arch "$arch" \
|
||||
--root-password password:foobar \
|
||||
--ssh-inject root:file:$BASE/../../machine/identity.pub \
|
||||
--upload $BASE/../../machine/host_key:/etc/ssh/ssh_host_rsa_key \
|
||||
--chmod 0600:/etc/ssh/ssh_host_rsa_key \
|
||||
--upload $BASE/../../machine/host_key.pub:/etc/ssh/ssh_host_rsa_key.pub \
|
||||
${apt_source:+--write /etc/apt/sources.list:"$apt_source"} \
|
||||
--write /etc/apt/apt.conf.d/90nolanguages:'Acquire::Languages "none";' \
|
||||
--run-command "sed -i 's/GRUB_TIMEOUT.*/GRUB_TIMEOUT=0/; /GRUB_CMDLINE_LINUX=/ s/"'"'"$/ console=ttyS0,115200 net.ifnames=0 biosdevname=0"'"'"/' /etc/default/grub" \
|
||||
--run-command "update-grub" \
|
||||
--run-command "sed -i 's/ens[^[:space:]:]*/eth0/' /etc/network/interfaces /etc/netplan/*.yaml || true" \
|
||||
--run-command "rm --verbose -f /etc/apt/apt.conf" \
|
||||
--run-command "export DEBIAN_FRONTEND=noninteractive; apt-get -y update; apt-get -y install eatmydata; eatmydata apt-get -y dist-upgrade"
|
||||
92
bots/images/scripts/lib/debian.install
Executable file
92
bots/images/scripts/lib/debian.install
Executable file
|
|
@ -0,0 +1,92 @@
|
|||
#! /bin/sh
|
||||
|
||||
set -ex
|
||||
|
||||
export DEB_BUILD_OPTIONS=""
|
||||
|
||||
do_build=
|
||||
do_install=
|
||||
stdout_dest="/dev/null"
|
||||
args=$(getopt -o "vqs:" -l "verbose,quick,skip:,build,install" -- "$@")
|
||||
eval set -- "$args"
|
||||
while [ $# -gt 0 ]; do
|
||||
case $1 in
|
||||
-v|--verbose)
|
||||
stdout_dest="/dev/stdout"
|
||||
;;
|
||||
-q|--quick)
|
||||
DEB_BUILD_OPTIONS="$DEB_BUILD_OPTIONS nocheck"
|
||||
;;
|
||||
--build)
|
||||
do_build=t
|
||||
;;
|
||||
--install)
|
||||
do_install=t
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
break
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
tar="$1"
|
||||
|
||||
|
||||
# Build
|
||||
|
||||
if [ -n "$do_build" ]; then
|
||||
rm -rf build-results
|
||||
mkdir build-results
|
||||
resultdir=$PWD/build-results
|
||||
upstream_ver=$(ls cockpit-*.tar.gz | sed 's/^.*-//; s/.tar.gz//' | head -n1)
|
||||
|
||||
ln -sf cockpit-*.tar.gz cockpit_${upstream_ver}.orig.tar.gz
|
||||
|
||||
rm -rf cockpit-*/
|
||||
tar -xzf cockpit-*.tar.gz
|
||||
( cd cockpit-*/
|
||||
cp -rp tools/debian debian
|
||||
# put proper version into changelog, as we have versioned dependencies
|
||||
sed -i "1 s/(.*)/($upstream_ver-1)/" debian/changelog
|
||||
# Hack: Remove PCP build dependencies while pcp is not in testing
|
||||
# (https://tracker.debian.org/pcp)
|
||||
sed -i '/libpcp.*-dev/d' debian/control
|
||||
dpkg-buildpackage -S -uc -us -nc
|
||||
)
|
||||
|
||||
# Some unit tests want a real network interface
|
||||
echo USENETWORK=yes >>~/.pbuilderrc
|
||||
|
||||
# pbuilder < 0.228.6 has broken /dev/pts/ptmx permissions; affects Ubuntu < 17.04
|
||||
# see https://bugs.debian.org/841935
|
||||
if ! grep -q ptmxmode /usr/lib/pbuilder/pbuilder-modules; then
|
||||
echo "Fixing /dev/pts/ptmx mode in pbuilder"
|
||||
sed -i '/mount -t devpts none/ s/$/,ptmxmode=666,newinstance/' /usr/lib/pbuilder/pbuilder-modules
|
||||
fi
|
||||
|
||||
pbuilder build --buildresult "$resultdir" \
|
||||
--logfile "$resultdir/build.log" \
|
||||
cockpit_${upstream_ver}-1.dsc >$stdout_dest
|
||||
lintian $resultdir/cockpit_*_$(dpkg --print-architecture).changes >&2
|
||||
fi
|
||||
|
||||
# Install
|
||||
|
||||
if [ -n "$do_install" ]; then
|
||||
packages=$(find build-results -name "*.deb")
|
||||
dpkg --install $packages
|
||||
|
||||
# FIXME: our tests expect cockpit.socket to not be running after boot, only
|
||||
# after start_cockpit().
|
||||
systemctl disable cockpit.socket
|
||||
|
||||
# HACK: tuned breaks QEMU (https://launchpad.net/bugs/1774000)
|
||||
systemctl disable tuned.service 2>/dev/null || true
|
||||
|
||||
firewall-cmd --add-service=cockpit --permanent
|
||||
|
||||
journalctl --flush
|
||||
journalctl --sync || killall systemd-journald
|
||||
rm -rf /var/log/journal/*
|
||||
fi
|
||||
36
bots/images/scripts/lib/docker-images.setup
Executable file
36
bots/images/scripts/lib/docker-images.setup
Executable file
|
|
@ -0,0 +1,36 @@
|
|||
#!/bin/bash
|
||||
set -ex
|
||||
|
||||
# This file is part of Cockpit.
|
||||
#
|
||||
# Copyright (C) 2016 Red Hat, Inc.
|
||||
#
|
||||
# Cockpit is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published by
|
||||
# the Free Software Foundation; either version 2.1 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Cockpit is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with Cockpit; If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if [ $(uname -m) = x86_64 ]; then
|
||||
docker pull busybox:latest
|
||||
docker pull busybox:buildroot-2014.02
|
||||
docker pull gcr.io/google_containers/pause:0.8.0
|
||||
docker pull k8s.gcr.io/pause-amd64:3.1
|
||||
# some aliases for different k8s variants
|
||||
docker tag k8s.gcr.io/pause-amd64:3.1 gcr.io/google_containers/pause-amd64:3.0
|
||||
docker tag k8s.gcr.io/pause-amd64:3.1 k8s.gcr.io/pause:3.1
|
||||
fi
|
||||
|
||||
# Download the i386 image and rename it
|
||||
if [ $(uname -m) = i686 ]; then
|
||||
docker pull i386/busybox:latest
|
||||
docker tag docker.io/i386/busybox busybox
|
||||
docker rmi docker.io/i386/busybox
|
||||
fi
|
||||
116
bots/images/scripts/lib/fedora.install
Executable file
116
bots/images/scripts/lib/fedora.install
Executable file
|
|
@ -0,0 +1,116 @@
|
|||
#! /bin/bash
|
||||
|
||||
set -ex
|
||||
|
||||
# don't update already installed cockpit packages
|
||||
installed=$(rpm --query --all --queryformat "%{NAME}-\[0-9\]\n" "cockpit*")
|
||||
skip="cockpit-doc-[0-9]"
|
||||
if [ -n "$installed" ]; then
|
||||
skip="$skip
|
||||
$installed"
|
||||
fi
|
||||
|
||||
do_build=
|
||||
do_install=
|
||||
# we build RHEL 7.x in a CentOS mock, thus we can't parse os-release in the .spec
|
||||
mock_opts="--define='os_version_id $(. /etc/os-release; echo $VERSION_ID)'"
|
||||
args=$(getopt -o "vqs:" -l "verbose,quick,skip:,build,install,rhel,HACK-no-bootstrap-chroot" -- "$@")
|
||||
eval set -- "$args"
|
||||
while [ $# -gt 0 ]; do
|
||||
case $1 in
|
||||
-v|--verbose)
|
||||
mock_opts="$mock_opts --verbose"
|
||||
;;
|
||||
-q|--quick)
|
||||
mock_opts="$mock_opts --nocheck --define='selinux 0'"
|
||||
;;
|
||||
-s|--skip)
|
||||
skip="$skip
|
||||
$2"
|
||||
shift
|
||||
;;
|
||||
--build)
|
||||
do_build=t
|
||||
;;
|
||||
--install)
|
||||
do_install=t
|
||||
;;
|
||||
--rhel)
|
||||
# For RHEL we actually build in EPEL, which is based
|
||||
# on CentOS. On CentOS, the spec file has both
|
||||
# %centos and %rhel defined, but it gives precedence
|
||||
# to %centos, as it must. To make it produce the RHEL
|
||||
# packages, we explicitly undefine %centos here.
|
||||
mock_opts="$mock_opts --define='centos 0'"
|
||||
;;
|
||||
--HACK-no-bootstrap-chroot)
|
||||
mock_opts="$mock_opts --no-bootstrap-chroot"
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
break
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
tar=$1
|
||||
|
||||
# Build
|
||||
|
||||
if [ -n "$do_build" ]; then
|
||||
# Some tests need a non-loopback internet address, so we allow
|
||||
# networking during build. Note that we use "--offline" below, so
|
||||
# we should still be protected against unexpected package
|
||||
# installations.
|
||||
echo "config_opts['rpmbuild_networking'] = True" >>/etc/mock/site-defaults.cfg
|
||||
# don't destroy the mock after building, we want to run rpmlint
|
||||
echo "config_opts['cleanup_on_success'] = False" >>/etc/mock/site-defaults.cfg
|
||||
# HACK: don't fall over on unavailable repositories, as we are offline
|
||||
# (https://bugzilla.redhat.com/show_bug.cgi?id=1549291)
|
||||
sed --follow-symlinks -i '/skip_if_unavailable=False/d' /etc/mock/default.cfg
|
||||
|
||||
rm -rf build-results
|
||||
srpm=$(/var/lib/testvm/make-srpm "$tar")
|
||||
LC_ALL=C.UTF-8 su builder -c "/usr/bin/mock --offline --no-clean --resultdir build-results $mock_opts --rebuild $srpm"
|
||||
|
||||
su builder -c "/usr/bin/mock --offline --shell" <<EOF
|
||||
rm -rf /builddir/build
|
||||
if type rpmlint >/dev/null 2>&1; then
|
||||
# blacklist "E: no-changelogname-tag" rpmlint error, expected due to our template cockpit.spec
|
||||
mkdir -p ~/.config
|
||||
echo 'addFilter("E: no-changelogname-tag")' > ~/.config/rpmlint
|
||||
# we expect the srpm to be clean
|
||||
echo
|
||||
echo '====== rpmlint on srpm ====='
|
||||
rpmlint /builddir/build/SRPMS/*.src.rpm
|
||||
# this still has lots of errors, run it for information only
|
||||
echo
|
||||
echo '====== rpmlint binary rpms (advisory) ====='
|
||||
rpmlint /builddir/build/RPMS/ || true
|
||||
else
|
||||
echo '====== skipping rpmlint check, not installed ====='
|
||||
fi
|
||||
EOF
|
||||
fi
|
||||
|
||||
# Install
|
||||
|
||||
if [ -n "$do_install" ]; then
|
||||
packages=$(find build-results -name "*.rpm" -not -name "*.src.rpm" | grep -vG "$skip")
|
||||
rpm -U --force $packages
|
||||
|
||||
if type firewall-cmd > /dev/null 2> /dev/null; then
|
||||
systemctl start firewalld
|
||||
firewall-cmd --add-service=cockpit --permanent
|
||||
fi
|
||||
|
||||
# Make sure we clean out the journal
|
||||
journalctl --flush
|
||||
journalctl --sync || killall systemd-journald
|
||||
rm -rf /var/log/journal/*
|
||||
rm -rf /var/lib/NetworkManager/dhclient-*.lease
|
||||
fi
|
||||
|
||||
if [ -n "$do_build" ]; then
|
||||
su builder -c "/usr/bin/mock --clean"
|
||||
fi
|
||||
46
bots/images/scripts/lib/kubernetes.setup
Executable file
46
bots/images/scripts/lib/kubernetes.setup
Executable file
|
|
@ -0,0 +1,46 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Kubernetes is delivered in a non-functional state on Fedora and similar operating systems
|
||||
# The following commands are needed to get it running.
|
||||
|
||||
cd /etc/kubernetes/
|
||||
|
||||
cat <<EOF > openssl.conf
|
||||
oid_section = new_oids
|
||||
[new_oids]
|
||||
[req]
|
||||
encrypt_key = no
|
||||
string_mask = nombstr
|
||||
req_extensions = v3_req
|
||||
distinguished_name = v3_name
|
||||
[v3_name]
|
||||
commonName = kubernetes
|
||||
[v3_req]
|
||||
basicConstraints = CA:FALSE
|
||||
subjectAltName = @alt_names
|
||||
[alt_names]
|
||||
DNS.1 = kubernetes
|
||||
DNS.2 = kubernetes.default
|
||||
DNS.3 = kubernetes.default.svc
|
||||
DNS.4 = kubernetes.default.svc.cluster.local
|
||||
IP.1 = 127.0.0.1
|
||||
IP.2 = 10.254.0.1
|
||||
EOF
|
||||
|
||||
openssl genrsa -out ca.key 2048
|
||||
openssl req -x509 -new -nodes -key ca.key -days 3072 -out ca.crt -subj '/CN=kubernetes'
|
||||
openssl genrsa -out server.key 2048
|
||||
openssl req -config openssl.conf -new -key server.key -out server.csr -subj '/CN=kubernetes'
|
||||
openssl x509 -req -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out server.crt -days 3072 -extensions v3_req -extfile openssl.conf
|
||||
# make keys readable for "kube" group and thus for kube-apiserver.service on newer OSes
|
||||
if getent group kube >/dev/null; then
|
||||
chgrp kube ca.key server.key
|
||||
chmod 640 ca.key server.key
|
||||
fi
|
||||
|
||||
echo -e '{"user":"admin"}\n{"user":"scruffy","readonly": true}' > /etc/kubernetes/authorization
|
||||
echo -e 'fubar,admin,10101\nscruffy,scruffy,10102' > /etc/kubernetes/passwd
|
||||
|
||||
echo 'KUBE_API_ARGS="--service-account-key-file=/etc/kubernetes/server.key --client-ca-file=/etc/kubernetes/ca.crt --tls-cert-file=/etc/kubernetes/server.crt --tls-private-key-file=/etc/kubernetes/server.key --basic-auth-file=/etc/kubernetes/passwd --authorization-mode=ABAC --authorization-policy-file=/etc/kubernetes/authorization"' >> apiserver
|
||||
echo 'KUBE_CONTROLLER_MANAGER_ARGS="--root-ca-file=/etc/kubernetes/ca.crt --service-account-private-key-file=/etc/kubernetes/server.key"' >> controller-manager
|
||||
|
||||
33
bots/images/scripts/lib/make-srpm
Executable file
33
bots/images/scripts/lib/make-srpm
Executable file
|
|
@ -0,0 +1,33 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -eu
|
||||
|
||||
tar=$1
|
||||
|
||||
version=$(echo "$1" | sed -n 's|.*cockpit-\([^ /-]\+\)\.tar\..*|\1|p')
|
||||
if [ -z "$version" ]; then
|
||||
echo "make-srpm: couldn't parse version from tarball: $1"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# We actually modify the spec so that the srpm is standalone buildable
|
||||
modify_spec() {
|
||||
sed -e "/^Version:.*/d" -e "1i\
|
||||
%define wip wip\nVersion: $version\n"
|
||||
}
|
||||
|
||||
tmpdir=$(mktemp -d $PWD/srpm-build.XXXXXX)
|
||||
tar xaf "$1" -O cockpit-$version/tools/cockpit.spec | modify_spec > $tmpdir/cockpit.spec
|
||||
|
||||
rpmbuild -bs \
|
||||
--quiet \
|
||||
--define "_sourcedir $(dirname $1)" \
|
||||
--define "_specdir $tmpdir" \
|
||||
--define "_builddir $tmpdir" \
|
||||
--define "_srcrpmdir `pwd`" \
|
||||
--define "_rpmdir $tmpdir" \
|
||||
--define "_buildrootdir $tmpdir/.build" \
|
||||
$tmpdir/cockpit.spec
|
||||
|
||||
rpm --qf '%{Name}-%{Version}-%{Release}.src.rpm\n' -q --specfile $tmpdir/cockpit.spec | head -n1
|
||||
rm -rf $tmpdir
|
||||
BIN
bots/images/scripts/lib/pubring.gpg
Normal file
BIN
bots/images/scripts/lib/pubring.gpg
Normal file
Binary file not shown.
BIN
bots/images/scripts/lib/secring.gpg
Normal file
BIN
bots/images/scripts/lib/secring.gpg
Normal file
Binary file not shown.
51
bots/images/scripts/lib/zero-disk.setup
Executable file
51
bots/images/scripts/lib/zero-disk.setup
Executable file
|
|
@ -0,0 +1,51 @@
|
|||
#!/bin/bash
|
||||
|
||||
# This file is part of Cockpit.
|
||||
#
|
||||
# Copyright (C) 2016 Red Hat, Inc.
|
||||
#
|
||||
# Cockpit is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published by
|
||||
# the Free Software Foundation; either version 2.1 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Cockpit is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with Cockpit; If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# We don't want to delete the pbuilder caches since we need them
|
||||
# during build. Mock with --offline and dnf is happy without caches,
|
||||
# but with yum it isn't, so we provide an option to also leave the
|
||||
# mock caches in place.
|
||||
#
|
||||
# We also want to keep cracklib since otherwise password quality
|
||||
# checks break on Debian.
|
||||
|
||||
if [ -f /root/.skip-zero-disk ]; then
|
||||
echo "Skipping zero-disk.setup as /root/.skip-zero-disk exists"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
keep="! -path /var/cache/pbuilder ! -path /var/cache/cracklib ! -path /var/cache/tomcat"
|
||||
while [ $# -gt 0 ]; do
|
||||
case $1 in
|
||||
--keep-mock-cache)
|
||||
keep="$keep ! -path /var/cache/mock"
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if [ -d "/var/cache" ]; then
|
||||
find /var/cache/* -maxdepth 0 -depth -name "*" $keep -exec rm -rf {} \;
|
||||
fi
|
||||
rm -rf /var/tmp/*
|
||||
rm -rf /var/log/journal/*
|
||||
|
||||
dd if=/dev/zero of=/root/junk || true
|
||||
sync
|
||||
rm -f /root/junk
|
||||
Loading…
Add table
Add a link
Reference in a new issue