
unset $(env | sed -n 's/=.*//p')
PATH=/bin:/usr/bin:/sbin/:/usr/sbin

declare -A FR_FLAGS
FR_FLAGS[EPEL5]=''

declare -A FR_SETTINGS 
FR_SETTINGS[resultdir]=""
FR_SETTINGS[verbose]="True"
FR_SETTINGS[no_report]=""
FR_SETTINGS[session_log]="/home/w0rm/.cache/fedora-review.log"
FR_SETTINGS[list_flags]=""
FR_SETTINGS[list_checks]=""
FR_SETTINGS[single]=""
FR_SETTINGS[rpm_spec]="True"
FR_SETTINGS[exclude]="CheckRpmlintInstalled,CheckApprovedLicense,CheckContainsLicenseText,CheckLicenseField,CheckLicenseUpstream,CheckReqPkgConfig,CheckBuildCompleted,CheckPackageInstalls,CheckNoNameConflict,CheckBuild,CheckBuildRequires"
FR_SETTINGS[configdir]=""
FR_SETTINGS[log_level]="10"
FR_SETTINGS[log]="<logging.RootLogger object at 0x7f7683287a90>"
FR_SETTINGS[init_done]="True"
FR_SETTINGS[cache]=""
FR_SETTINGS[mock_config]="fedora-rawhide-x86_64"
FR_SETTINGS[version]=""
FR_SETTINGS[uniqueext]=""
FR_SETTINGS[flags]=""
FR_SETTINGS[bz_url]="https://bugzilla.redhat.com"
FR_SETTINGS[mock_options]="--no-cleanup-after --no-clean"
FR_SETTINGS[other_bz]=""
FR_SETTINGS[repo]=""
FR_SETTINGS[use_colors]="True"
FR_SETTINGS[bug]=""
FR_SETTINGS[prebuilt]="True"
FR_SETTINGS[name]="geoclue"
FR_SETTINGS[url]=""
FR_SETTINGS[checksum]="sha256"
FR_SETTINGS[nobuild]=""

export FR_REVIEWDIR='/data/temp/rhel-reviews/geoclue-0.12.99-2.fc19/geoclue'
export HOME=$FR_REVIEWDIR
cd $HOME

export FR_NAME='geoclue'
export FR_VERSION='0.12.99'
export FR_RELEASE='2.fc18'
export FR_GROUP='System Environment/Libraries'
export FR_LICENSE='LGPLv2'
export FR_URL='http://geoclue.freedesktop.org/'

export Source0="http://folks.o-hand.com/jku/geoclue-releases/geoclue-0.12.99.tar.gz"



export FR_PREP='cd '\''/home/w0rm/rpmbuild/BUILD'\''
rm -rf '\''geoclue-0.12.99'\''
/usr/bin/tar -xf /home/w0rm/rpmbuild/SOURCES/geoclue-0.12.99.tar.gz
cd '\''geoclue-0.12.99'\''
/usr/bin/chmod -Rf a+rX,u+w,g-w,o-w .
sed -i -e "s/gtk+-2.0/gtk+-3.0/" configure'
export FR_BUILD='CFLAGS="${CFLAGS:--O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4  -m64 -mtune=generic}" ; export CFLAGS ;
CXXFLAGS="${CXXFLAGS:--O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4  -m64 -mtune=generic}" ; export CXXFLAGS ;
FFLAGS="${FFLAGS:--O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4  -m64 -mtune=generic -I/usr/lib64/gfortran/modules}" ; export FFLAGS ;
LDFLAGS="${LDFLAGS:--Wl,-z,relro }"; export LDFLAGS;
./configure --build=x86_64-redhat-linux-gnu --host=x86_64-redhat-linux-gnu \
--program-prefix= \
--disable-dependency-tracking \
--prefix=/usr \
--exec-prefix=/usr \
--bindir=/usr/bin \
--sbindir=/usr/sbin \
--sysconfdir=/etc \
--datadir=/usr/share \
--includedir=/usr/include \
--libdir=/usr/lib64 \
--libexecdir=/usr/libexec \
--localstatedir=/var \
--sharedstatedir=/var/lib \
--mandir=/usr/share/man \
--infodir=/usr/share/info --disable-static --enable-gtk-doc --enable-networkmanager=yes --enable-gypsy=yes --enable-skyhook=yes --enable-gsmloc=yes --enable-gpsd=no
make -j2 V=1'
export FR_INSTALL='make install DESTDIR=/home/w0rm/rpmbuild/BUILDROOT/geoclue-0.12.99-2.fc18.x86_64 INSTALL='\''install -p'\''
#Remove libtool archives.
find /home/w0rm/rpmbuild/BUILDROOT/geoclue-0.12.99-2.fc18.x86_64 -name '\''*.la'\'' -exec rm -f {} '\'';'\''
# Install the test gui as it seems the test isn'\''t installed any more
mkdir $RPM_BUILD_ROOT/usr/bin
cp test/.libs/geoclue-test-gui $RPM_BUILD_ROOT/usr/bin/'

declare -A FR_FILES
FR_FILES[geoclue]='%defattr(-,root,root,-)
%doc AUTHORS COPYING README
%dir /usr/share/geoclue-providers
/usr/lib64/libgeoclue.so.0
/usr/lib64/libgeoclue.so.0.0.0
/usr/share/GConf/gsettings/geoclue
/usr/share/glib-2.0/schemas/org.freedesktop.Geoclue.gschema.xml
/usr/share/dbus-1/services/org.freedesktop.Geoclue.Master.service
/usr/share/dbus-1/services/org.freedesktop.Geoclue.Providers.Example.service
/usr/share/dbus-1/services/org.freedesktop.Geoclue.Providers.Geonames.service
/usr/share/dbus-1/services/org.freedesktop.Geoclue.Providers.Hostip.service
/usr/share/dbus-1/services/org.freedesktop.Geoclue.Providers.Localnet.service
/usr/share/dbus-1/services/org.freedesktop.Geoclue.Providers.Manual.service
/usr/share/dbus-1/services/org.freedesktop.Geoclue.Providers.Nominatim.service
/usr/share/dbus-1/services/org.freedesktop.Geoclue.Providers.Plazes.service
/usr/share/dbus-1/services/org.freedesktop.Geoclue.Providers.Skyhook.service
/usr/share/dbus-1/services/org.freedesktop.Geoclue.Providers.Yahoo.service
/usr/share/geoclue-providers/geoclue-example.provider
/usr/share/geoclue-providers/geoclue-geonames.provider
/usr/share/geoclue-providers/geoclue-hostip.provider
/usr/share/geoclue-providers/geoclue-localnet.provider
/usr/share/geoclue-providers/geoclue-manual.provider
/usr/share/geoclue-providers/geoclue-nominatim.provider
/usr/share/geoclue-providers/geoclue-plazes.provider
/usr/share/geoclue-providers/geoclue-skyhook.provider
/usr/share/geoclue-providers/geoclue-yahoo.provider
/usr/libexec/geoclue-example
/usr/libexec/geoclue-geonames
/usr/libexec/geoclue-hostip
/usr/libexec/geoclue-localnet
/usr/libexec/geoclue-manual
/usr/libexec/geoclue-nominatim
/usr/libexec/geoclue-master
/usr/libexec/geoclue-plazes
/usr/libexec/geoclue-skyhook
/usr/libexec/geoclue-yahoo'
FR_FILES[geoclue-devel]='%defattr(-,root,root,-)
/usr/include/geoclue
/usr/lib64/pkgconfig/geoclue.pc
/usr/lib64/libgeoclue.so'
FR_FILES[geoclue-doc]='%defattr(-,root,root,-)
/usr/share/gtk-doc/html/geoclue/'
FR_FILES[geoclue-gui]='%defattr(-,root,root,-)
/usr/bin/geoclue-test-gui'
FR_FILES[geoclue-gypsy]='%defattr(-,root,root,-)
/usr/libexec/geoclue-gypsy
/usr/share/geoclue-providers/geoclue-gypsy.provider
/usr/share/dbus-1/services/org.freedesktop.Geoclue.Providers.Gypsy.service'
FR_FILES[geoclue-gsmloc]='%defattr(-,root,root,-)
/usr/libexec/geoclue-gsmloc
/usr/share/geoclue-providers/geoclue-gsmloc.provider
/usr/share/dbus-1/services/org.freedesktop.Geoclue.Providers.Gsmloc.service'

declare -A FR_DESCRIPTION


export FR_FILES FR_DESCRIPTION

export FR_PASS=80
export FR_FAIL=81
export FR_PENDING=82
export FR_NOT_APPLICABLE=83


function get_used_rpms()
# returns (stdout) list of used rpms if found, else returns 1
{
    cd $FR_REVIEWDIR
    if test  "${FR_SETTINGS[prebuilt]}" = True
    then
        files=( $(ls ../*.rpm 2>/dev/null | grep -v .src.rpm) )                || files=( '@@' )
    else
        files=( $(ls results/*.rpm 2>/dev/null | grep -v .src.rpm) )                || files=( '@@' )
    fi
    test -e ${files[0]} || return 1
    echo "${files[@]}"
    cd $OLDPWD
}

function unpack_rpms()
# Unpack all non-src rpms in results into rpms-unpacked, one dir per rpm.
{
    [ -d rpms-unpacked ] && return 0
    rpms=( $( get_used_rpms ) ) || return 1
    mkdir rpms-unpacked
    cd rpms-unpacked
    retval=0
    for rpm_path in ${rpms[@]};  do
        rpm=$( basename $rpm_path)
        mkdir $rpm
        cd $rpm
        rpm2cpio ../../$rpm_path | cpio -id &>/dev/null
        cd ..
    done
    cd ..
}

function unpack_sources()
# Unpack sources in upstream into upstream-unpacked
# Ignores (reuses) already unpacked items.
{
    sources=( $(cd upstream; ls) ) || sources=(  )
    if [[ ${#sources[@]} -eq 0 || ! -e "upstream/${sources[0]}" ]]; then
       return $FR_NOT_APPLICABLE
    fi
    for source in "${sources[@]}"; do
        mkdir upstream-unpacked/$source 2>/dev/null || continue
        rpmdev-extract -qfC  upstream-unpacked/$source upstream/$source ||            cp upstream/$source upstream-unpacked/$source
    done
}

function attach()
# Usage: attach <sorting hint> <header>
# Reads attachment from stdin
{
    startdir=$(pwd)
    cd $FR_REVIEWDIR
    for (( i = 0; i < 10; i++ )); do
        test -e $FR_REVIEWDIR/.attachments/*$i || break
    done
    if [ $i -eq 10 ]; then
        echo "More than 10 attachments! Giving up" >&2
        exit 1
    fi
    sort_hint=$1
    shift
    title=${*//\/ }
    file="$sort_hint;${title/;/:};$i"
    cat > .attachments/"$file"
    cd $startdir
}

