Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression of #1040: cannot compile on macOS - bzip2 #1173

Open
rjhornsby opened this issue Mar 13, 2020 · 2 comments
Open

Regression of #1040: cannot compile on macOS - bzip2 #1173

rjhornsby opened this issue Mar 13, 2020 · 2 comments

Comments

@rjhornsby
Copy link

Version:

v7.0.7 (as supplied/installed by chef-workstation source code build steps)

Environment:

macOS 10.14.6, Ruby 2.6.5 (via rbenv)

While it does not appear to be an issue with chef-workstation, for the sake of completeness chef-workstation repo master branch and 0.17.5 tag behave the same.

Scenario:

Unable to build chef-workstation via omnibus. Possibly same issue discussed in omnibus-software #1040.

      [NetFetcher: bzip2] I | 2020-03-12T19:07:43-05:00 | Extracting `./local/cache/bzip2-1.0.8.tar.gz' to `/Users/rhornsby/projects/work/esp/chef/chef-workstation/omnibus/local/src/bzip2'
         [Builder: bzip2] I | 2020-03-12T19:07:43-05:00 | Starting build
         [Builder: bzip2] I | 2020-03-12T19:07:43-05:00 | Environment:
         [Builder: bzip2] I | 2020-03-12T19:07:43-05:00 |   CFLAGS="-I/opt/chef-workstation/embedded/include -O2 -D_FORTIFY_SOURCE=2 -fstack-protector -fPIC"
         [Builder: bzip2] I | 2020-03-12T19:07:43-05:00 |   CPPFLAGS="-I/opt/chef-workstation/embedded/include -O2 -D_FORTIFY_SOURCE=2 -fstack-protector -fPIC"
         [Builder: bzip2] I | 2020-03-12T19:07:43-05:00 |   CXXFLAGS="-I/opt/chef-workstation/embedded/include -O2 -D_FORTIFY_SOURCE=2 -fstack-protector -fPIC"
         [Builder: bzip2] I | 2020-03-12T19:07:43-05:00 |   LDFLAGS="-Wl,-rpath,/opt/chef-workstation/embedded/lib -L/opt/chef-workstation/embedded/lib"
         [Builder: bzip2] I | 2020-03-12T19:07:43-05:00 |   LD_RUN_PATH="/opt/chef-workstation/embedded/lib"
         [Builder: bzip2] I | 2020-03-12T19:07:43-05:00 |   OMNIBUS_INSTALL_DIR="/opt/chef-workstation"
         [Builder: bzip2] I | 2020-03-12T19:07:43-05:00 |   PATH=<truncated>
         [Builder: bzip2] I | 2020-03-12T19:07:43-05:00 |   PKG_CONFIG_PATH="/opt/chef-workstation/embedded/lib/pkgconfig"
         [Builder: bzip2] I | 2020-03-12T19:07:43-05:00 | $ patch -p1 -i /Users/rhornsby/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/bundler/gems/omnibus-software-c086d8057ac9/config/patches/bzip2/makefile_take_env_vars.patch
         [Builder: bzip2] I | 2020-03-12T19:07:43-05:00 | Apply patch `makefile_take_env_vars.patch': 0.0194s
         [Builder: bzip2] I | 2020-03-12T19:07:43-05:00 | Build bzip2: 0.0199s
The following shell command exited with status 1:

    $ CFLAGS=-I/opt/chef-workstation/embedded/include -O2 -D_FORTIFY_SOURCE=2 -fstack-protector -fPIC CPPFLAGS=-I/opt/chef-workstation/embedded/include -O2 -D_FORTIFY_SOURCE=2 -fstack-protector -fPIC CXXFLAGS=-I/opt/chef-workstation/embedded/include -O2 -D_FORTIFY_SOURCE=2 -fstack-protector -fPIC LDFLAGS=-Wl,-rpath,/opt/chef-workstation/embedded/lib -L/opt/chef-workstation/embedded/lib LD_RUN_PATH=/opt/chef-workstation/embedded/lib OMNIBUS_INSTALL_DIR=/opt/chef-workstation PATH=<truncated> PKG_CONFIG_PATH=/opt/chef-workstation/embedded/lib/pkgconfig patch -p1 -i /Users/rhornsby/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/bundler/gems/omnibus-software-c086d8057ac9/config/patches/bzip2/makefile_take_env_vars.patch

Output:

    patching file Makefile
Hunk #1 FAILED at 18.
1 out of 1 hunk FAILED -- saving rejects to file Makefile.rej
patching file Makefile-libbz2_so

Error:

    (nothing)

Steps to Reproduce:

  1. On a Mac, clone the GitHub repo @ chef/chef-workstation
  2. Follow the instructions therein, in omnibus/README.md
    a. cd omnibus; bundle install --binstubs
    b. sudo bin/omnibus build chef-workstation

Expected Result:

Should have omnibus build a chef-workstation package.

Actual Result:

From what I can see it looks like omnibus downloads a chef published tarball for bzip2 v1.0.8. Later, just prior to compiling bzip2, omnibus attempts to patch the two bzip Makefiles Makefile and Makefile-libbz2_so. The patch file itself, makefile_take_env_vars.patch says it was created from bzip2 1.0.6.

The build fails with error

Output:

    patching file Makefile
Hunk #1 FAILED at 18.
1 out of 1 hunk FAILED -- saving rejects to file Makefile.rej
patching file Makefile-libbz2_so

Error:

    (nothing)

Contents of Makefile.rej:

$ cat local/src/bzip2/bzip2-1.0.8/Makefile.rej
***************
*** 18,27 ****
- CC=gcc
  AR=ar
  RANLIB=ranlib
- LDFLAGS=

- BIGFILES=-D_FILE_OFFSET_BITS=64
- CFLAGS=-Wall -Winline -O2 -g $(BIGFILES)

  # Where you want it installed when you do 'make install'
  PREFIX=/usr/local
--- 18,27 ----
+ CC?=gcc
  AR=ar
  RANLIB=ranlib
+ LDFLAGS+=

+ BIGFILES?=-D_FILE_OFFSET_BITS=64
+ CFLAGS+=-Wall -Winline -O2 -g $(BIGFILES)

  # Where you want it installed when you do 'make install'
  PREFIX=/usr/local
@rjhornsby
Copy link
Author

I took a closer look at @erikng's proposed solution in #1040, and it looks like he gave patch more context to work with. Without omnibus, just the bzip2 1.0.8 source and the patch file, plus this minor change, I was able to get patch to run successfully:

--- bzip2-1.0.6/Makefile-orig   2010-09-10 17:46:02.000000000 -0500
+++ bzip2-1.0.6/Makefile        2013-11-21 13:55:11.000000000 -0600
-change-> @@ -15,13 +15,13 @@
-add>> SHELL=/bin/sh
-add>>
-add>> # To assist in cross-compiling

@Quantu
Copy link

Quantu commented May 27, 2020

The issue is with the very old version of patch preinstalled on macos (even through 10.15.5 at least, doubt they will ever update it). brew install gpatch and it works fine as-is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants