1#!/bin/bash -eu 2# Copyright 2019 Google Inc. 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15# 16################################################################################ 17 18# Build CUPS 19pushd $SRC/cups 20# Fix bad line 21sed -i '2110s/\(\s\)f->value/\1(int)f->value/' cups/ppd-cache.c 22 23LSB_BUILD=y ./configure --prefix="$WORK" --libdir="$OUT" --disable-gnutls \ 24 --disable-libusb --with-components=core 25 26make clean 27make install-headers install-libs 28make -C filter libs install-libs 29install -m755 cups-config "$WORK"/cups-config 30popd 31 32rm -rf cups/libs || die 33rm -rf freetype || die 34rm -rf libpng || die 35rm -rf zlib || die 36 37mv $SRC/freetype freetype 38 39CUPSCONFIG="$WORK/cups-config" 40CUPS_CFLAGS=$($CUPSCONFIG --cflags) 41CUPS_LDFLAGS=$($CUPSCONFIG --ldflags) 42CUPS_LIBS=$($CUPSCONFIG --image --libs) 43export CXXFLAGS="$CXXFLAGS $CUPS_CFLAGS" 44 45CPPFLAGS="${CPPFLAGS:-} $CUPS_CFLAGS -DPACIFY_VALGRIND" ./autogen.sh \ 46 CUPSCONFIG=$CUPSCONFIG \ 47 --enable-freetype --enable-fontconfig \ 48 --enable-cups --with-ijs --with-jbig2dec \ 49 --with-drivers=cups,ljet4,laserjet,pxlmono,pxlcolor,pcl3,uniprint 50make -j$(nproc) libgs 51 52$CXX $CXXFLAGS $CUPS_LDFLAGS -std=c++11 -I. \ 53 $SRC/gstoraster_fuzzer.cc \ 54 -o "$OUT/gstoraster_fuzzer" \ 55 -Wl,-rpath='$ORIGIN' \ 56 $CUPS_LIBS \ 57 $LIB_FUZZING_ENGINE bin/gs.a 58 59mkdir -p "$WORK/seeds" 60for f in examples/*.{ps,pdf}; do 61 s=$(sha1sum "$f" | awk '{print $1}') 62 cp "$f" "$WORK/seeds/$s" 63done 64zip -j "$OUT/gstoraster_fuzzer_seed_corpus.zip" "$WORK"/seeds/* 65