wok view get-flash-plugin/stuff/get-flash-plugin @ rev 22835

modified get-flash-plugin
author Hans-G?nter Theisgen
date Mon Feb 10 10:39:19 2020 +0100 (2020-02-10)
parents d5999a28461c
children
line source
1 #!/bin/sh
2 #
3 # get-flash-plugin - create and install SliTaz package flash-plugin
4 #
5 # (C) 2020 SliTaz - GNU General Public License v3.
6 # Author : Pascal Bellard
7 # modified by HGT on 2020-02-10
8 #
10 # === Initialisations ===
12 PKGS_DB="/var/lib/tazpkg" # packages database directory
13 PACKAGE="flash-plugin"
14 SHORT_DESC="Adobe Flash Player."
15 CATEGORY="non-free"
16 LICENSE="non-free"
17 WEB_SITE="https://www.adobe.com/products/flashplayer/"
19 DEPENDS="atk cairo curl expat fontconfig freetype glib gtk+ libfirefox libpng \
20 nss pango pixman xorg-libICE xorg-libSM xorg-libX11 xorg-libXau xorg-libXcomposite \
21 xorg-libXcursor xorg-libXdamage xorg-libXdmcp xorg-libXext xorg-libXfixes \
22 xorg-libXinerama xorg-libXrandr xorg-libXrender xorg-libXt zlib"
24 # Declare functions check_root, status, ...
25 . /lib/libtaz.sh
26 # and make commandline options (if any) available as variables
28 is_installed()
29 {
30 if [ -d $ROOT$PKGS_DB/installed/$PACKAGE ]
31 then #package is deemed to be installed
32 return 0
33 else
34 return 1
35 fi
36 }
38 # Show commandline options, if requested by --help
39 if [ "$help" == "yes" ]
40 then
41 echo "Commandline options:
42 $0
43 --version=<version>
44 --root=<path-to-root>
45 --install=yes|no
46 --keep=no|yes
47 --tmpdir=<directory-to-build-package>"
48 exit
49 fi
51 # Check for system administrator privileges
52 check_root
54 title "Package $PACKAGE will be build as SliTaz package and installed"
56 # Fetch latest version, unless version is set by option --version
57 [ -z "$version" ] && version="latest"
59 # Install SliTaz package, unless inhibited by option --install=no
60 [ -z "$install" ] && install="yes"
62 # Delete SliTaz package file $PACKAGE-$VERSION.tazpkg after installation,
63 # unless option --keep=yes is given
64 [ -z "$keep" ] && keep="no"
66 # Directory for temporary files
67 TMP_DIR="$tmpdir"
68 [ -z "$tmpdir" ] && TMP_DIR="/tmp/get-$PACKAGE"
70 # Logging file (unused by now)
71 LOG=$TMP_DIR/get-$PACKAGE.log
73 cat <<EOT
74 Options in use:
75 root : $root/
76 version : $version
77 install package: $install
78 keep tazpkg : $keep
79 build directory: $TMP_DIR
81 EOT
83 separator; newline
85 # === Remove package, if installed ===
86 if is_installed
87 then
88 echo "$PACKAGE is already installed."
89 echo -n "Would you like to remove and reinstall this package [y/n]? "
90 read answer
91 case "$answer" in
92 y|Y)
93 action "Removing installed version..."
94 tazpkg remove $PACKAGE --root="$root/"
95 [ ! is_installed ] &&
96 die "Can't remove installed version. Exiting."
97 ;;
98 *)
99 echo "Leaving $PACKAGE untouched."
100 exit 0
101 ;;
102 esac
103 fi
105 # === Fetch archive file, if not existing ===
106 if [ "$version" == "latest" ]
107 then
108 VERSION="$(wget --no-check-certificate -q -O - \
109 https://helpx.adobe.com/flash-player/kb/archived-flash-player-versions.html |\
110 sed -n '/Released /p' | head -1 | sed 's|.*fp_\(.*\)_archive.*|\1|')"
111 else
112 VERSION=$version
113 fi
114 FILE="fp_${VERSION}_archive.zip"
115 WGET_URL="https://fpdownload.macromedia.com/pub/flashplayer/installers/archive/$FILE"
117 CUR_DIR=$(pwd)
118 mkdir -p $TMP_DIR
119 cd $TMP_DIR
120 if [ -f $FILE ]
121 then
122 echo "Using existing archive file $FILE"
123 else
124 action "Fetching the archive"
125 newline
126 wget --no-check-certificate $WGET_URL
127 if [ ! -f $FILE ]
128 then
129 cd $CUR_DIR
130 rm -rf $TMP_DIR
131 echo "Could not transfer $FILE from $WGET_URL. Exiting."
132 exit 1
133 fi
134 fi
136 # === Extract files from archive ===
137 action "Extracting the archive"
138 newline
140 mkdir $PACKAGE
141 cd $PACKAGE
142 unzip $TMP_DIR/$FILE *linux.i386.tar.gz
143 tar xf */*linux.i386.tar.gz
144 status
146 # Remove archive file
147 cd $TMP_DIR
148 rm -f $FILE
150 # Install files
151 fs=$PACKAGE-$VERSION/fs
152 mkdir -p $fs/usr/share/flash
154 mv $PACKAGE/libflashplayer.so $fs/usr/share/flash
155 chmod 755 $fs/usr/share/flash/libflashplayer.so
156 chown root.root $fs/usr/share/flash/libflashplayer.so
157 mv $PACKAGE/usr/bin $fs/usr
158 mv $PACKAGE/usr/share/icons $fs/usr/share
159 mv $PACKAGE/usr/share/pixmaps $fs/usr/share
160 mv $PACKAGE/usr/share/applications $fs/usr/share
162 # Sanity Check: Reexport firefox libraries if they don't exist
163 dir=$PACKAGE-$VERSION/fs/usr/lib
164 mkdir -p $dir
165 for i in /usr/lib/firefox/*.so
166 do
167 [ -f $i ] &&
168 [ -z "$(ls /usr/lib/$(basename $i))" ] &&
169 ln -s $i $dir
170 done
172 # === Create SliTaz package ===
174 cd $PACKAGE-$VERSION
176 # Create recipe for SliTaz package
177 cat > receipt <<EOT
178 # SliTaz package receipt.
180 PACKAGE="$PACKAGE"
181 VERSION="$VERSION"
182 CATEGORY="$CATEGORY"
183 SHORT_DESC="$SHORT_DESC"
184 LICENSE="$LICENSE"
185 WEB_SITE="$WEB_SITE"
187 DEPENDS="$DEPENDS"
189 post_install()
190 {
191 [ -d \$1/usr/lib/mozilla/plugins ] || mkdir -p \$1/usr/lib/mozilla/plugins
192 ln -s /usr/share/flash/libflashplayer.so \$1/usr/lib/mozilla/plugins
193 [ -d \$1/opt/google/chrome/plugins ] || mkdir -p \$1/opt/google/chrome/plugins
194 ln -s /usr/share/flash/libflashplayer.so \$1/opt/google/chrome/plugins/libgcflashplayer.so
195 [ -d \$1/usr/lib/opera/plugins ] || mkdir -p \$1/usr/lib/opera/plugins
196 ln -s /usr/share/flash/libflashplayer.so \$1/usr/lib/opera/plugins/libflashplayer.so
197 }
199 post_remove()
200 {
201 rm -f \$1/usr/lib/mozilla/plugins/libflashplayer.so
202 rm -f \$1/opt/google/chrome/plugins/libgcflashplayer.so
203 rm -f \$1/usr/lib/opera/plugins/libflashplayer.so
204 }
205 EOT
207 cd $TMP_DIR
209 action "Creating the package $PACKAGE..."
210 # Pack
211 tazpkg pack $PACKAGE-$VERSION
212 # Remove package tree
213 rm -rf $PACKAGE-$VERSION
215 # === Install the SliTaz package ===
216 [ "$install" == "yes" ] &&
217 tazpkg install $PACKAGE-$VERSION.tazpkg --root="$root"
219 # === Cleanup ===
220 # Preserve package file, if requested
221 [ "$keep" == "yes" ] &&
222 ( mv $PACKAGE-$VERSION.tazpkg $CUR_DIR &&
223 echo Saved $PACKAGE-$VERSION.tazpkg to $CUR_DIR )
225 # Remove temporary build directory
226 cd $CUR_DIR
227 rm -rf $TMP_DIR