summaryrefslogtreecommitdiff
path: root/obs_example
diff options
context:
space:
mode:
Diffstat (limited to 'obs_example')
-rw-r--r--obs_example/Dockerfile19
-rw-r--r--obs_example/fissile_example_spec.yml11
-rwxr-xr-xobs_example/obs_pkg_mgr70
3 files changed, 100 insertions, 0 deletions
diff --git a/obs_example/Dockerfile b/obs_example/Dockerfile
new file mode 100644
index 0000000..56101f2
--- /dev/null
+++ b/obs_example/Dockerfile
@@ -0,0 +1,19 @@
+FROM opensuse:latest
+
+# Make obs_pkg_mgr available
+ARG OBS_REPOSITORY_URL
+ADD obs_pkg_mgr /usr/bin/obs_pkg_mgr
+RUN chmod +x /usr/bin/obs_pkg_mgr
+
+RUN obs_pkg_mgr add_repo http://download.opensuse.org/repositories/Virtualization:/containers/openSUSE_Leap_42.2/ "Virtualization:Containers (openSUSE_Leap_42.2)" && ls ; obs_pkg_mgr add_repo http://example.com/my_project:/mysubproject/my_package/ "My example project" && ls
+
+RUN obs_pkg_mgr install util-linux calcurse # amarok
+RUN obs_pkg_mgr install awk gcc \
+ which
+
+RUN ls # irrelevant command before additional dependencies
+
+RUN obs_pkg_mgr install glibc \
+ file-magic && ls ; ls -la ; obs_pkg_mgr install nethogs
+
+RUN obs_pkg_mgr install ssh-contact dumb-init; ls && ls -la
diff --git a/obs_example/fissile_example_spec.yml b/obs_example/fissile_example_spec.yml
new file mode 100644
index 0000000..729235d
--- /dev/null
+++ b/obs_example/fissile_example_spec.yml
@@ -0,0 +1,11 @@
+Name: "uaa-fissile-package"
+Version: 0.0
+Release: 0
+Summary: This package generates docker images for uaa-fissile-release
+License: [TBD]
+Description: "This is a very long description"
+DockerImageDeps:
+ - "fissile-dev:201707081450"
+Build: "./build"
+Artifacts:
+ - ".bosh/cache/*"
diff --git a/obs_example/obs_pkg_mgr b/obs_example/obs_pkg_mgr
new file mode 100755
index 0000000..0c30d7a
--- /dev/null
+++ b/obs_example/obs_pkg_mgr
@@ -0,0 +1,70 @@
+#!/bin/bash
+VERSION="0.1"
+DESCRIPTION="Command/Subcommand line script template"
+
+usage() {
+ echo "Usage: $0 (install|add_repo) args" 1>&2; exit 1;
+}
+function disable_repos {
+ # Disable all repos
+ for repo in "${repos[@]}"; do
+ zypper modifyrepo -d $repo
+ done
+
+ # Add OBS repository
+ zypper ar $OBS_REPOSITORY_URL obs_repository
+}
+
+function enable_repos {
+ # Remove our obs repository
+ zypper rr obs_repository
+
+ # Enable all repos
+ for repo in "${repos[@]}"; do
+ zypper modifyrepo -e $repo
+ done
+}
+
+install() {
+ shift # remove the subcommand
+
+ # Get enables repos and store them so we can enable them in the end.
+ readarray -t repos <<< "$(zypper ls -E | grep "Yes" | awk '{print $1}' )"
+
+ [ ! -z "$OBS_REPOSITORY_URL" ] && disable_repos
+
+ zypper ref
+ # TODO: use the "-r" option to avoid disabling/enabling repos
+ zypper --no-gpg-checks -n in "$@"
+
+ [ ! -z "$OBS_REPOSITORY_URL" ] && enable_repos
+}
+
+# Currently only this format is supported:
+# obs_pkg_mgr add_repo <URI> <alias>
+# obs_pkg_mgr add_repo <URI> <alias>
+add_repo() {
+ shift # remove the subcommand
+
+ # No need to refresh the repo if we are inside OBS
+ if [ ! -z "$OBS_REPOSITORY_URL" ]; then
+ zypper ar -C -G "$@"
+ else
+ zypper ar -G "$@"
+ fi
+}
+
+case "$1" in
+ install)
+ install "$@"
+ ;;
+ add_repo)
+ add_repo "$@"
+ ;;
+ *)
+ usage
+ exit 1
+ ;;
+esac
+
+exit 0;