wok view get-OpenOffice/stuff/get-OpenOffice @ rev 25121

created recipe for get-OpenOffice
author Hans-G?nter Theisgen
date Mon Jun 27 15:00:45 2022 +0100 (23 months ago)
parents
children
line source
1 #!/bin/sh
2 # get-OpenOffice, install everything for OpenOffice except KDE and Gnome integration and testsuite.
3 #
4 # (C) 2022 SliTaz - GNU General Public License v3.
5 #
6 # Author : HGT
7 #
9 # === Initialisations ===
11 PKGS_DB="/var/lib/tazpkg" # packages database directory
12 PACKAGE="OpenOffice"
13 CATEGORY="office"
14 SHORT_DESC="Productivity suite."
15 MAINTAINER="nobody@slitaz.org"
16 LICENSE="Apache"
17 WEB_SITE="https://www.openoffice.org"
19 EXCLUDE="kde|gnome|test|onlineupdate"
21 # Declare functions check_root, status, ...
22 . /lib/libtaz.sh
23 # and make commandline options (if any) available as variables
25 is_installed()
26 {
27 if [ -d $ROOT$PKGS_DB/installed/$PACKAGE ]
28 then #package is deemed to be installed
29 return 0
30 else
31 return 1
32 fi
33 }
35 # Show commandline options, if requested by --help
36 if [ "$help" == "yes" ]
37 then
38 echo "Commandline options:
39 $0
40 --version=<version>
41 --lang=<language>
42 --root=<path-to-root>
43 --install=yes|no
44 --keep=no|yes
45 --tmpdir=<directory-to-build-package>
46 --logfile=<logging-file>"
47 exit
48 fi
50 # Check for system administrator privileges
51 check_root
53 title "Package $PACKAGE will be build as SliTaz package and installed"
55 # Fetch latest version
56 # unless version is set by option --version
57 [ -z "$version" ] && version="latest"
59 # Fetch RPM package for english language
60 # unless language is set by option --lang
61 [ -z "$lang" ] && lang="en-GB"
63 # Install SliTaz package
64 # unless inhibited by option --install=no
65 [ -z "$install" ] && install="yes"
67 # Delete SliTaz package file $PACKAGE-$VERSION.tazpkg after installation
68 # unless option --keep=yes is given
69 [ -z "$keep" ] && keep="no"
71 # Directory for temporary files
72 TMP_DIR="$tmpdir"
73 [ -z "$tmpdir" ] && TMP_DIR="/tmp/get-$PACKAGE"
75 # Logging file
76 LOG="$logfile"
77 [ -z "$logfile" ] && LOG=$TMP_DIR/get-$PACKAGE.log
79 cat <<EOT
80 Options in use:
81 root : $root/
82 version : $version
83 lang : $lang
84 install package: $install
85 keep tazpkg : $keep
86 build directory: $TMP_DIR
87 logging file : $LOG
89 EOT
91 separator; newline
93 # Set VERSION, unless supplied by --version
94 if [ "$version" == "latest" ]
95 then
96 echo "Selecting latest version from $WEB_SITE ..."
97 VERSION=$(wget -O - $WEB_SITE 2>/dev/null | sed '/Released: Apache OpenOffice /!d;s|.* OpenOffice ||;s|</a></div>||')
98 else
99 VERSION=$version
100 fi
102 MV=${VERSION%%.*} # main version
104 TARBALL=Apache_OpenOffice_${VERSION}_Linux_x86_install-rpm_${lang}.tar.gz
105 echo "Archive is $TARBALL ..."
106 WGET_URL=https://archive.apache.org/dist/openoffice/$VERSION/binaries/$lang/$TARBALL
108 # === Remove package, if installed ===
109 if is_installed
110 then
111 echo "$PACKAGE is already installed."
112 echo -n "Would you like to remove and reinstall this package [y/n]? "
113 read answer
114 case "$answer" in
115 (y|Y)
116 action "Removing installed version..."
117 newline
118 tazpkg remove $PACKAGE --root="$root/"
119 [ ! is_installed ] &&
120 die "Can't remove installed version. Exiting."
121 ;;
122 (*)
123 echo "Leaving $PACKAGE untouched."
124 exit 0
125 ;;
126 esac
127 fi
129 # === Fetch archive file, if not existing ===
131 CUR_DIR=$(pwd)
132 mkdir -p $TMP_DIR
133 cd $TMP_DIR
134 if [ -f $TARBALL ]
135 then
136 echo "Using existing archive file $TARBALL"
137 else
138 action "Fetching the archive"
139 newline
140 wget --no-check-certificate $WGET_URL
141 if [ ! -f $TARBALL ]
142 then
143 cd $CUR_DIR
144 rm -rf $TMP_DIR
145 echo "Could not transfer $TARBALL from $WGET_URL. Exiting."
146 exit 1
147 fi
148 fi
150 # === Extract files from archive ===
151 action "Extracting the archive"
152 newline
154 tar x -vf $TARBALL > $LOG 2>&1 || \
155 (echo "Failed to extract $TARBALL" ; exit 1)
157 status
159 # Remove archive file
160 rm -f $TARBALL
162 # Extract everything from rpm files and remove them
163 cd $TMP_DIR/*/RPMS
164 for i in *.rpm
165 do
166 if (! echo $i | egrep -qi $EXCLUDE)
167 then
168 (rpm2cpio $i | cpio -id >> $LOG 2>&1 ) &&
169 rm -f $i
170 fi
171 done
173 # Extracted from freedesktop rpm and remove it
174 rpm2cpio desktop-integration/*freedesktop*.rpm | cpio -id >> $LOG 2>&1
175 rm -f desktop-integration/*freedesktop*.rpm
177 # Prepare the package tree
178 mkdir -p $PACKAGE-$VERSION/fs/usr/lib/openoffice
179 mkdir -p $PACKAGE-$VERSION/fs/usr/share
181 mv opt/openoffice* $PACKAGE-$VERSION/fs/usr/lib/openoffice
182 mv usr/share/mime $PACKAGE-$VERSION/fs/usr/share
183 mv usr/share/icons $PACKAGE-$VERSION/fs/usr/share
184 mv usr/bin $PACKAGE-$VERSION/fs/usr
186 # relocalised OOo libexec directory
187 sed -i 's|/opt/|/usr/lib/openoffice/|' \
188 $PACKAGE-$VERSION/fs/usr/bin/openoffice*
190 # Create recipe for tazpkg
191 cat > $PACKAGE-$VERSION/receipt <<EOT
192 # SliTaz package receipt.
194 PACKAGE="$PACKAGE"
195 VERSION="$VERSION"
196 CATEGORY="$CATEGORY"
197 SHORT_DESC="$SHORT_DESC"
198 MAINTAINER="$MAINTAINER"
199 LICENSE="$LICENSE"
200 WEB_SITE="$WEB_SITE"
202 post_install()
203 {
204 cd \$1/usr/share/applications
205 ln -s /usr/lib/openoffice/openoffice$MV/share/xdg/base.desktop openoffice$MV-base.desktop
206 ln -s /usr/lib/openoffice/openoffice$MV/share/xdg/impress.desktop openoffice$MV-impress.desktop
207 ln -s /usr/lib/openoffice/openoffice$MV/share/xdg/writer.desktop openoffice$MV-writer.desktop
208 ln -s /usr/lib/openoffice/openoffice$MV/share/xdg/calc.desktop openoffice$MV-calc.desktop
209 ln -s /usr/lib/openoffice/openoffice$MV/share/xdg/math.desktop openoffice$MV-math.desktop
210 ln -s /usr/lib/openoffice/openoffice$MV/share/xdg/draw.desktop openoffice$MV-draw.desktop
211 ln -s /usr/lib/openoffice/openoffice$MV/share/xdg/printeradmin.desktop openoffice$MV-printeradmin.desktop
213 cd \$1/usr/bin
214 ln -sf /usr/lib/openoffice/openoffice$MV/program/soffice
215 }
217 post_remove()
218 {
219 rm -f \$1/usr/share/applications/openoffice$MV-*
220 }
222 EOT
224 # Pack
225 tazpkg pack $PACKAGE-$VERSION
226 # Remove package tree
227 rm -rf $PACKAGE-$VERSION
229 # === Install the SliTaz package ===
230 [ "$install" == "yes" ] &&
231 tazpkg install $PACKAGE-$VERSION.tazpkg --root="$root"
233 # === Cleanup ===
234 # Preserve package file, if requested
235 [ "$keep" == "yes" ] &&
236 ( mv $PACKAGE-$VERSION.tazpkg $CUR_DIR &&
237 echo Saved $PACKAGE-$VERSION.tazpkg to $CUR_DIR )
239 # Remove temporary build directory
240 cd $CUR_DIR
241 rm -rf $TMP_DIR