diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..7727dbe --- /dev/null +++ b/Makefile @@ -0,0 +1,2 @@ +%: + $(MAKE) -C src/ $@ diff --git a/README.chef.md b/README.chef.md new file mode 100644 index 0000000..6d0e826 --- /dev/null +++ b/README.chef.md @@ -0,0 +1,96 @@ +# Software Público - configuration management + +## Requirements + +* [chake](https://rubygems.org/gems/chake) +* rake + +For development + +* vagrant +* shunit2 +* moreutils +* redir + +## Configuration parameters + +All configuration parameters are defined in `nodes.yaml`, with exception of IP +addresses, which are defined in different files: + +- for local development, the IP addresses of the Vagrant VMs are defined in + config/local/ips.yaml. + +- for production, you need to create a new file called + `config/production/ips.yaml` + +You will probably not need to change nodes.yaml unless you are developing the +deployment process. + +## Deploy + +### Development + +First you have to bring up the development virtual machines: + +```bash +$ vagrant up +$ rake preconfig +$ rake bootstrap_common +``` + +Right now there are 5 VM's, so this might take a while. The basic commands for +deployment: + +```bash +$ rake # deploys all servers +$ rake nodes # lists all servers +$ rake converge:$server # deploys only $server +``` + +### Production + +* TODO: document adding the SSL key and certificate +* TODO: document creation of `prod.yaml`. +* TODO: document SSH configuration + +The very first step is + +``` +$ rake preconfig SPB_ENV=production +``` + +This will perform some initial configuration to the system that is required +before doing the actual deployment. + +After that: + +```bash +$ rake SPB_ENV=production # deploys all servers +$ rake nodes SPB_ENV=production # lists all servers +$ rake converge:$server SPB_ENV=production # deploys only $server +``` + +You can also do `export SPB_ENV=production` in your shell and omit it in the +`rake` calls. + +See the output of `rake -T` for other tasks. + +## Viewing the running site when developping locally + +Run: + +```bash +./server +``` + +Follow the on-screen instructions an browse to +[http://softwarepublico.dev/](http://softwarepublico.dev/). + +Note: this requires that your system will resolve `\*.dev` to `localhost`. +Google DNS servers will do that automatically, otherwise you might add the following entries to `/etc/hosts`: + +``` +127.0.53.53 softwarepublico.dev +127.0.53.53 listas.softwarepublico.dev +``` + diff --git a/README.md b/README.md index 6d0e826..e828f6d 100644 --- a/README.md +++ b/README.md @@ -1,96 +1,20 @@ -# Software Público - configuration management +# Software Público Brasileiro - desenvolvimento -## Requirements +## Organização -* [chake](https://rubygems.org/gems/chake) -* rake +Este repositório contém tanto o código fonte desenvolvimento especificamente +para o SPB, quando o código de gestão de configuração necessário para implantar +o ambiente do SPB. -For development +O código fonte dos componentes e pacotes desenvolvidos está no diretório +`src/`. Os demais diretórios contém código de gestão de configuração, +documentação, utilitários etc. -* vagrant -* shunit2 -* moreutils -* redir +## Fazendo um release -## Configuration parameters +* Atualize o número de versão no arquivo VERSION +* Execute `make release`. -All configuration parameters are defined in `nodes.yaml`, with exception of IP -addresses, which are defined in different files: - -- for local development, the IP addresses of the Vagrant VMs are defined in - config/local/ips.yaml. - -- for production, you need to create a new file called - `config/production/ips.yaml` - -You will probably not need to change nodes.yaml unless you are developing the -deployment process. - -## Deploy - -### Development - -First you have to bring up the development virtual machines: - -```bash -$ vagrant up -$ rake preconfig -$ rake bootstrap_common -``` - -Right now there are 5 VM's, so this might take a while. The basic commands for -deployment: - -```bash -$ rake # deploys all servers -$ rake nodes # lists all servers -$ rake converge:$server # deploys only $server -``` - -### Production - -* TODO: document adding the SSL key and certificate -* TODO: document creation of `prod.yaml`. -* TODO: document SSH configuration - -The very first step is - -``` -$ rake preconfig SPB_ENV=production -``` - -This will perform some initial configuration to the system that is required -before doing the actual deployment. - -After that: - -```bash -$ rake SPB_ENV=production # deploys all servers -$ rake nodes SPB_ENV=production # lists all servers -$ rake converge:$server SPB_ENV=production # deploys only $server -``` - -You can also do `export SPB_ENV=production` in your shell and omit it in the -`rake` calls. - -See the output of `rake -T` for other tasks. - -## Viewing the running site when developping locally - -Run: - -```bash -./server -``` - -Follow the on-screen instructions an browse to -[http://softwarepublico.dev/](http://softwarepublico.dev/). - -Note: this requires that your system will resolve `\*.dev` to `localhost`. -Google DNS servers will do that automatically, otherwise you might add the following entries to `/etc/hosts`: - -``` -127.0.53.53 softwarepublico.dev -127.0.53.53 listas.softwarepublico.dev -``` +## Implantação +Veja as instruções em README.chef.md. diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..c834cf4 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +5.0a0 diff --git a/cookbooks/colab/recipes/default.rb b/cookbooks/colab/recipes/default.rb index fe91b63..229de77 100644 --- a/cookbooks/colab/recipes/default.rb +++ b/cookbooks/colab/recipes/default.rb @@ -21,6 +21,11 @@ package 'colab-spb-theme' do notifies :restart, 'service[colab]' end +package 'colab-spb-theme' do + action :upgrade + notifies :restart, 'service[colab]' +end + directory '/etc/colab' do owner 'root' group 'root' diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000..71ffedc --- /dev/null +++ b/src/Makefile @@ -0,0 +1,49 @@ +VERSION = $(shell cat ../VERSION) +subdirs = colab-spb-plugin colab-spb-theme-plugin noosfero-spb + +dist_all = $(patsubst %, %-dist, $(subdirs)) +dist: $(dist_all) +$(dist_all): %-dist : % + if [ -f $*/Makefile ]; then make -C $* dist; fi + if [ -f $*/setup.py ]; then (cd $* && python setup.py sdist); fi + +clean_all = $(patsubst %, %-clean, $(subdirs)) +clean: $(clean_all) + $(MAKE) -C pkg-rpm/ clean + +$(clean_all): %-clean : % + if [ -f $*/Makefile ]; then make -C $* clean; fi + if [ -f $*/setup.py ]; then rm -rf $*/dist; fi + +release: + @if git tag | grep -q '^v$(VERSION)$$'; then \ + echo "E: version $(VERSION) already tagged. You need a new version number"; \ + false; \ + fi + echo '$(VERSION)' > colab-spb-plugin/VERSION + echo '$(VERSION)' > colab-spb-theme-plugin/VERSION + echo '$(VERSION)' > noosfero-spb/VERSION + $(MAKE) dist + cp noosfero-spb/dist/*.tar.* pkg-rpm/noosfero-spb/ + cp colab-spb-theme-plugin/dist/*.tar.* pkg-rpm/colab-spb-theme/ + cp colab-spb-plugin/dist/*.tar.* pkg-rpm/colab-spb-plugin/ + sed -i -e 's/^\(Version:\s*\).*/\1$(VERSION)/' \ + pkg-rpm/colab-spb-theme/colab-spb-theme.spec \ + pkg-rpm/colab-spb-plugin/colab-spb-plugin.spec \ + pkg-rpm/noosfero-spb/noosfero-spb.spec + git diff + @printf "Confirm release? [y/N]"; \ + read confirm; \ + if [ "$$confirm" = 'y' -o "$$confirm" = 'Y' ]; then \ + echo "SPB release $(VERSION)" > .commit_template; \ + git commit * --file .commit_template; \ + rm -f .commit_template; \ + else \ + echo 'Aborting at your request!'; \ + git checkout -- colab-spb-theme-plugin/VERSION noosfero-spb/VERSION colab-spb-plugin/VERSION ; \ + git checkout -- pkg-rpm/colab-spb-theme/ pkg-rpm/noosfero-spb/ pkg-rpm/colab-spb-plugin/ ; \ + false; \ + fi + # TODO add pkg-rpm/colab-spb-plugin to the git checkout all above + $(MAKE) -C pkg-rpm/ noosfero-spb-upload colab-spb-theme-upload colab-spb-plugin-upload + git tag $(VERSION) -s -m 'SPB Release $(VERSION)' diff --git a/src/colab-spb-plugin/.gitignore b/src/colab-spb-plugin/.gitignore index b22381c..f9bee13 100644 --- a/src/colab-spb-plugin/.gitignore +++ b/src/colab-spb-plugin/.gitignore @@ -2,3 +2,4 @@ *.pyc *.sw[po] *~ +dist/ diff --git a/src/colab-spb-plugin/MANIFEST.in b/src/colab-spb-plugin/MANIFEST.in index 0b792a7..298ee4f 100644 --- a/src/colab-spb-plugin/MANIFEST.in +++ b/src/colab-spb-plugin/MANIFEST.in @@ -1,5 +1,6 @@ include README.rst include MANIFEST.in +include VERSION recursive-include src/colab_spb/static * recursive-include src/colab_spb/locale * recursive-include src/colab_spb/templates * diff --git a/src/colab-spb-plugin/VERSION b/src/colab-spb-plugin/VERSION new file mode 100644 index 0000000..c834cf4 --- /dev/null +++ b/src/colab-spb-plugin/VERSION @@ -0,0 +1 @@ +5.0a0 diff --git a/src/colab-spb-plugin/setup.py b/src/colab-spb-plugin/setup.py index 07beb9d..fbb0b1c 100644 --- a/src/colab-spb-plugin/setup.py +++ b/src/colab-spb-plugin/setup.py @@ -11,9 +11,11 @@ install_requires = ['colab', 'colab_noosfero', 'colab_gitlab'] tests_require = [ ] +version = open('VERSION').read().strip() + setup( - name='colab-spb', - version='0.1.0', + name='colab-spb-plugin', + version=version, author='Macartur Sousa', author_email='macartur.sc@gmail.com', url='https://portal.softwarepublico.gov.br/gitlab/softwarepublico/colab-spb-plugin/', diff --git a/src/colab-spb-theme-plugin/Makefile b/src/colab-spb-theme-plugin/Makefile index 39bbac1..88fa65b 100644 --- a/src/colab-spb-theme-plugin/Makefile +++ b/src/colab-spb-theme-plugin/Makefile @@ -1,5 +1,5 @@ PACKAGE = colab-spb-theme -VERSION = 0.2.0 +VERSION = $(shell cat VERSION) DISTDIR = dist PACKAGE_NAME = $(PACKAGE)-$(VERSION) TARBALL = $(PACKAGE_NAME).tar.gz @@ -10,10 +10,10 @@ all: colab_dir=/usr/lib/colab dist: clean - mkdir -p $(DISTDIR)/$(PACKAGE_NAME) - tar --exclude=.git --exclude=$(DISTDIR) -cf - * | (cd $(DISTDIR)/$(PACKAGE_NAME) && tar xzf -) + mkdir -p $(DISTDIR)/$(PACKAGE_NAME) + tar --exclude=.git --exclude=$(DISTDIR) -cf - * | (cd $(DISTDIR)/$(PACKAGE_NAME) && tar xf -) cd $(DISTDIR) && tar -czf $(TARBALL) $(PACKAGE_NAME) - rm -r $(DISTDIR)/$(PACKAGE_NAME) + rm -r $(DISTDIR)/$(PACKAGE_NAME) clean: $(RM) $(TARBALL) $(RM) -r $(DISTDIR) diff --git a/src/colab-spb-theme-plugin/VERSION b/src/colab-spb-theme-plugin/VERSION new file mode 100644 index 0000000..c834cf4 --- /dev/null +++ b/src/colab-spb-theme-plugin/VERSION @@ -0,0 +1 @@ +5.0a0 diff --git a/src/noosfero-spb/.gitignore b/src/noosfero-spb/.gitignore index 327eb61..849ddff 100644 --- a/src/noosfero-spb/.gitignore +++ b/src/noosfero-spb/.gitignore @@ -1,2 +1 @@ -*.tar.gz -/noosfero-spb-* +dist/ diff --git a/src/noosfero-spb/Makefile b/src/noosfero-spb/Makefile index 396d399..b8b9e5f 100644 --- a/src/noosfero-spb/Makefile +++ b/src/noosfero-spb/Makefile @@ -1,5 +1,5 @@ PACKAGE = noosfero-spb -VERSION = 4.2.1 +VERSION = $(shell cat VERSION) DISTDIR = $(PACKAGE)-$(VERSION) TARBALL = $(DISTDIR).tar.gz @@ -11,13 +11,13 @@ themes_dir=/usr/lib/noosfero/public/designs/themes noosfero_dir=/usr/lib/noosfero dist: clean - mkdir $(DISTDIR) - tar --exclude=.git --exclude=$(DISTDIR) -cf - * | (cd $(DISTDIR) && tar xaf -) - tar --exclude=.git -czf $(TARBALL) $(DISTDIR) + mkdir -p dist/$(DISTDIR) + tar --exclude=.git --exclude=$(DISTDIR) -cf - * | (cd dist/$(DISTDIR) && tar xaf -) + cd dist && tar --exclude=.git -czf $(TARBALL) $(DISTDIR) + $(RM) -r dist/$(DISTDIR) clean: - $(RM) $(TARBALL) - $(RM) -r $(DISTDIR) + $(RM) -r dist/ install: install -d -m 0755 $(DESTDIR)/$(plugins_dir)/software_communities diff --git a/src/noosfero-spb/VERSION b/src/noosfero-spb/VERSION new file mode 100644 index 0000000..c834cf4 --- /dev/null +++ b/src/noosfero-spb/VERSION @@ -0,0 +1 @@ +5.0a0 diff --git a/src/pkg-rpm/.gitignore b/src/pkg-rpm/.gitignore index 0f3f38b..a60d366 100644 --- a/src/pkg-rpm/.gitignore +++ b/src/pkg-rpm/.gitignore @@ -1,2 +1,4 @@ /.obs /.config.mk +*/*.tar.* +/.virtualenv diff --git a/src/pkg-rpm/Makefile b/src/pkg-rpm/Makefile index f4f5b65..d07cd23 100644 --- a/src/pkg-rpm/Makefile +++ b/src/pkg-rpm/Makefile @@ -1,9 +1,9 @@ OBSPROJECT = isv:spb:devel COPR_PROJECT = softwarepublico/v5 -LOCAL_BUILD_DIR = $(PWD)/build +LOCAL_BUILD_DIR = $(CURDIR)/build # Vagrant environment does not accept links from/to shared folder -ifeq "$(PWD)" "/vagrant" +ifeq "/vagrant" "$(shell ls -1d /vagrant 2>/dev/null)" LOCAL_BUILD_DIR = /home/vagrant/rpmbuild endif @@ -57,7 +57,7 @@ checkout_packages_obs = $(patsubst %, %-checkout-obs, $(packages)) upload_packages_obs = $(patsubst %, %-upload-obs, $(packages)) diff_packages_obs = $(patsubst %, %-diff-obs, $(packages)) -.PHONY: $(build_packages) $(checkout_packages_obs) $(upload_packages_obs) $(diff_packages_obs) +.PHONY: $(build_packages) $(checkout_packages_obs) $(upload_packages_obs) $(diff_packages_obs) copr-cli ### Targets @@ -76,8 +76,14 @@ $(build_src_packages): %-build-src : % rm -f $(LOCAL_BUILD_DIR)/SRPMS/$*-*.src.rpm cd $* && $(BUILD_PREFIX) rpmbuild --define "_topdir $(LOCAL_BUILD_DIR)" -bs $*.spec --nodeps -$(upload_packages): %-upload : %-build-src % - copr-cli build $(COPR_PROJECT) $(LOCAL_BUILD_DIR)/SRPMS/$*-*.src.rpm --nowait +$(upload_packages): %-upload : %-build-src % copr-cli + .virtualenv/bin/copr-cli build $(COPR_PROJECT) $(LOCAL_BUILD_DIR)/SRPMS/$*-*.src.rpm --nowait + +copr-cli: .virtualenv/bin/copr-cli + +.virtualenv/bin/copr-cli: + virtualenv .virtualenv + .virtualenv/bin/pip install copr-cli ### OBS targets (deprecated) @@ -102,3 +108,8 @@ diff-obs: $(diff_packages_obs) status-obs st-obs: @$(MAKE) diff | diffstat -C + +clean: + rm -rf */*.tar.* + rm -rf build/ + rm -rf .virtualenv/ diff --git a/src/pkg-rpm/colab-deps/colab-deps.spec b/src/pkg-rpm/colab-deps/colab-deps.spec index ca8de63..dd44a16 100644 --- a/src/pkg-rpm/colab-deps/colab-deps.spec +++ b/src/pkg-rpm/colab-deps/colab-deps.spec @@ -1,6 +1,6 @@ Summary: Collaboration platform for communities (Python dependencies) Name: colab-deps -Version: 1.11.3 +Version: 1.11.4 Release: 25.1 Source0: colab-deps-%{version}.tar.gz License: Various diff --git a/src/pkg-rpm/colab-spb-plugin/colab-spb-plugin.spec b/src/pkg-rpm/colab-spb-plugin/colab-spb-plugin.spec new file mode 100644 index 0000000..7b6a1ce --- /dev/null +++ b/src/pkg-rpm/colab-spb-plugin/colab-spb-plugin.spec @@ -0,0 +1,45 @@ +Name: colab-spb-plugin +Version: 5.0a0 +Release: 1 +Summary: SPB-specific Colab plugin +License: GPL-3.0 +Group: Applications/Publishing +Url: https://softwarepublico.gov.br/gitlab/softwarepublico/softwarepublico +Source0: %{name}-%{version}.tar.gz +Requires: colab >= 1.11 +BuildArch: noarch +BuildRequires: colab, colab-deps >= 1.11.4, python-virtualenv + +%description +This package contains Colab plugin for the Software Público Brasileiro platform. + +%prep +%setup -q + +%build +# install colab and colab-des into virtualenv +rm -rf virtualenv +cp -r /usr/lib/colab virtualenv +PATH=$(pwd)/virtualenv/bin:$PATH pip install --use-wheel --no-index . +virtualenv --relocatable virtualenv + +rpm -ql colab-deps colab | sed '/^\/usr\/lib\/colab\// !d; s#/usr/lib/colab/##' > cleanup.list +while read f; do + if [ -f "virtualenv/$f" ]; then + rm -f "virtualenv/$f" + fi +done < cleanup.list +rm -f cleanup.list +find virtualenv -type d -empty -delete +rm -rf virtualenv/bin +rm -rf virtualenv/include + +%install + +install -d -m 0755 %{buildroot}/usr/lib +rm -rf %{buildroot}/usr/lib/colab +cp -r virtualenv %{buildroot}/usr/lib/colab + +%files +%defattr(-,root,root) +/usr/lib/colab diff --git a/src/pkg-rpm/colab-spb-theme/colab-spb-theme.spec b/src/pkg-rpm/colab-spb-theme/colab-spb-theme.spec index 369adb8..28b759d 100644 --- a/src/pkg-rpm/colab-spb-theme/colab-spb-theme.spec +++ b/src/pkg-rpm/colab-spb-theme/colab-spb-theme.spec @@ -1,6 +1,6 @@ Name: colab-spb-theme -Version: 0.2.0 +Version: 5.0a0 Release: 9.1 Summary: SPB-specific Colab theme License: GPL-3.0 -- libgit2 0.21.2