Cryptofuture/nginx-hda-bundle-snap

I’m https://launchpad.net/~hda-me/+archive/ubuntu/nginx-stable maintainer, and I trying to make snap from it. But I need some help with it. I getting multiple multiple definition warnings, witch I had none with debian package.
https://github.com/cryptofuture/nginx-hda-bundle-snap

I just want to drop a note to say that your post has been spotted, and not forgotten; someone (me) is looking at it :slight_smile:

ok, I’ve got a build working - it seems the static modules via --add-module was the cause of the problem. They need to be dynamic modules instead for the build to succeed. I’ve also tidied up your use of ../../../ which is an assumption of how snapcraft sees the world and might change without notice:

name: nginx-hda-bundle
version: "1.13.8"
summary: Nginx HDA Bundle - Dynamic Modules Power
description: "For more details please visit: https://github.com/cryptofuture/nginx-hda-bundle/"

grade: devel
confinement: devmode

apps:
  nginx:
    command: bin/nginx
    daemon: simple
    plugs: [network-bind]

parts:
    wrappers:
        plugin: dump
        source: extras

    modules:
      plugin: dump
      source: .
      stage: [modules]
      prime: [-*]

    binary:
      plugin: dump
      source: binary
      install: |
        mkdir -p $SNAPCRAFT_PART_INSTALL/modules/ngx_brotli/deps/brotli $SNAPCRAFT_PART_INSTALL/modules/ngx_pagespeed

        tar zxf brotli.tar.gz -C $SNAPCRAFT_PART_INSTALL/modules/ngx_brotli/deps/brotli --strip-components=1

        case $(uname -m) in
        x86_64|amd64)
          tar zxf 1.13.35.1-x64.tar.gz -C $SNAPCRAFT_PART_INSTALL/modules/ngx_pagespeed
          ;;
        i386|i586|i686)
          tar zxf 1.13.35.1-ia32.tar.gz -C $SNAPCRAFT_PART_INSTALL/modules/ngx_pagespeed
          ;;
        *)
          false
        esac
      prime: [-*]

    nginx:
        after: [modules, binary, wrappers]
        plugin: autotools
        prepare: |
          echo foo
        source: https://nginx.org/download/nginx-1.13.8.tar.gz
        build-packages:
            - libgd-dev
            - libgeoip-dev
            - libpcre3-dev
            - libperl-dev
            - libssl-dev
            - libxslt1-dev
            - lsb-release
            - zlib1g-dev
            - libluajit-5.1-dev
            - tar
            - libpq-dev
            - libpam0g-dev
            - uuid-dev
        configflags:
            - --with-http_ssl_module
            - --with-http_realip_module
            - --with-http_addition_module
            - --with-http_sub_module
            - --with-http_gunzip_module
            - --with-http_gzip_static_module
            - --with-http_random_index_module
            - --with-http_secure_link_module
            - --with-http_stub_status_module
            - --with-http_auth_request_module
            - --with-http_xslt_module=dynamic
            - --with-http_image_filter_module=dynamic
            - --with-http_geoip_module=dynamic
            - --with-stream=dynamic
            - --with-stream_ssl_module
            - --with-stream_ssl_preread_module
            - --with-stream_geoip_module=dynamic
            - --with-http_perl_module=dynamic
            - --with-mail=dynamic
            - --with-mail_ssl_module
            - --add-dynamic-module=$SNAPCRAFT_STAGE/modules/njs/nginx
            - --add-dynamic-module=$SNAPCRAFT_STAGE/modules/ngx_pagespeed
            - --add-dynamic-module=$SNAPCRAFT_STAGE/modules/headers-more-nginx-module
            - --add-dynamic-module=$SNAPCRAFT_STAGE/modules/lua-nginx-module
            - --add-dynamic-module=$SNAPCRAFT_STAGE/modules/naxsi/naxsi_src/
            - --add-dynamic-module=$SNAPCRAFT_STAGE/modules/nginx-length-hiding-filter-module
            - --add-dynamic-module=$SNAPCRAFT_STAGE/modules/Session-Binding-Proxy/nginx_session_binding_proxy_module
            - --add-dynamic-module=$SNAPCRAFT_STAGE/modules/ngx_devel_kit
            - --add-dynamic-module=$SNAPCRAFT_STAGE/modules/ngx_http_upstream_order
            - --add-dynamic-module=$SNAPCRAFT_STAGE/modules/rds-json-nginx-module
            - --add-dynamic-module=$SNAPCRAFT_STAGE/modules/testcookie-nginx-module
            - --add-dynamic-module=$SNAPCRAFT_STAGE/modules/ngx_brotli
            - --add-dynamic-module=$SNAPCRAFT_STAGE/modules/ngx_postgres
            - --add-dynamic-module=$SNAPCRAFT_STAGE/modules/nchan
            - --add-dynamic-module=$SNAPCRAFT_STAGE/modules/ngx_http_auth_pam_module
            - --add-dynamic-module=$SNAPCRAFT_STAGE/modules/echo-nginx-module
            - --add-dynamic-module=$SNAPCRAFT_STAGE/modules/nginx-upstream-fair
            - --add-dynamic-module=$SNAPCRAFT_STAGE/modules/ngx_cache_purge
            - --add-dynamic-module=$SNAPCRAFT_STAGE/modules/ngx-fancyindex
            - --add-dynamic-module=$SNAPCRAFT_STAGE/modules/nginx-upload-progress-module
            - --add-dynamic-module=$SNAPCRAFT_STAGE/modules/ngx_http_substitutions_filter_module
            - --add-dynamic-module=$SNAPCRAFT_STAGE/modules/graphite-nginx-module
            - --add-dynamic-module=$SNAPCRAFT_STAGE/modules/nginx-module-vts
            - --add-dynamic-module=$SNAPCRAFT_STAGE/modules/nginx-ct
            - --add-dynamic-module=$SNAPCRAFT_STAGE/modules/nginx-rtmp-module
            - --add-dynamic-module=$SNAPCRAFT_STAGE/modules/nginx-ts-module
            - --add-dynamic-module=$SNAPCRAFT_STAGE/modules/nginx-module-sts
            - --add-dynamic-module=$SNAPCRAFT_STAGE/modules/nginx-module-stream-sts
            - --with-threads
            - --with-http_slice_module
            - --with-file-aio
            - --with-http_v2_module
        organize:
            sbin: bin

Woh! Thats awesome work @lucyllewy
Definitely will give it a try. Also what prime: [-*] means?

It means that we don’t want any files from this part to be in the final snap. It is equivalent to:

prime:
  - '-*'

The leading - means subtract and the * is a wildcard meaning match everything. So, subtract everything from the list of files from this part to be included in the final snap.

This works well, because the files in those parts are only used for the build process, so we don’t need them at runtime.