]>
Commit | Line | Data |
---|---|---|
3c32c275 ER |
1 | %define subver 2016-03-11 |
2 | %define ver %(echo %{subver} | tr -d -) | |
d045a0a5 | 3 | %define plugin data |
3c32c275 | 4 | %define php_min_version 5.3.0 |
4f0d4331 | 5 | %include /usr/lib/rpm/macros.php |
d045a0a5 ER |
6 | Summary: DokuWiki Structured Data Plugin |
7 | Name: dokuwiki-plugin-%{plugin} | |
3c32c275 ER |
8 | Version: %{ver} |
9 | Release: 0.1 | |
d045a0a5 ER |
10 | License: GPL v2 |
11 | Group: Applications/WWW | |
3c32c275 ER |
12 | # using master snapshot, upstream doesn't tag their code |
13 | # https://github.com/splitbrain/dokuwiki-plugin-data/issues/206 | |
14 | Source0: https://github.com/splitbrain/dokuwiki-plugin-%{plugin}/archive/master/%{plugin}-%{subver}.tar.gz | |
15 | # Source0-md5: eea5c5398f01db4f2b4f22c71d601aea | |
16 | URL: https://www.dokuwiki.org/plugin:data | |
58e46b85 | 17 | Patch2: separator-style.patch |
ce3f39eb | 18 | Patch3: separate-rpmdb.patch |
147d6c0c | 19 | Patch4: cache-enable.patch |
dca91af3 | 20 | BuildRequires: rpm-php-pearprov |
d045a0a5 | 21 | BuildRequires: rpmbuild(macros) >= 1.520 |
272501f6 | 22 | Requires: php(core) >= %{php_min_version} |
860b9ced | 23 | Requires(triggerun): sqlite |
0b4d4d8b | 24 | Requires(triggerun): sqlite3 |
87d1921d | 25 | Requires: dokuwiki >= 20090214b-5 |
58185fea | 26 | Requires: dokuwiki-plugin-sqlite >= 20120619 |
f4bb0314 | 27 | Requires: php(pcre) |
d045a0a5 ER |
28 | BuildArch: noarch |
29 | BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n) | |
30 | ||
31 | %define dokuconf /etc/webapps/dokuwiki | |
69e06802 | 32 | %define dokudir /usr/share/dokuwiki |
860b9ced | 33 | %define metadir /var/lib/dokuwiki/meta |
d045a0a5 | 34 | %define plugindir %{dokudir}/lib/plugins/%{plugin} |
711f0ba6 | 35 | %define find_lang %{_usrlibrpm}/dokuwiki-find-lang.sh %{buildroot} |
d045a0a5 | 36 | |
4f0d4331 ER |
37 | # no pear deps |
38 | %define _noautopear pear | |
39 | ||
40 | # sqlite is dokuwiki-plugin-sqlite dep, not ours | |
41 | %define _noautophp php-sqlite | |
42 | ||
43 | # put it together for rpmbuild | |
44 | %define _noautoreq %{?_noautophp} %{?_noautopear} | |
45 | ||
d045a0a5 ER |
46 | %description |
47 | This plugin allows you to add structured data to any DokuWiki page. | |
48 | Think about this data as additional named attributes. Those attributes | |
49 | can then be queried and aggregated. The plugin is similar to what was | |
50 | done here for the repository plugin but its internals are very | |
51 | different to the repository plugin. | |
52 | ||
53 | %prep | |
860b9ced ER |
54 | %setup -qc |
55 | mv *-%{plugin}-*/* . | |
58e46b85 | 56 | %patch2 -p1 |
ce3f39eb | 57 | %patch3 -p1 |
147d6c0c | 58 | %patch4 -p0 |
87d1921d | 59 | |
ab0be40f | 60 | version=$(awk '/date/{print $2}' plugin.info.txt) |
4978bd8e ER |
61 | if [ $(echo "$version" | tr -d -) != %{version} ]; then |
62 | : %%{version} mismatch | |
58185fea | 63 | # exit 1 |
4978bd8e ER |
64 | fi |
65 | ||
1d83f60d ER |
66 | # nothing to do with tests |
67 | rm -rf _test | |
68 | ||
ab0be40f ER |
69 | # cleanup backups after patching |
70 | find '(' -name '*~' -o -name '*.orig' ')' -print0 | xargs -0 -r -l512 rm -f | |
71 | ||
d045a0a5 ER |
72 | %install |
73 | rm -rf $RPM_BUILD_ROOT | |
860b9ced | 74 | install -d $RPM_BUILD_ROOT{%{plugindir},%{metadir}} |
d045a0a5 | 75 | cp -a . $RPM_BUILD_ROOT%{plugindir} |
58185fea | 76 | %{__rm} $RPM_BUILD_ROOT%{plugindir}/README |
0b4d4d8b | 77 | # sqlite2: php-sqlite |
860b9ced | 78 | touch $RPM_BUILD_ROOT%{metadir}/data.sqlite |
0b4d4d8b ER |
79 | # sqlite3: php-pdo-sqlite |
80 | touch $RPM_BUILD_ROOT%{metadir}/data.sqlite3 | |
69e06802 | 81 | |
d045a0a5 ER |
82 | # find locales |
83 | %find_lang %{name}.lang | |
84 | ||
85 | %clean | |
86 | rm -rf $RPM_BUILD_ROOT | |
87 | ||
88 | %post | |
89 | # force css cache refresh | |
90 | if [ -f %{dokuconf}/local.php ]; then | |
91 | touch %{dokuconf}/local.php | |
92 | fi | |
93 | ||
860b9ced ER |
94 | %triggerun -- %{name} < 20100322-0.5 |
95 | # move to new location | |
96 | mv /var/lib/dokuwiki/cache/dataplugin.sqlite %{metadir}/data.sqlite | |
97 | ||
98 | # perform new indexes add manually | |
99 | sqlite %{metadir}/data.sqlite <<'EOF' | |
100 | CREATE TABLE opts (opt,val); | |
101 | CREATE UNIQUE INDEX idx_opt ON opts(opt); | |
102 | INSERT INTO opts VALUES ('dbversion', 1); | |
103 | EOF | |
104 | chown root:http %{metadir}/data.sqlite | |
105 | chmod 660 %{metadir}/data.sqlite | |
106 | ||
cf948c6d ER |
107 | %triggerun -- %{name} < 20120716-3 |
108 | if [ -f %{metadir}/data.sqlite3 ]; then | |
109 | # already migrated | |
110 | exit 0 | |
111 | fi | |
ca427950 | 112 | # perform sqlite2 -> sqlite3 migration of both tools present |
cf948c6d | 113 | if [ ! -x /usr/bin/sqlite ] || [ ! -x /usr/bin/sqlite3 ]; then |
ca427950 ER |
114 | echo >&2 "data plugin: To migrate db from sqlite2 to sqlite3 you need to install 'sqlite' and 'sqlite3' packages" |
115 | exit 0 | |
116 | fi | |
117 | ||
118 | sqlite %{metadir}/data.sqlite .dump > %{metadir}/data.dump | |
119 | sqlite3 %{metadir}/data.dump.new < %{metadir}/data.dump | |
120 | mv %{metadir}/data.sqlite3{.new,} | |
121 | chown root:http %{metadir}/data.sqlite3 | |
122 | chmod 660 %{metadir}/data.sqlite3 | |
123 | ||
d045a0a5 ER |
124 | %files -f %{name}.lang |
125 | %defattr(644,root,root,755) | |
58185fea | 126 | %doc README |
d045a0a5 | 127 | %dir %{plugindir} |
b0216a62 | 128 | %{plugindir}/admin |
d045a0a5 | 129 | %{plugindir}/syntax |
860b9ced ER |
130 | %{plugindir}/conf |
131 | %{plugindir}/db | |
132 | %{plugindir}/*.js | |
d045a0a5 | 133 | %{plugindir}/*.php |
ab0be40f | 134 | %{plugindir}/*.txt |
d045a0a5 | 135 | %{plugindir}/*.css |
860b9ced | 136 | %attr(660,http,http) %ghost %{metadir}/data.sqlite |
0b4d4d8b | 137 | %attr(660,http,http) %ghost %{metadir}/data.sqlite3 |