File rubygems.spec of Package rubygems-3.1.3

#
# spec file for SUSE CAP buildpack dependency
#
# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.



Name:           rubygems-3.1.3
Version:        3.1.3
Release:        1
Summary:        This is a dependency used in SUSE CAP buildpacks
License:        Ruby
Group:          Cloud/Platform/scf
Url:            https://rubygems.org
Source:         https://rubygems.org/rubygems/rubygems-3.1.3.tgz
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  unzip
BuildRequires:  zip

%define otherdir %{_topdir}/OTHER

%description

%prep

%build
EXTENSION=$(echo "%{SOURCE0}" | perl -lne 'print $& if /(\.[a-zA-Z]{1,4}\.{0,1}[a-zA-Z]{0,3})/')

if echo "${EXTENSION}" | grep -iq "tar" || echo "${EXTENSION}" | grep -iq "tgz"; then
    # Strip top level directory
    OLD_FILE_NAME=${PWD}/temp.${EXTENSION}
    mkdir content
    tar -C content --transform 's:^\./::' --strip-components 1 -xf "%{SOURCE0}"
    tar -C content -czf ${OLD_FILE_NAME} .
elif echo "${EXTENSION}" | grep -iq "zip"; then
    # Strip top level directory
    OLD_FILE_NAME=${PWD}/temp.${EXTENSION}
    mkdir content
    unzip -d content "%{SOURCE0}"
    pushd content/*
        zip -r "${OLD_FILE_NAME}" .
    popd
else
    OLD_FILE_NAME=%{SOURCE0}
fi

CHECKSUM=`sha256sum ${OLD_FILE_NAME}`
NEW_FILE_NAME=%{otherdir}/%{name}-${CHECKSUM:0:8}${EXTENSION}

cp ${OLD_FILE_NAME} ${NEW_FILE_NAME}
pushd $(dirname ${NEW_FILE_NAME})
sha256sum $(basename ${NEW_FILE_NAME}) > ${NEW_FILE_NAME}.sha256
popd

%files
%defattr(-,root,root)

%changelog

openSUSE Build Service is sponsored by