-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Add dependency on zlib when building with libmagic #1084
Conversation
This fixes linking against static libmagic.
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here (e.g. What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
I signed it! |
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
Hi @metthal, I've reverted this change because it was causing trouble when building YARA in Alpine Linux. Can you please provide more information about what specific issue you were trying to fix so that we can come up with a solution that works for all environments? Apparently your problem was while building a static version of YARA, can you please tell how did you hit that issue? |
Hi. Basically I was trying to build full portable version of yara for CentOS which wouldn't require installation of any additional packages. You can use this Docker image to observe the bahvior FROM centos:7
RUN yum install -y epel-release && \
yum install -y autotools cmake3 cmake3-data file-devel file-static \
gcc libtool make openssl-devel openssl-static unzip wget && \
yum clean all
RUN mkdir -p /tmp/build && cd /tmp/build && \
wget https://github.com/akheron/jansson/archive/v2.12.zip && \
unzip v2.12.zip && \
cd jansson-2.12 && mkdir build && cd build && \
cmake3 -DCMAKE_BUILD_TYPE=Release \
-DJANSSON_EXAMPLES=OFF \
-DJANSSON_BUILD_DOCS=OFF \
-DJANSSON_WITHOUT_TESTS=ON \
.. && \
cmake3 --build . --target install -- -j && \
cd / && rm -rf /tmp/build
# Force remove libmagic.so because we only want libmagic.a
# and I didn't find better way to force yara build system
# to use libmagic.a instead of libmagic.so
RUN rm /usr/lib64/libmagic.so
ARG yara_gitref
RUN mkdir /tmp/yara && cd /tmp/yara && \
wget https://github.com/VirusTotal/yara/archive/${yara_gitref}.zip && \
unzip ${yara_gitref}.zip && \
cd yara-${yara_gitref} && \
./bootstrap.sh && \
./configure --enable-cuckoo --enable-magic --disable-shared && \
make -j$(nproc) && \
make install Now if you run
you can see that it builds successfully (it is one commit before your revert). Now let's build the commit where you reverted the change
I've tried to debug the problem back when I first encountered it. The problem is that program which is used during configure time to test whether |
This fixes linking against static libmagic.
I ran into this when I was trying to compile yara with almost everything static so it can be portable among multiple Linux machines. Linking against static libmagic.a requires linking against zlib. Since zlib is dependency of libmagic, everyone who has installed libmagic will also have zlib.
I don't really know if this is the right way to solve it since I am not familiar with autotools whatsoever but I am open to any other (better) solutions.