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