Project

General

Profile

« Previous | Next » 

Revision d5006820

Added by Ewoud Kohl van Wijngaarden about 6 years ago

Allow rewriting the spec file for gems

View differences:

add_gem_package.sh
PACKAGE_DIR=packages/$PACKAGE_SUBDIR/$PACKAGE_NAME
if [[ -f "${PACKAGE_DIR}/${PACKAGE_NAME}.spec" ]]; then
echo "Detected update..."
UPDATE=true
else
UPDATE=false
fi
usage() {
echo "Usage: $0 GEM_NAME TEMPLATE TITO_TAG [PACKAGE_SUBDIR]"
echo "Valid templates: $(ls gem2rpm | sed 's/.spec.erb//' | tr '\n' ' ')"
......
}
generate_gem_package() {
if [[ $UPDATE == true ]] ; then
CHANGELOG=$(mktemp)
sed -n '/%changelog/,$p' $PACKAGE_DIR/$PACKAGE_NAME.spec > $CHANGELOG
git rm -r $PACKAGE_DIR
fi
mkdir $PACKAGE_DIR
pushd $PACKAGE_DIR
gem2rpm -o $PACKAGE_NAME.spec --fetch $GEM_NAME -t $TEMPLATE
sed -i 's/\s\+$//' $PACKAGE_NAME.spec
git annex add *.gem
VERSION=$(rpmspec --srpm -q --queryformat="%{version}-%{release}" --undefine=dist $PACKAGE_NAME.spec)
if [[ $UPDATE == true ]]; then
cat $CHANGELOG >> $PACKAGE_NAME.spec
sed -i '/^%changelog/,/^%changelog/{0,//!d}' $PACKAGE_NAME.spec
rm $CHANGELOG
CHANGELOG="- Update to $VERSION"
else
CHANGELOG="- Add $PACKAGE_NAME generated by gem2rpm using the $TEMPLATE_NAME template"
fi
echo "$CHANGELOG" | $ROOT/add_changelog.sh $PACKAGE_NAME.spec
git add $PACKAGE_NAME.spec
$ROOT/add_changelog.sh $PACKAGE_NAME.spec <<-EOF
- Add $PACKAGE_NAME generated by gem2rpm using the $TEMPLATE_NAME template
EOF
popd
}
......
git add comps/
}
commit() {
git commit -m "Add $PACKAGE_NAME package"
}
# Main script
if [[ -z $GEM_NAME ]] || [[ -z $TEMPLATE_NAME ]] || [[ -z $TITO_TAG ]]; then
......
fi
generate_gem_package
add_to_tito_props
add_gem_to_comps
commit
if [[ $UPDATE == true ]] ; then
VERSION=$(rpmspec --srpm -q --queryformat="%{version}-%{release}" --undefine=dist $PACKAGE_DIR/$PACKAGE_NAME.spec)
git commit -m "Bump $PACKAGE_NAME to $VERSION"
else
add_to_tito_props
add_gem_to_comps
git commit -m "Add $PACKAGE_NAME package"
fi

Also available in: Unified diff