#
# spec file for jenkins-scripts
#

Name:           jenkins-scripts
Version:        1.4.5
%if 0%{?opensuse_bs}
Release:        1.<CI_CNT>.<B_CNT>
%else
Release:        1
%endif
License:        GPLv2
Summary:        An extendable backend scripts for jenkins
Url:            http://www.tizen.org
Group:          Development/Tools/Building
Source:         %{name}-%{version}.tar.gz
Requires:       %{name}-common = %{version}-%{release}
Requires:       %{name}-submitobs = %{version}-%{release}
Requires:       %{name}-tzs = %{version}-%{release}
Requires:       %{name}-init = %{version}-%{release}
BuildArch:      noarch

%define destdir /var/lib/jenkins/%{name}
%define destinitdir /var/lib/jenkins/init.groovy.d

%description
Jenkins build job will call this scripts when build job is triggered by
Gerrit/OBS event.

%package common
Summary:    Common API for all instances
Group:      Development/Tools/Building
Requires:   createrepo_c
Requires:   git-core
Requires:   tizen-gbp-rpm >= 20131017
Requires:   python-beautifulsoup4
Requires:   python-cheetah
Requires:   python-redis
Requires:   python-requests >= 2.0.1
Requires:   python-snapdiff
Requires:   python-yaml
Requires:   python-lxml
Requires:   python-mysql
Requires:   gbs-api

%description common
Common part of jenkins scripts

%package tzs
Summary:    Scripts for tzs customer appliance
Group:      Development/Tools/Building
Requires:   %{name}-common = %{version}-%{release}

%description tzs
Jenkins scripts for tzs customer appliance instance

%package init
Summary:    Groovy init scripts for jenkins startup
Group:      Development/Tools/Building

%description init
Groovy init scripts for jenkins startup

%package submitobs
Summary:    Temporary package to isolate job_submitobs
Group:      Development/Tools/Building
Requires:   %{name}-common = %{version}-%{release}

%description submitobs
Isolated job_submitobs to avoid package installation conflicts

%prep
%setup -q

%build

%install
install -d %{buildroot}%{destdir}
cp -r job_*.py dir-purge-tool.sh logs-collector.sh common obs_requests templates scripts vis dep_graph %{buildroot}%{destdir}/
install -d %{buildroot}%{destinitdir}
cp -r groovy_init_scripts/* %{buildroot}%{destinitdir}/

%post common
if [ ! -d /var/lib/jenkins/userContent ]; then
  mkdir -p /var/lib/jenkins/userContent
fi
ln -sf %{destdir} /var/lib/jenkins/userContent/

%postun common
# remove link only when uninstall the package
if [ ${1:-0} -eq 0 ]; then
  if [ -L /var/lib/jenkins/userContent/jenkins-scripts ]; then
    rm -f /var/lib/jenkins/userContent/jenkins-scripts
  fi
fi

%files
%defattr(-,jenkins,jenkins)
%dir /var/lib/jenkins/
%dir %{destdir}
%{destdir}/job_post_image.py
%{destdir}/job_local_cache_cleanups.py
%{destdir}/job_pre_release_obs.py
%{destdir}/job_publish_test_results.py
%{destdir}/job_request.py
%{destdir}/job_test_build.py
%{destdir}/job_rpm_buildlogs.py
%{destdir}/obs_requests
%{destdir}/common/tempbuildpkg.py
%{destdir}/dir-purge-tool.sh
%{destdir}/logs-collector.sh

%files common
%defattr(-,jenkins,jenkins)
%doc doc/RELEASE_NOTES
%dir %{destdir}/common
%{destdir}/common/__init__.py
%{destdir}/common/backenddb.py
%{destdir}/common/builddata.py
%{destdir}/common/buildservice.py
%{destdir}/common/buildtrigger.py
%{destdir}/common/gerrit.py
%{destdir}/common/git.py
%{destdir}/common/imagedata.py
%{destdir}/common/mapping.py
%{destdir}/common/obspkg.py
%{destdir}/common/prerelease.py
%{destdir}/common/repomaker.py
%{destdir}/common/runner.py
%{destdir}/common/send_mail.py
%{destdir}/common/snapshot.py
%{destdir}/common/utils.py
%{destdir}/common/manifest.py
%{destdir}/common/upload_service.py
%{destdir}/common/iris_rest_client.py
%{destdir}/common/apply_scm_meta_git.py
%{destdir}/common/check_scm_meta_git.py
%{destdir}/common/git_diff_parse.py
%{destdir}/common/buildmonitor_db.py
%{destdir}/common/git_obs_mapping.py
%{destdir}/job_re.py
%{destdir}/job_create_snapshot.py
%{destdir}/job_release_snapshot.py
%{destdir}/job_buildlogs.py
%{destdir}/job_jobs_dispatcher.py
%{destdir}/job_imager.py
%{destdir}/job_mail_sender.py
%{destdir}/job_load_repos.yaml.py
%{destdir}/job_sync_obs.py
%{destdir}/job_sync_snapdiff.py
%{destdir}/job_buildmonitor.py
%{destdir}/job_update_nuget.py
%{destdir}/job_add_git_tag.py
%{destdir}/job_repa.py
%{destdir}/job_trbs_test_result_receiver.py
%{destdir}/job_update_scm_meta_git_for_dashboard.py
%{destdir}/job_update_git_obs_mapping_for_dashboard.py
%{destdir}/job_update_git_branch_project_mapping_for_dashboard.py
%{destdir}/job_litmus_jira_issue_receiver.py
%{destdir}/job_litmus_tct_file_receiver.py
%dir %{destdir}/templates
%{destdir}/templates/index.html
%{destdir}/job_update_local_git.py
%{destdir}/job_monitor_scm_meta_git.py
%{destdir}/job_check_scm_meta_git.py
%dir %{destdir}/scripts
%{destdir}/scripts/check_section.sh
%{destdir}/scripts/get_git_desc_info.sh
%{destdir}/scripts/nuget.exe
%{destdir}/job_ref_snapshot_info_update.py
%{destdir}/job_ref_create_prj_obs.py
%{destdir}/job_ref_import_rpm_obs.py
%{destdir}/job_ref_purge_prj_obs.py
%{destdir}/job_test_trigger_info_update.py
%{destdir}/job_make_dep_graph.py
%{destdir}/common/dep_graph.php.template
%{destdir}/common/dep_graph.php.template_simple
%{destdir}/common/dep_parse.py
%dir %{destdir}/dep_graph
%{destdir}/dep_graph/dep_graph.css
%{destdir}/dep_graph/dep_graph.include.html
%{destdir}/dep_graph/dep_graph.js
%{destdir}/dep_graph/dep_graph_common.js
%{destdir}/dep_graph/dep_graph_full.include.html
%{destdir}/dep_graph/dep_graph_simple.js
%{destdir}/dep_graph/dep_graph_full.js
%{destdir}/dep_graph/slider.js
%dir %{destdir}/vis
%{destdir}/vis/CONTRIBUTING.md
%{destdir}/vis/HISTORY.md
%{destdir}/vis/LICENSE-APACHE-2.0
%{destdir}/vis/LICENSE-MIT
%{destdir}/vis/NOTICE
%{destdir}/vis/README.md
%dir %{destdir}/vis/dist
%{destdir}/vis/dist/vis-graph3d.min.js
%{destdir}/vis/dist/vis-network.min.js
%{destdir}/vis/dist/vis-timeline-graph2d.min.js
%{destdir}/vis/dist/vis.css
%{destdir}/vis/dist/vis.js
%{destdir}/vis/dist/vis.map
%{destdir}/vis/dist/vis.min.css
%{destdir}/vis/dist/vis.min.js
%dir %{destdir}/vis/dist/img
%dir %{destdir}/vis/dist/img/network
%{destdir}/vis/dist/img/network/acceptDeleteIcon.png
%{destdir}/vis/dist/img/network/addNodeIcon.png
%{destdir}/vis/dist/img/network/backIcon.png
%{destdir}/vis/dist/img/network/connectIcon.png
%{destdir}/vis/dist/img/network/cross.png
%{destdir}/vis/dist/img/network/cross2.png
%{destdir}/vis/dist/img/network/deleteIcon.png
%{destdir}/vis/dist/img/network/downArrow.png
%{destdir}/vis/dist/img/network/editIcon.png
%{destdir}/vis/dist/img/network/leftArrow.png
%{destdir}/vis/dist/img/network/minus.png
%{destdir}/vis/dist/img/network/plus.png
%{destdir}/vis/dist/img/network/rightArrow.png
%{destdir}/vis/dist/img/network/upArrow.png
%{destdir}/vis/dist/img/network/zoomExtends.png
%dir %{destdir}/vis/dist/img/timeline
%{destdir}/vis/dist/img/timeline/delete.png


%files tzs
%defattr(-,jenkins,jenkins)
%{destdir}/job_submit.py

%files init
%defattr(-,jenkins,jenkins)
%dir /var/lib/jenkins/
%dir %{destinitdir}/
%{destinitdir}/init.groovy
%{destinitdir}/setup.properties.example
%{destinitdir}/Module_AmazonEC2Cloud
%{destinitdir}/Module_AmazonEC2Slave
%{destinitdir}/Module_AwsCredentials
%{destinitdir}/Module_Executors
%{destinitdir}/Module_GerritServer
%{destinitdir}/Module_Ldap
%{destinitdir}/Module_LocationConfig
%{destinitdir}/Module_Mailer
%{destinitdir}/Module_MatrixAuthorization
%{destinitdir}/Module_Node
%{destinitdir}/Module_RabbitmqConsumer
%{destinitdir}/Module_SshCredentials

%files submitobs
%defattr(-,jenkins,jenkins)
%{destdir}/job_submitobs.py

%changelog
