<commit_before>#!/bin/bash

RPMBUILD_DIR="${HOME}/rpmbuild/"
BUILD_DIR="$RPMBUILD_DIR/BUILD"
GITREV=`git rev-parse --short HEAD`
PREFIX=""   # Root project dir
MY_DIR=`dirname $0`
MY_DIR="$MY_DIR/"

if [ $# -lt "1"  -o $# -gt "2" ]
then
    echo "Usage: `basename $0` <root_project_dir> [revision]"
    exit 1
fi

PREFIX="$1/"

if [ ! -d "$RPMBUILD_DIR" ]; then
    echo "rpmbuild dir $RPMBUILD_DIR doesn't exist!"
    echo "init rpmbuild dir with command: rpmdev-setuptree"
    echo "(Hint: Package group @development-tools and package fedora-packager)"
    exit 1
fi

echo "Cleaning $BUILD_DIR"
rm -rf $BUILD_DIR
echo "Removing $RPMBUILD_DIR/librepo.spec"
rm -f $RPMBUILD_DIR/librepo.spec

echo "> Making tarball .."
$MY_DIR/make_tarball.sh $GITREV
if [ ! $? == "0" ]; then
    echo "Error while making tarball"
    exit 1
fi
echo "Tarball done"

echo "> Copying tarball and .spec file into the $RPMBUILD_DIR .."
cp $PREFIX/librepo-$GITREV.tar.xz $RPMBUILD_DIR/SOURCES/
if [ ! $? == "0" ]; then
    echo "Error while: cp $PREFIX/librepo-$GITREV.tar.xz $RPMBUILD_DIR/SOURCES/"
    exit 1
fi

#cp $PREFIX/librepo.spec $RPMBUILD_DIR/SPECS/
# Copy via sed
sed "s/%global gitrev .*/%global gitrev $GITREV/g" $PREFIX/librepo.spec > $RPMBUILD_DIR/SPECS/librepo.spec
if [ ! $? == "0" ]; then
    echo "Error while: cp $PREFIX/librepo.spec $RPMBUILD_DIR/SPECS/"
    exit 1
fi
echo "Copying done"

echo "> Starting rpmbuild librepo.."
rpmbuild -ba $RPMBUILD_DIR/SPECS/librepo.spec
if [ ! $? == "0" ]; then
    echo "Error while: rpmbuild -ba $RPMBUILD_DIR/SPECS/librepo.spec"
    exit 1
fi
echo "rpmbuild done"

echo "> Cleanup .."
rpmbuild --clean $RPMBUILD_DIR/SPECS/librepo.spec
echo "Cleanup done"

echo "> Moving rpms and srpm .."
mv --verbose $RPMBUILD_DIR/SRPMS/librepo-*.src.rpm $PREFIX/.
mv --verbose $RPMBUILD_DIR/RPMS/*/librepo-*.rpm $PREFIX/.
mv --verbose $RPMBUILD_DIR/RPMS/*/python-librepo-*.rpm $PREFIX/.
echo "Moving done"

echo "All done!"<commit_msg>Add timestamp substitution into the make_rpm.sh.<commit_after>#!/bin/bash

RPMBUILD_DIR="${HOME}/rpmbuild/"
BUILD_DIR="$RPMBUILD_DIR/BUILD"
GITREV=`git rev-parse --short HEAD`
TIMESTAMP=`date +%Y%m%d`
PREFIX=""   # Root project dir
MY_DIR=`dirname $0`
MY_DIR="$MY_DIR/"

if [ $# -lt "1"  -o $# -gt "2" ]
then
    echo "Usage: `basename $0` <root_project_dir> [revision]"
    exit 1
fi

PREFIX="$1/"

if [ ! -d "$RPMBUILD_DIR" ]; then
    echo "rpmbuild dir $RPMBUILD_DIR doesn't exist!"
    echo "init rpmbuild dir with command: rpmdev-setuptree"
    echo "(Hint: Package group @development-tools and package fedora-packager)"
    exit 1
fi

echo "Cleaning $BUILD_DIR"
rm -rf $BUILD_DIR
echo "Removing $RPMBUILD_DIR/librepo.spec"
rm -f $RPMBUILD_DIR/librepo.spec

echo "> Making tarball .."
$MY_DIR/make_tarball.sh $GITREV
if [ ! $? == "0" ]; then
    echo "Error while making tarball"
    exit 1
fi
echo "Tarball done"

echo "> Copying tarball and .spec file into the $RPMBUILD_DIR .."
cp $PREFIX/librepo-$GITREV.tar.xz $RPMBUILD_DIR/SOURCES/
if [ ! $? == "0" ]; then
    echo "Error while: cp $PREFIX/librepo-$GITREV.tar.xz $RPMBUILD_DIR/SOURCES/"
    exit 1
fi

#cp $PREFIX/librepo.spec $RPMBUILD_DIR/SPECS/
# Copy via sed
sed "s/%global gitrev .*/%global gitrev $GITREV/g" $PREFIX/librepo.spec > $RPMBUILD_DIR/SPECS/librepo.spec
if [ ! $? == "0" ]; then
    echo "Error while: cp $PREFIX/librepo.spec $RPMBUILD_DIR/SPECS/"
    exit 1
fi
sed --in-place "s/%global timestamp .*/%global timestamp $TIMESTAMP/g" $RPMBUILD_DIR/SPECS/librepo.spec

echo "Copying done"

echo "> Starting rpmbuild librepo.."
rpmbuild -ba $RPMBUILD_DIR/SPECS/librepo.spec
if [ ! $? == "0" ]; then
    echo "Error while: rpmbuild -ba $RPMBUILD_DIR/SPECS/librepo.spec"
    exit 1
fi
echo "rpmbuild done"

echo "> Cleanup .."
rpmbuild --clean $RPMBUILD_DIR/SPECS/librepo.spec
echo "Cleanup done"

echo "> Moving rpms and srpm .."
mv --verbose $RPMBUILD_DIR/SRPMS/librepo-*.src.rpm $PREFIX/.
mv --verbose $RPMBUILD_DIR/RPMS/*/librepo-*.rpm $PREFIX/.
mv --verbose $RPMBUILD_DIR/RPMS/*/python-librepo-*.rpm $PREFIX/.
echo "Moving done"

echo "All done!"
{'fraction_non_alphanumeric': 0.1561811505507956, 'fraction_numerical': 0.0073439412484700125, 'mean_word_length': 3.801410105757932, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4508118', 'n_tokens_mistral': 1671, 'n_tokens_neox': 1595, 'n_words': 406}