summaryrefslogtreecommitdiff
path: root/roles/openwrt/image/tasks/main.yml
blob: 47a8793eb20707caf8aeb8f527c35d390665c99f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
---
- include: fetch.yml
  run_once: true
  when: openwrt_imgbuilder_tarball is not defined

- block:
    - include: prepare.yml

    - name: Create the output directory for built images
      file:
        path: "{{ openwrt_output_dir }}"
        state: directory

    - name: generate list of packages to add or remove
      set_fact:
        openwrt_packages: >-
          {{ openwrt_packages_remove | map('regex_replace', '^', '-') | join(' ') }}
          {{ openwrt_packages_add   | join(' ') }}
          {{ openwrt_packages_extra | join(' ') }}

    - name: Build the OpenWrt image
      command: >-
        make -C {{ openwrt_imgbuilder_dir }}/{{ openwrt_tarball_basename }} image
          {% if openwrt_profile is defined %}PROFILE="{{ openwrt_profile }}" {% endif %}
          FILES="{{ openwrt_imgbuilder_files }}"
          PACKAGES="{{ openwrt_packages }}"
          {% if openwrt_extra_name is defined %} EXTRA_IMAGE_NAME="{{ openwrt_extra_name }}" {% endif %}

    - name: Copy newly built OpenWrt image
      with_items: "{{ openwrt_output_image_suffixes }}"
      copy:
        src: "{{ openwrt_imgbuilder_dir }}/{{ openwrt_tarball_basename }}/bin/targets/{{ openwrt_arch }}/{{ openwrt_target }}/{{ openwrt_output_image_name_base }}-{{ item }}"
        dest: "{{ openwrt_output_dir }}"

        ## TODO: make this less ugly..
    - name: set output image names
      set_fact:
        openwrt_output_images: "{{ '[\"' + openwrt_output_dir + '/' + openwrt_output_image_name_base + '-' + (openwrt_output_image_suffixes | join('\", \"' + openwrt_output_dir + '/' + openwrt_output_image_name_base + '-')) + '\"]' }}"

  always:
    - name: Delete the temporary build directory
      file:
        path: "{{ openwrt_imgbuilder_dir }}"
        state: absent