summaryrefslogtreecommitdiff
path: root/irfanview/irfanview.spec
blob: 56cdcca3c7153f3b93a4400e912263ac96516f15 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
%global dummy_package 0
%global include_plugins 1
%global devtty /dev/null
# select irfanview binary build: 32 or 64
%global arch 32

Name:		irfanview
Version:	4.52
Release:	1
Summary:	Irfanview graphic viewer
%define version_num %( echo %version | tr -d '\.' )

Group:   Applications/Graphics
License:	Freeware
URL:		http://bgstack15.wordpress.com
# must download like: curl 'https://www.irfanview.info/files/iview451_x64.zip' --compressed -H 'Referer: https://www.irfanview.info/files/iview451_x64.zip'  iview451_x64.zip
%if 0%{?arch} == 64
#Source0: http://www.irfanview.info/files/iview%%{version_num}_x64.zip
#Source1: http://www.irfanview.info/files/iview%%{version_num}_plugins_x64.zip
Source0: http://gitlab.com/bgstack15/big-sources/raw/master/%{name}/iview%{version_num}_x64.zip
Source0: http://gitlab.com/bgstack15/big-sources/raw/master/%{name}/iview%{version_num}_plugins_x64.zip
%else
#Source0: http://www.irfanview.info/files/iview%%{version_num}.zip
#Source1: http://www.irfanview.info/files/iview%%{version_num}_plugins.zip
Source0: http://gitlab.com/bgstack15/big-sources/raw/master/%{name}/iview%{version_num}.zip
Source1: http://gitlab.com/bgstack15/big-sources/raw/master/%{name}/iview%{version_num}_plugins.zip
%endif
Source2: %{name}.desktop
Source3: %{name}
Source4: %{name}.default
Source5: %{name}-vlc
Source6: i_view32.ini
Source7: %{name}-icons.tgz

Packager:	Bgstack15 <bgstack15@gmail.com>
Buildarch:	noarch
BuildRequires: desktop-file-utils
BuildRequires: ImageMagick
Requires(pre): bgscripts-core >= 1.1-20
# WORKHERE: this requires will depend on if this is i686 or x86_64 package
%if 0%{?arch} == 64
Requires:	/usr/bin/wine64
%else
Requires:	/usr/bin/wine32
%endif
Obsoletes:  irfan < 4.51-2
Provides:	application(irfanview.desktop)
Provides:	mimehandler(image/bmp)
Provides:	mimehandler(image/gif)
Provides:	mimehandler(image/ico)
Provides:	mimehandler(image/jpeg)
Provides:	mimehandler(image/jpg)
Provides:	mimehandler(image/png)
Provides:	mimehandler(image/tiff)
Provides:	mimehandler(vnd.adobe.photoshop)
Provides:	mimehandler(x-content/image-dcf)

%description
Irfanview is an amazing graphics application for a different platform. Irfanview is ported to GNU/Linux using wine.

%prep
# main
export UNZIP=-o || :
%setup -q -c

# plugins
%if 0%{?include_plugins}
pushd Plugins
%{__unzip} -o %{SOURCE1}
popd
%endif

# icons
%{__tar} -zxvf %{SOURCE7}
for shape in square clear lubuntu circle ;
do
   for s in 16 22 24 32 48 64 96 128 256 ;
   do
      convert %{name}-${shape}.svg -filter Lanczos -resize ${s}x${s} %{name}-${shape}-${s}.png
   done
done

%build
# the upstream source is the binaries; nothing to do here
:

%install
# main files
%if 0%{?arch} == 64
%{__install} -p -D -m0755 -t %{buildroot}%{_datadir}/%{name} i_view64.exe
%else
%{__install} -p -D -m0755 -t %{buildroot}%{_datadir}/%{name} i_view32.exe
%endif
# skipped iv_uninstall.exe

%if 0%{?include_plugins}
#%{__install} -p -D -m0644 -t %{buildroot}%{_datadir}/%{name}/Plugins Plugins/*
%{__cp} -pr Plugins %{buildroot}%{_datadir}/%{name}/
%{__chmod} -R u=rwX,g=rX,o=rX %{buildroot}%{_datadir}/%{name}/Plugins
%endif

%{__install} -p -D -m0644 -t %{buildroot}%{_datadir}/%{name}/Toolbars Toolbars/*
%{__install} -p -D -m0644 -t %{buildroot}%{_datadir}/%{name}/Languages Languages/*

# desktop files
%{__mkdir_p} %{buildroot}%{_datadir}/applications
desktop-file-install --dir %{buildroot}%{_datadir}/applications %{SOURCE2}

# application start and default scripts
%{__install} -p -D -m0755 %{SOURCE3} %{buildroot}%{_bindir}/%{name}
%{__install} -p -D -m0666 %{SOURCE4} %{buildroot}%{_sysconfdir}/sysconfig/%{name}
%{__install} -p -D -m0755 %{SOURCE5} %{buildroot}%{_bindir}/%{name}-vlc

# select architecture
%if 0%{?arch} == 64
   %{__sed} -i -r -e 's/32/64/g;' -e 's/\.wine$/\.wine64/;' \
      %{buildroot}%{_sysconfdir}/sysconfig/%{name}
%endif

# application default config
%{__install} -p -D -m0666 %{SOURCE6} %{buildroot}%{_sysconfdir}/i_view32.ini
%{__ln_s} ../../..%{_sysconfdir}/i_view32.ini %{buildroot}%{_datadir}/%{name}/i_view32.ini

# man pages
%{__install} -p -D -m0644 -t %{buildroot}%{_docdir}/%{name} *.txt *.chm
%{__install} -p -D -m0644 -t %{buildroot}%{_docdir}/%{name}/Html Html/*

# icons
%{__install} -p -D -m0644 -t %{buildroot}%{_datadir}/%{name}/icons *.svg *.png
%{__install} -p -D -m0644 %{name}-square.svg %{buildroot}%{_datadir}/icons/hicolor/scalable/apps/%{name}.svg

# system services
# none

%clean
rm -rf %{buildroot} || :

%post
# Deploy theme icons
which xdg-icon-resource 1>%{devtty} 2>&1 && {

   # Deploy default apps icons
   for theme in locolor Numix-Circle Lubuntu ;
   do
      shape=square
      case "${theme}" in Numix-Circle) shape=circle;; Lubuntu) shape=lubuntu;; esac
      # Deploy scalable application icons
      %{__cp} -p %{_datadir}/%{name}/icons/%{name}-${shape}.svg %{_datadir}/icons/${theme}/scalable/apps/%{name}.svg
   done

   # Deploy custom apps icons
   # custom: Numix-Circle apps 48 uses svg
   cp -p %{_datadir}/%{name}/icons/%{name}-circle.svg %{_datadir}/icons/Numix-Circle/48/apps/%{name}.svg &
   # custom: Lubuntu apps 48 uses svg
   cp -p %{_datadir}/%{name}/icons/%{name}-lubuntu.svg %{_datadir}/icons/Lubuntu/apps/48/%{name}.svg &
   # default
   cp -p %{_datadir}/%{name}/icons/%{name}-square-48.png %{_datadir}/icons/hicolor/48x48/apps/%{name}.png

} 1>%{devtty} 2>&1

# Mimetypes and default applications
which xdg-mime 1>/dev/null 2>&1 &&
{
   for user in $( /usr/share/bgscripts/enumerate-users.sh || : ) ;
   do

      # Skip non-user objects
      ! getent passwd "${user}" && continue

      # Add new mimetypes
      #su "${user}" -c "xdg-mime install %{_datadir}/%{name}/inc/nonedefined.xml &"

      # Assign default applications
      while read line;
      do
         echo "${user} ${line}"
         # Assign mimetype a default application
         su "${user}" -c "test -f ~/.config/mimeapps.list && xdg-mime default irfanview.desktop ${line} &" &

      done <<'EOW'
image/bmp
image/gif
image/ico
image/jpeg
image/png
image/tiff
image/vnd.adobe.photoshop
x-content/image-dcf
EOW
   done
} 1>%{devtty} 2>&1

# Update icon caches
for word in hicolor locolor Numix-Circle Numix Lubuntu elementary-xfce ;
do
   touch --no-create %{_datadir}/icons/${word} || :
done
/usr/bin/update-mime-database "%{_datadir}/mime" &> /dev/null || :
update-desktop-database &> /dev/null || :
/sbin/ldconfig || :

%preun
if test "$1" = "0" ;   # total uninstall
then
{

   # Remove theme icons
   which xdg-icon-resource 1>%{devtty} 2>&1 && {

      # Remove default apps icons
      for theme in locolor Numix-Circle Lubuntu ;
      do

         # Remove scalable apps icons
         %{__rm} -f %{_datadir}/icons/${theme}/scalable/apps/%{name}.svg

      # Remove custom apps icons
      # custom: Numix-Circle apps 48 uses svg
      rm -f %{_datadir}/icons/Numix-Circle/48/apps/%{name}.svg
      # custom: Lubuntu apps 48 uses svg
      rm -f %{_datadir}/icons/Lubuntu/apps/48/%{name}.svg
      # default
      rm -f %{_datadir}/icons/hicolor/48x48/apps/%{name}.png

      done

   }
} 1>%{devtty} 2>&1
fi

%postun
update-desktop-database &> /dev/null || :
if test "$1" = "0" ;
then

   for word in hicolor locolor Numix-Circle Numix Lubuntu elementary-xfce ;
   do
      touch --no-create %{_datadir}/icons/${word} &>/dev/null 
      gtk-update-icon-cache %{_datadir}/icons/${word} &>/dev/null || :
   done

   /usr/bin/update-mime-database "%{_datadir}/mime" &>/dev/null || :

fi
/sbin/ldconfig || :

%posttrans
/usr/bin/gtk-update-icon-cache "%{_datadir}/icons/hicolor" &>/dev/null || :
/usr/bin/update-mime-database "%{_datadir}/mime" &>/dev/null || :

%files
%{_datadir}/%{name}
%{_docdir}/%{name}
%{_datadir}/applications/*
%{_datadir}/icons/hicolor/*/*/*
%attr(755, -, -) %{_bindir}/*
%config %{_sysconfdir}/sysconfig/%{name}
%config %attr(666, -, -) %{_sysconfdir}/i_view32.ini

%changelog
* Tue Nov 29 2016 B Stack <bgstack15@gmail.com>
- initial package built
bgstack15