From b1cb331711c23e5619deb09307fee40438b525a3 Mon Sep 17 00:00:00 2001 From: lcappelli <laura.cappelli@cnaf.infn.it> Date: Thu, 19 Jan 2023 17:54:18 +0000 Subject: [PATCH] Create a readme for developers in .devcontainer --- .devcontainer/README.md | 32 +++++++++++ .devcontainer/assets/build-library.sh | 81 +++++++++++++++++++++++++++ 2 files changed, 113 insertions(+) create mode 100644 .devcontainer/README.md create mode 100644 .devcontainer/assets/build-library.sh diff --git a/.devcontainer/README.md b/.devcontainer/README.md new file mode 100644 index 0000000..b4aaedd --- /dev/null +++ b/.devcontainer/README.md @@ -0,0 +1,32 @@ +# `ngx_http_voms_module` for developers + +A devcontainer is ready to use for the developers. A set of packages without nginx are already installed. + +## How to build and install nginx with or without httpg patch + +To build and install the last stable version of [nginx](http://nginx.org/en/download.html) (1.22.1) you have to copy the ```nginx.repo``` file (it is contained in the ```docker``` directory) into the ```/etc/yum.repos.d/``` directory and install nginx with yum: + +``` +$ sudo cp docker/nginx.repo /etc/yum.repos.d/ +$ sudo yum install -y nginx +``` + +Otherwise, if you want to build and install the last stable version of [nginx](http://nginx.org/en/download.html) (1.22.1) with the httpg patch, a bash library is ready to use. You can source it and follow the commands below: + +``` +$ source .devcontainer/assets/build-library.sh +$ downloadNginx +$ buildHttpgNginxRPM +$ sudo rpm -ivh ~/rpmbuild/RPMS/x86_64/nginx-httpg-1.22.1-1.el7.ngx.x86_64.rpm +``` + +## How to build and install the `ngx_http_voms_module` + +If you want to build and install the `ngx_http_voms_module`, nginx have to be installed in the container (see the previous section). When this requirement is satisfied, you can use the library contained in the ```.devcontainer/assets``` folder as follows (NOTE: if you have already download nginx source file, you can skip the relative command): + +``` +$ source .devcontainer/assets/build-library.sh +$ downloadNginx +$ buildVomsModuleRPM +$ sudo rpm -ivh ~/rpmbuild/RPMS/x86_64/nginx-module-http-voms-1.22.1-1.el7.x86_64.rpm +``` diff --git a/.devcontainer/assets/build-library.sh b/.devcontainer/assets/build-library.sh new file mode 100644 index 0000000..edcf244 --- /dev/null +++ b/.devcontainer/assets/build-library.sh @@ -0,0 +1,81 @@ +#!/usr/bin/env bash + +# Copyright 2018-2023 Istituto Nazionale di Fisica Nucleare +# SPDX-License-Identifier: EUPL-1.2 + +downloadNginx() { + +# check if a version of nginx is specified +if [ -z ${ngxVersion} ]; then + ngxVersion=1.22.1 +fi +echo "nginx version required: ${ngxVersion}"; + +# check if ~/rpmbuild exists and is not empty +if [ "$(ls -A ${HOME}/rpmbuild)" ]; +then + echo "Error: ${HOME}/rpmbuild already exists and is not empty" + return 1 +fi + +# setup rpmbuild dir +cat <<EOF > ${HOME}/.rpmmacros +%_topdir %{getenv:HOME}/rpmbuild +EOF +cd +rpmdev-setuptree + +# download nginx sources +cd ~/rpmbuild/SOURCES/ +wget http://nginx.org/packages/centos/7/SRPMS/nginx-$ngxVersion-1.el7.ngx.src.rpm +rpm2cpio nginx-$ngxVersion-1.el7.ngx.src.rpm | cpio -idm + +cd /workspaces/ngx_http_voms_module + +} + +buildHttpgNginxRPM() { + +if [ -z ${CI_PROJECT_DIR} ]; then + CI_PROJECT_DIR="/workspaces/ngx_http_voms_module"; +fi + +# set the nginx spec file with the httpg patch +cd ~/rpmbuild/SOURCES/ +cp ${CI_PROJECT_DIR}/nginx-httpg_no_delegation.patch ${HOME}/rpmbuild/SOURCES/ +cp ${CI_PROJECT_DIR}/rpm/nginx.spec ~/rpmbuild/SPECS + +# build rpm +rpmlint ~/rpmbuild/SPECS/nginx.spec +rpmbuild -ba ~/rpmbuild/SPECS/nginx.spec + +# include httpg in the rpm name +mv ~/rpmbuild/RPMS/x86_64/nginx-$ngxVersion-1.el7.ngx.x86_64.rpm ~/rpmbuild/RPMS/x86_64/nginx-httpg-$ngxVersion-1.el7.ngx.x86_64.rpm +mv ~/rpmbuild/RPMS/x86_64/nginx-debuginfo-$ngxVersion-1.el7.ngx.x86_64.rpm ~/rpmbuild/RPMS/x86_64/nginx-httpg-debuginfo-$ngxVersion-1.el7.ngx.x86_64.rpm +mv ~/rpmbuild/SRPMS/nginx-$ngxVersion-1.el7.ngx.src.rpm ~/rpmbuild/SRPMS/nginx-httpg-$ngxVersion-1.el7.ngx.src.rpm + +cd ${CI_PROJECT_DIR} + +} + +buildVomsModuleRPM() { + +if [ -z ${CI_PROJECT_DIR} ]; then + CI_PROJECT_DIR="/workspaces/ngx_http_voms_module"; +fi + +# set voms modules sources +cd ~/rpmbuild/SOURCES/ +mkdir ngx-http-voms-module +cp ${CI_PROJECT_DIR}/config ngx-http-voms-module/ +cp ${CI_PROJECT_DIR}/config.make ngx-http-voms-module/ +cp -r ${CI_PROJECT_DIR}/src ngx-http-voms-module/ +cp ${CI_PROJECT_DIR}/rpm/nginx-module-http-voms.spec ~/rpmbuild/SPECS + +# build rpm +rpmlint ~/rpmbuild/SPECS/nginx-module-http-voms.spec +rpmbuild -ba ~/rpmbuild/SPECS/nginx-module-http-voms.spec + +cd ${CI_PROJECT_DIR} + +} -- GitLab