Skip to content

Commit

Permalink
make ccache and git tasks idempotent(ish)
Browse files Browse the repository at this point in the history
  • Loading branch information
rvagg committed Dec 31, 2015
1 parent cb25ff0 commit 4a1107f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
16 changes: 13 additions & 3 deletions setup/ansible-tasks/ccache.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,47 @@
# Downloads and installs ccache
# @requires: version=3.2.4

- name: CCache | Check ccache --version
shell: ccache --version
ignore_errors: True
register: ccache_version

- name: CCache | Download ccache-{{ version }}
get_url: url=http://samba.org/ftp/ccache/ccache-{{ version }}.tar.gz dest=/tmp/
register: new_archive
when: ccache_version.stdout.find('{{ version }}') == -1

- name: CCache | Extract ccache-{{ version }}
unarchive: src=/tmp/ccache-{{ version }}.tar.gz dest=/tmp/ copy=no
when: new_archive|changed
when: ccache_version.stdout.find('{{ version }}') == -1 and new_archive|changed

- name: CCache | Prepare for compilation by running configure
shell: ./configure chdir=/tmp/ccache-{{ version }} >> /dev/null
when: ccache_version.stdout.find('{{ version }}') == -1

- name: CCache | Compile ccache
shell: make chdir=/tmp/ccache-{{ version }} >> /dev/null
when: ccache_version.stdout.find('{{ version }}') == -1

- name: CCache | Install generated binary
command: install -c -m 755 ccache /usr/local/bin
args:
creates: /usr/local/bin/ccache
chdir: /tmp/ccache-{{ version }}
when: ccache_version.stdout.find('{{ version }}') == -1


- name: CCache | Create symlinks
- name: CCache | Create symlinks in /usr/local/bin/
file: src=/usr/local/bin/ccache dest=/usr/local/bin/{{ item }} state=link
with_items:
- gcc
- cc
- g++
- c++
when: ccache_version.stdout.find('{{ version }}') == -1

- name: CCache | Cleanup
file: path="{{ item }}" state=absent
with_items:
- /tmp/ccache-{{ version }}.tar.gz
- /tmp/ccache-{{ version }}
when: ccache_version.stdout.find('{{ version }}') == -1
13 changes: 12 additions & 1 deletion setup/ansible-tasks/git.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,52 @@
# Downloads and installs git
# @requires: version=2.5.0

- name: Git | Check git --version
shell: git --version
ignore_errors: True
register: git_version

- name: Git | Install required packages for git compile
apt: name={{ item }} update_cache=yes state=latest
with_items:
- gettext
- libcurl4-openssl-dev
when: git_version.stdout.find('{{ version }}') == -1
tags: git

- name: Git | Download git-{{ version }}
get_url: url=https://www.kernel.org/pub/software/scm/git/git-{{ version }}.tar.xz dest=/tmp/
register: new_archive
when: git_version.stdout.find('{{ version }}') == -1
tags: git

- name: Git | Extract git-{{ version }}
unarchive: src=/tmp/git-{{ version }}.tar.xz dest=/tmp/ copy=no
when: new_archive|changed
when: git_version.stdout.find('{{ version }}') == -1 and new_archive|changed
tags: git

- name: Git | Prepare for compilation by running configure
shell: ./configure --prefix=/usr --with-gitconfig=/etc/gitconfig chdir=/tmp/git-{{ version }} >> /dev/null
when: git_version.stdout.find('{{ version }}') == -1
tags: git

- name: Git | Compile git
shell: make chdir=/tmp/git-{{ version }} >> /dev/null
when: git_version.stdout.find('{{ version }}') == -1
tags: git

- name: Git | Install generated binary
command: make install
args:
creates: /usr/local/bin/git
chdir: /tmp/git-{{ version }}
when: git_version.stdout.find('{{ version }}') == -1
tags: git

- name: Git | Cleanup
file: path="{{ item }}" state=absent
with_items:
- /tmp/git-{{ version }}.tar.gz
- /tmp/git-{{ version }}
when: git_version.stdout.find('{{ version }}') == -1
tags: git

0 comments on commit 4a1107f

Please sign in to comment.