/log
/gpg/vault-keyring.gpg~
+/files/openwrt
+/files/.cache
*.pyc
*.retry
.*.sw?
--- /dev/null
+# Build OpenWRT images with Ansible
+
+## Configuration
--- /dev/null
+openwrt_release: 17.01.4
+download_dir: .cache/openwrt
+openwrt_tarball_basename: lede-imagebuilder-{{ openwrt_release }}-{{ openwrt_arch }}{% if openwrt_target != 'generic' %}-{{ openwrt_target }}{% endif %}.Linux-x86_64
+openwrt_tarball_name: "{{ openwrt_tarball_basename }}.tar.xz"
+openwrt_target: generic
+openwrt_output_dir: files/openwrt
+
+
+openwrt_packages_remove: []
+openwrt_packages_add: []
+openwrt_packages_extra: []
--- /dev/null
+- name: Create download directory
+ file:
+ dest: "{{ download_dir }}"
+ state: directory
+
+- block:
+ - name: Generate OpenWrt download URLs
+ set_fact:
+ openwrt_url:
+ https://downloads.openwrt.org/releases/{{ openwrt_release }}/targets/{{ openwrt_arch | mandatory }}/{{ openwrt_target }}
+
+ - name: Download sha256sums
+ get_url:
+ url: "{{ openwrt_url }}/sha256sums"
+ dest: "{{ download_dir }}/{{ openwrt_tarball_basename }}.sha256"
+
+ - name: Download sha256sums.asc
+ get_url:
+ url: "{{ openwrt_url }}/sha256sums.asc"
+ dest: "{{ download_dir }}/{{ openwrt_tarball_basename }}.sha256.asc"
+
+ - name: Check OpenPGP signature
+ command: gpg --verify "{{ download_dir }}/{{ openwrt_tarball_basename }}.sha256.asc"
+ changed_when: False
+
+ - name: Extract SHA256 hash of the imagebuilder archive
+ command: grep '{{ openwrt_tarball_name }}' "{{ download_dir }}/{{ openwrt_tarball_basename }}.sha256"
+ register: sha256
+ changed_when: False
+
+ - name: Download imagebuilder
+ get_url:
+ url: "{{ openwrt_url }}/{{ openwrt_tarball_name }}" #lede-imagebuilder-{{ openwrt_release }}-{{ openwrt_arch }}.Linux-x86_64.tar.xz"
+ dest: "{{ download_dir }}/{{ openwrt_tarball_name }}"
+ checksum: sha256:{{ sha256.stdout.split(' ') | first }}
+
+ # /!\ This needs to be the last task in 00-fetch.yml
+# - set_fact:
+# openwrt_imgbuilder_tarball: >
+# {{ download_dir }}/{{ openwrt_tarball_name }}
+
+ rescue:
+ - name: Delete downloaded artifacts
+ file:
+ path: "{{ item }}"
+ state: absent
+ with_items:
+ - "{{ download_dir }}/{{ openwrt_tarball_basename }}.sha256"
+ - "{{ download_dir }}/{{ openwrt_tarball_basename }}.sha256.asc"
+ - "{{ download_dir }}/{{ openwrt_tarball_name }}"
+ - fail:
+ msg: Something borked
--- /dev/null
+- include: 00-fetch.yml
+ when: openwrt_imgbuilder_tarball is not defined
+
+- name: Create temporary build directory
+ command: mktemp -d openwrt-{{ ansible_hostname }}.XXXXXX
+ register: tmpdir
+
+- set_fact:
+ openwrt_imgbuilder_dir: "{{ tmpdir.stdout }}"
+ openwrt_imgbuilder_files: "{{ tmpdir.stdout }}/files"
+
+- name: Create the directory for slipstreamed files
+ file:
+ path: "{{ openwrt_imgbuilder_files }}"
+ state: directory
+
+
+- block:
+# - unarchive:
+# copy: False
+# src: "{{ download_dir }}/{{ openwrt_tarball_name }}"
+# dest: "{{ openwrt_imgbuilder_dir }}"
+
+ - name: Decompress the OpenWrt image builder
+ command: >-
+ tar -xf "{{ download_dir }}/{{ openwrt_tarball_name }}"
+ -C "{{ openwrt_imgbuilder_dir }}"
+
+# - include: 02-prepare.yml
+
+ - name: Create the output directory for built images
+ file:
+ path: "{{ openwrt_output_dir }}"
+ state: directory
+
+ - name: Build the OpenWrt image
+ shell: >-
+ make -C {{ openwrt_imgbuilder_dir }}/{{ openwrt_tarball_basename }} image
+
+ FILES="{{ openwrt_imgbuilder_files }}"
+
+ PACKAGES="
+ {% for x in openwrt_packages_remove %}-{{x}} {% endfor %}
+ {% for x in openwrt_packages_add %} {{x}} {% endfor %}
+ {% for x in openwrt_packages_extra %} {{x}} {% endfor %}
+ "
+ BIN_DIR="{{ openwrt_output_dir }}"
+
+ {% if openwrt_extra_name is defined %}
+ EXTRA_IMAGE_NAME="{{ openwrt_extra_name }}"
+ {% endif %}
+
+
+ always:
+ - name: Delete the temporary build directory
+ file:
+ path: "{{ openwrt_imgbuilder_dir }}"
+ state: absent