diff options
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | composer.json | 10 | ||||
-rwxr-xr-x | makesrc.sh | 27 | ||||
-rw-r--r-- | php-iamcal-lib-autolink.spec | 102 |
4 files changed, 143 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..91b0fd5 --- /dev/null +++ b/Makefile @@ -0,0 +1,4 @@ +SRCDIR := $(shell pwd) +NAME := $(shell basename $(SRCDIR)) +include ../../common/Makefile + diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..3c14bb8 --- /dev/null +++ b/composer.json @@ -0,0 +1,10 @@ +{ + "name": "iamcal/lib_autolink", + "description": "Adds anchors to urls in a text", + "keywords": ["link", "autolink", "anchor"], + "autoload": { + "files": ["lib_autolink.php"] + }, + "license": "MIT" +} + diff --git a/makesrc.sh b/makesrc.sh new file mode 100755 index 0000000..c047df5 --- /dev/null +++ b/makesrc.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +NAME=$(sed -n '/^Name:/{s/.* //;p}' *.spec) +OWNER=$(sed -n '/^%global gh_owner/{s/.* //;p}' $NAME.spec) +PROJECT=$(sed -n '/^%global gh_project/{s/.* //;p}' $NAME.spec) +VERSION=$(sed -n '/^Version:/{s/.* //;p}' $NAME.spec) +COMMIT=$(sed -n '/^%global gh_commit/{s/.* //;p}' $NAME.spec) +SHORT=${COMMIT:0:7} + +echo -e "\nCreate git snapshot\nName=$NAME, Owner=$OWNER, Project=$PROJECT, Version=$VERSION\n" + +echo "Cloning..." +git clone https://github.com/$OWNER/$PROJECT.git $PROJECT-$COMMIT + +echo "Getting commit..." +pushd $PROJECT-$COMMIT +git checkout $COMMIT +cp composer.json ../composer.json +popd + +echo "Archiving..." +tar czf $NAME-$VERSION-$SHORT.tgz --exclude .git $PROJECT-$COMMIT + +echo "Cleaning..." +rm -rf $PROJECT-$COMMIT + +echo "Done." diff --git a/php-iamcal-lib-autolink.spec b/php-iamcal-lib-autolink.spec new file mode 100644 index 0000000..9bfe351 --- /dev/null +++ b/php-iamcal-lib-autolink.spec @@ -0,0 +1,102 @@ +# spec file for php-iamcal-lib-autolink +# +# Copyright (c) 2016 Remi Collet +# License: CC-BY-SA +# http://creativecommons.org/licenses/by-sa/4.0/ +# +# Please, preserve the changelog entries +# +%global gh_commit b3a86d8437e5d635fb85b155a86288d94f6a924d +%global gh_short %(c=%{gh_commit}; echo ${c:0:7}) +%global gh_owner iamcal +%global gh_project lib_autolink +%global with_tests 0%{!?_without_tests:1} + + +Name: php-iamcal-lib-autolink +Version: 1.7 +Release: 1%{?dist} +Summary: Adds anchors to urls in a text + +Group: Development/Libraries +License: MIT +URL: https://github.com/%{gh_owner}/%{gh_project} +Source0: %{name}-%{version}-%{gh_short}.tgz +# Used to retrieve a git snapshot with test suite +Source1: makesrc.sh + +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) +BuildArch: noarch +# For tests +%if %{with_tests} +BuildRequires: php-cli +BuildRequires: php-pcre +%endif + +# From composer.json, nothing +# From phpcompatinfo report for 1.7 +Requires: php-pcre + +Provides: php-composer(%{gh_owner}/%{gh_project}) = %{version} + + +%description +Find URLs in HTML that are not already links, and make them into links. + +Autoloader: %{_datadir}/php/%{name}/autoload.php + + +%prep +%setup -q -n %{gh_project}-%{gh_commit} + + +%build +: Nothing + + +%install +rm -rf %{buildroot} + +: Single file, only functions +install -Dpm 0644 lib_autolink.php %{buildroot}%{_datadir}/php/%{name}/lib_autolink.php + +# from composer.json, "autoload": { +# "files": ["lib_autolink.php"] +ln -s lib_autolink.php %{buildroot}%{_datadir}/php/%{name}/autoload.php + + +%check +%if %{with_tests} +for unit in t/*.t; do + %{_bindir}/php $unit | tee -a tests.log +done + +if which php70; then + for unit in t/*.t; do + php70 $unit | tee -a tests.log + done +fi + +grep -q '^not ok' tests.log && exit 1 +%else +: Test suite disabled +%endif + + +%clean +rm -rf %{buildroot} + + +%files +%defattr(-,root,root,-) +%{!?_licensedir:%global license %%doc} +%license LICENSE +%doc *.md +%doc composer.json +%{_datadir}/php/%{name} + + +%changelog +* Tue Apr 26 2016 Remi Collet <remi@fedoraproject.org> - 1.7-1 +- initial package, version 1.7 + |