Skip to content

Failure to build when /etc/resolv.conf is missing (e.g. with Mock) #1546

@dvershinin

Description

@dvershinin

In general, the build is 100% failing when /etc/resolv.conf is absent. See error below.

A specific way to reproduce this is to build a Tengine package with Mock.

Mock allows building RPMs in a clean environment. However, Tengine build fails because it relies on /etc/resolv.conf and the
related define is not set because the file is not present:

In file included from src/core/ngx_core.h:55,
                 from src/core/ngx_resolver.c:9:
src/core/ngx_resolver.c: In function 'ngx_resolver_create':
src/core/ngx_resolver.c:283:41: error: 'NGX_RESOLVER_FILE' undeclared (first use in this function); did you mean 'T_NGX_RESOLVER_FILE'?
     ngx_str_t default_file = ngx_string(NGX_RESOLVER_FILE);
                                         ^~~~~~~~~~~~~~~~~
src/core/ngx_string.h:40:38: note: in definition of macro 'ngx_string'
 #define ngx_string(str)     { sizeof(str) - 1, (u_char *) str }
                                      ^~~
src/core/ngx_resolver.c:283:41: note: each undeclared identifier is reported only once for each function it appears in
     ngx_str_t default_file = ngx_string(NGX_RESOLVER_FILE);
                                         ^~~~~~~~~~~~~~~~~
src/core/ngx_string.h:40:38: note: in definition of macro 'ngx_string'
 #define ngx_string(str)     { sizeof(str) - 1, (u_char *) str }
                                      ^~~

How to reproduce it

  1. install mock in an RPM distro
  2. attempt to build RPM for Tengine
  3. build always fails with error above because /etc/resolv.conf is not there, and thus NGX_RESOLVER_FILE is undefined

Alternative way reproduce it

  1. Delete /etc/resolve.conf
  2. attempt to build normally
  3. build fails same as above

PR with fixes will follow.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions