wok view get-dropbox/stuff/get-dropbox @ rev 22833

Add webgames
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Feb 08 18:41:54 2020 +0100 (2020-02-08)
parents 48da20277f5a
children 49bbb4b9da3c
line source
1 #!/bin/sh
2 #
3 # get-dropbox - create and install SliTaz package dropbox
4 #
5 # (C) 2020 SliTaz - GNU General Public License v3.
6 # Author : unknown
7 # modified by HGT on 2020-02-07
8 #
10 # === Initialisations ===
12 PKGS_DB="/var/lib/tazpkg" # packages database directory
13 PACKAGE="dropbox"
14 WEB_SITE="https://www.dropbox.com"
15 CATEGORY="non-free"
16 DEPENDS="python"
18 PLATFORM="lnx.x86" # or lnx.x86_64
20 # Declare functions check_root, status, ...
21 . /lib/libtaz.sh
22 # and make commandline options (if any) available as variables
24 is_installed()
25 {
26 if [ -d $ROOT$PKGS_DB/installed/$PACKAGE ]
27 then #package is deemed to be installed
28 return 0
29 else
30 return 1
31 fi
32 }
34 # Show commandline options, if requested by --help
35 if [ "$help" == "yes" ]
36 then
37 echo "Commandline options:
38 $0
39 --root=<path-to-root>
40 --install=yes|no
41 --keep=no|yes
42 --tmpdir=<directory-to-build-package>"
43 exit
44 fi
46 # Check for system administrator privileges
47 check_root
49 title "Package $PACKAGE will be build as SliTaz package and installed"
51 # Fetch latest version, unless version is set by option --version (unusable by now)
52 [ -z "$version" ] && version="latest"
54 # Install SliTaz package, unless inhibited by option --install=no
55 [ -z "$install" ] && install="yes"
57 # Delete SliTaz package file $PACKAGE-$VERSION.tazpkg after installation,
58 # unless option --keep=yes is given
59 [ -z "$keep" ] && keep="no"
61 # Directory for temporary files
62 [ -z "$tempdir" ] && TMP_DIR="/tmp/get-$PACKAGE"
64 # Logging file (unused by now)
65 LOG=$TMP_DIR/get-$PACKAGE.log
67 cat <<EOT
68 Options in use:
69 root : $root/
70 install package: $install
71 keep tazpkg : $keep
72 build directory: $TMP_DIR
74 EOT
76 separator; newline
78 # === Remove package, if installed ===
79 if [ is_installed ]
80 then
81 action "Removing installed version..."
82 tazpkg remove $PACKAGE --root="$root/"
83 [ ! is_installed ] &&
84 die "Can't remove installed version. Exiting."
85 fi
87 # === Fetch archive file, if not existing ===
88 if [ "$version" == "latest" ]
89 then
90 FILE=$PACKAGE-$PLATFORM.tar.gz
91 WGET_URL="$WEB_SITE/download?plat=$PLATFORM"
92 else
93 die "A version cannot be specified. Exiting."
94 fi
96 CUR_DIR=$(pwd)
97 mkdir -p $TMP_DIR
98 cd $TMP_DIR
99 if [ -f $FILE ]
100 then
101 echo "Using existing archive file $FILE"
102 else
103 action "Fetching the archive"
104 newline
105 wget --no-check-certificate -O $FILE $WGET_URL
106 if [ ! -f $FILE ]
107 then
108 cd $CUR_DIR
109 rm -rf $TMP_DIR
110 echo "Could not transfer $FILE from $WGET_URL. Exiting."
111 exit 1
112 fi
113 fi
115 # === Extract files from archive ===
116 action "Extracting the archive"
117 newline
119 tar xzf $FILE
120 status
122 # Remove archive file
123 rm -f $FILE
125 # === Create SliTaz package ===
127 VERSION="$(cat $TMP_DIR/.dropbox-dist/VERSION)"
129 mkdir -p $PACKAGE-$VERSION/fs/usr/lib
130 mkdir -p $PACKAGE-$VERSION/fs/usr/bin
131 mkdir -p $PACKAGE-$VERSION/fs/usr/share/applications
133 mv $TMP_DIR/.dropbox-dist $PACKAGE-$VERSION/fs/usr/lib/dropbox
134 strip $PACKAGE-$VERSION/fs/usr/lib/dropbox 2>/dev/null
136 # Customise Dropboxd
137 cat > $PACKAGE-$VERSION/fs/usr/lib/dropbox/dropboxd << "EOT"
138 #!/bin/sh
139 PAR=$(ls -d /usr/lib/dropbox/dropbox-lnx*)
140 LD_LIBRARY_PATH=$PAR:$LD_LIBRARY_PATH exec $PAR/dropboxd $@
141 EOT
143 # Create Desktop file
144 cat > $PACKAGE-$VERSION/fs/usr/share/applications/dropbox.desktop << EOT
145 [Desktop Entry]
146 Type=Application
147 Name=Dropbox Storage
148 Exec=dropboxd
149 Icon=dropbox
150 Terminal=false
151 Categories=Network
152 EOT
154 # Create symbolic links to have Dropbox in PATH and fake nautilus
155 cd $PACKAGE-$VERSION/fs/usr/bin
156 rm -f dropboxd nautilus
157 ln -s ../lib/dropbox/dropboxd .
158 ln -s /usr/bin/pcmanfm nautilus
160 cd $TMP_DIR
162 # Create recipe for SliTaz package
163 cat > $PACKAGE-$VERSION/receipt << EOT
164 # SliTaz package receipt.
166 PACKAGE="$PACKAGE"
167 VERSION="$VERSION"
168 CATEGORY="$CATEGORY"
169 SHORT_DESC="Dropbox daemon and client for online storage."
170 WEB_SITE="$WEB_SITE/"
172 SUGGESTED="ntlmaps"
173 DEPENDS="$DEPENDS"
174 EOT
176 action "Creating the package $PACKAGE..."
177 # Pack
178 tazpkg pack $PACKAGE-$VERSION
180 # Remove package tree
181 rm -rf $PACKAGE-$VERSION
183 # === Install the SliTaz package ===
184 [ "$install" == "yes" ] &&
185 yes y | tazpkg install $PACKAGE-$VERSION.tazpkg --root="$root"
187 # === Cleanup ===
188 # Preserve package file, if requested
189 [ "$keep" == "yes" ] &&
190 ( mv $PACKAGE-$VERSION.tazpkg $CUR_DIR &&
191 echo Saved $PACKAGE-$VERSION.tazpkg to $CUR_DIR )
193 # Remove temporary build directory
194 cd $CUR_DIR
195 rm -rf $TMP_DIR