1
0

Accepting request 134366 from X11:MATE

updated script and spec

OBS-URL: https://build.opensuse.org/request/show/134366
OBS-URL: https://build.opensuse.org/package/show/GNOME:Apps/faenza-icon-theme?expand=0&rev=4
This commit is contained in:
Dominique Leuenberger 2012-11-01 20:57:50 +00:00 committed by Git OBS Bridge
parent eb6a865788
commit 638517554b
3 changed files with 189 additions and 36 deletions

View File

@ -1,3 +1,9 @@
-------------------------------------------------------------------
Fri Sep 14 16:40:54 UTC 2012 - nmo.marques@gmail.com
- update faenza-install script; updated the spec file to use the
new syntax, cleaned up old stuff.
------------------------------------------------------------------- -------------------------------------------------------------------
Fri Jan 13 13:25:33 UTC 2012 - vuntz@opensuse.org Fri Jan 13 13:25:33 UTC 2012 - vuntz@opensuse.org

View File

@ -17,6 +17,8 @@
# Please submit bugfixes or comments via http://bugs.opensuse.org/ # Please submit bugfixes or comments via http://bugs.opensuse.org/
# #
Name: faenza-icon-theme Name: faenza-icon-theme
Version: 1.2 Version: 1.2
Release: 0 Release: 0
@ -27,7 +29,10 @@ Url: http://tiheum.deviantart.com/art/Faenza-Icons-173323228
## http://www.deviantart.com/download/173323228/faenza_icons_by_tiheum-d2v6x24.zip ## http://www.deviantart.com/download/173323228/faenza_icons_by_tiheum-d2v6x24.zip
Source: faenza_icons_by_tiheum-d2v6x24.zip Source: faenza_icons_by_tiheum-d2v6x24.zip
Source1: http://gnome-look.org/CONTENT/content-files/132681-Faenza-Mint.tar.gz Source1: http://gnome-look.org/CONTENT/content-files/132681-Faenza-Mint.tar.gz
# script to rebrand and install stuff...
Source2: faenza-install
BuildRequires: fdupes BuildRequires: fdupes
BuildRequires: python
%if 0%{?suse_version} %if 0%{?suse_version}
# For all the icon themes macros # For all the icon themes macros
BuildRequires: hicolor-icon-theme BuildRequires: hicolor-icon-theme
@ -109,50 +114,18 @@ applications, folder, files and GNOME menu items.
%prep %prep
%setup -q -c "faenza-%{version}" -a 1 %setup -q -c "faenza-%{version}" -a 1
dist=
%if 0%{?suse_version:1}
dist=opensuse
%endif
%if 0%{?fedora_version:1}
dist=fedora
%endif
%if 0%{?mandriva_version:1} || 0%{?mdv_version:1}
dist=mandriva
%endif
[ -n "$dist" ] || { echo "Failed to determine distribution" >&2; exit 1; }
for f in Faenza*.tar.gz; do for f in Faenza*.tar.gz; do
tar xzf "$f" tar xzf "$f"
done done
find . -maxdepth 1 -type d -name 'Faenza*' | while read f; do
f="${f#*/}"
n="${f##*/}"
n="${n%.tar.gz}"
find "$n/" -type f ! -perm 0644 -exec chmod 0644 {} \;
pushd "$n"
find . -type f -name "distributor-logo-${dist}.*" | while read x; do
xf="${x##*/}"
xd="${x%/*}"
xe="${xf##*.}"
rm -f "$xd/distributor-logo.$xe"
ln -s "$xf" "$xd/distributor-logo.$xe"
rm -f "$xd/start-here.$xe"
ln -s "$xf" "$xd/start-here.$xe"
done
popd #$n
done
%build %build
%install %install
install -d "%{buildroot}%{_datadir}/icons" python %{S:2} --install %{buildroot}%{_datadir}/icons/
find . -maxdepth 1 -type d -name 'Faenza*' | while read d; do %fdupes %{buildroot}%{_datadir}/icons
n="${d##*/}" find %{buildroot}%{_datadir}/icons -type f -exec chmod 0644 {} \;
cp -a "$d" "%{buildroot}%{_datadir}/icons/$n"
%fdupes -s "%{buildroot}%{_datadir}/icons/$n"
done
%if 0%{?suse_version} > 1130 %if 0%{?suse_version} > 1130
%icon_theme_cache_create_ghost Faenza %icon_theme_cache_create_ghost Faenza
%icon_theme_cache_create_ghost Faenza-Ambiance %icon_theme_cache_create_ghost Faenza-Ambiance

174
faenza-install Normal file
View File

@ -0,0 +1,174 @@
#!/usr/bin/env python
#
# Copyright (c) 2011-2012 Nelson Marques <nmo.marques@gmail.com>
#
# crap script to rebrand and install faenza icon theme; this is aimed to
# be invoked from the .spec file during the install process.
#
import os, shutil, sys
from fnmatch import fnmatch
from optparse import OptionParser, OptionGroup
VERSION = '0.2'
icons = []
base = os.getcwd()
variants = ( 'Faenza-Ambiance', 'Faenza-Dark', 'Faenza-Darker',
'Faenza-Darkest', 'Faenza-Mint', 'Faenza-Radiance',
'Faenza')
class Faenza():
'''
print header
'''
def header(self):
print '\n faenza-install -- version %s \n' % VERSION
print ' This script performs minimum rebranding and installs the'
print ' faenza-icon-theme in INSTALL_DIR (sys.argv[1]). For help'
print ' run the following this script with "-h" or "--help". \n'
'''
returns a list of matching targets
'''
def scan(self, target):
for variant in variants:
for root, dirs, files in os.walk(variant):
for f in files:
if fnmatch(f, target + '.png'):
icons.append(root + '/' + f)
return 0
'''
delete designated file
'''
def delete(self, target):
try:
if os.path.exists(target):
os.unlink(target)
else:
print ' - file not found: %s' % target
except Exception, errno:
print errno
sys.exit(1)
return 0
'''
install a file
'''
def rebrand(self, distribution):
self.scan('start-here')
self.scan('distributor-logo')
if not icons:
print '\n - NO icons found.. Exiting!\n'
sys.exit(1)
else:
for icon in icons:
dirname, myfile = os.path.split(icon)
filename, myext = os.path.splitext(myfile)
print ' - %s' % icon
try:
self.delete(icon)
print ' + delete file: %s' % icon
except Exception, errno:
print errno
sys.exit(1)
os.chdir(dirname)
os.system('ln -s %s %s' % ( filename + '-' + dist + myext, myfile))
print ' + file rebranded to: %s' % ( filename + '-' + distribution + myext )
os.chdir(base)
return 0
'''
install Faenza themes on sys.argv[1]
'''
def install(self, target):
print ' - Installation \n'
for variant in variants:
fs_dir = os.path.join(target, variant)
if not os.path.isdir(fs_dir):
try:
shutil.copytree(variant, fs_dir)
print ' + file installed: %s' % fs_dir
except Exception, err:
print err
return 1
return 0
def main():
faenza = OptionParser(
usage = '%prog [OPTIONS] INSTALL_DIR',
epilog = ''' A simple python script to install icon theme with branding ''')
f_group = OptionGroup(faenza, 'Distribution Options: \n' +
' - opensuse, fedora, debian, frugalware, linux-mint, \n' +
' archlinux, gnome, mandriva, slackware, archlinux, \n' +
' ubuntu')
faenza.add_option('-v', '--version', action='store_true', dest='version',
default=False, help='print version and exit to shell')
faenza.add_option('-i', '--install', action='store_true', dest='install',
default=False, help='install icon themes on INSTALL_DIR')
faenza.add_option('-r', '--rebrand', action='store_true', dest='rebrand',
default=True, help='rebrand "start-here" and "distributor-logo" (default)')
faenza.add_option('--dist', action='store', dest='distribution',
default='opensuse', help='set default distribution for branding')
faenza.add_option_group(f_group)
(option, args) = faenza.parse_args()
if len(args) != 1:
faenza.print_help()
return 1
if option.version:
print '\n faenza-install -- version %s \n' % VERSION
print ' This script performs minimum rebranding and installs the'
print ' faenza-icon-theme in INSTALL_DIR (sys.argv[1]). For help'
print ' run the following this script with "-h" or "--help". \n'
sys.exit(0)
global dist
dist = str(option.distribution)
run = Faenza()
fs = args[0]
run.header()
if option.rebrand:
run.rebrand(dist)
if option.install:
if not os.path.isdir(fs):
os.makedirs(fs)
run.install(fs)
return 0
if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
pass