#!/bin/bash

set -e

if [ -z $1 ]; then
    echo -e "Usage: $0 <root> [<dist>]\n - example: $0 rhel-7-x86_64 .el7_9"
    exit 1
fi

root="$1"

for p in lxqt-build-tools libqtxdg liblxqt libsysstat qtxdg-tools lxqt-menu-data libfm-qt lxqt-themes lxqt-qtplugin obconf-qt pavucontrol-qt qps qtermwidget screengrab lximage-qt lxqt-about lxqt-admin lxqt-archiver lxqt-config lxqt-globalkeys lxqt-notificationd lxqt-openssh-askpass lxqt-policykit lxqt-session lxqt-sudo pcmanfm-qt qterminal xdg-desktop-portal-lxqt lxqt-panel  lxqt-powermanagement lxqt-runner lxqt-desktop meteo-qt
do
    if [ "x$2" != "x" ]; then
        mock -r ${root} -nN --nocheck --sources ./$p --spec ./${p}/${p}.spec -D "dist $2"
    else
        mock -r ${root} -nN --nocheck --sources ./$p --spec ./${p}/${p}.spec
    fi
    pushd ../../mock/${root}/result
        createrepo .
    popd
done
