diff options
Diffstat (limited to 'roles/installer/openwrt/image/tasks/main.yml')
-rw-r--r-- | roles/installer/openwrt/image/tasks/main.yml | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/roles/installer/openwrt/image/tasks/main.yml b/roles/installer/openwrt/image/tasks/main.yml new file mode 100644 index 00000000..5bf07d04 --- /dev/null +++ b/roles/installer/openwrt/image/tasks/main.yml @@ -0,0 +1,65 @@ +--- +- name: fetch imagebuilder + when: openwrt_imgbuilder_tarball is not defined + run_once: true + import_tasks: fetch.yml + +- name: build the image + block: + - import_tasks: 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 %} + {% if openwrt_rootfs_partsize is defined %} ROOTFS_PARTSIZE="{{ openwrt_rootfs_partsize }}" {% endif %} + register: openwrt_build + + - name: Copy newly built OpenWrt image + loop: "{{ 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 }}" + + - name: set output image names + set_fact: + output_images: "{{ [(openwrt_output_dir, openwrt_output_image_name_base) | path_join | realpath] | product(openwrt_output_image_suffixes) | map('join', '-') }}" + + always: + - name: save stdout build-log to output directory + when: openwrt_build is defined + copy: + content: "{{ openwrt_build.stdout }}\n" + dest: "{{ openwrt_output_dir }}/build-stdout.log" + + - name: save stderr build-log to output directory + when: openwrt_build is defined + copy: + content: "{{ openwrt_build.stderr }}\n" + dest: "{{ openwrt_output_dir }}/build-stderr.log" + + - name: delete the temporary build directory + when: not openwrt_keep_temporary_build_dir + file: + path: "{{ openwrt_imgbuilder_dir }}" + state: absent + + - name: print temporary build directory information + when: openwrt_keep_temporary_build_dir + debug: + msg: "The temporary build directory has not been deleted, the path to the directory is: {{ openwrt_imgbuilder_dir }}" |