wok view get-eclipse-pdt/stuff/get-eclipse-pdt @ rev 3893

get-*: do not create empty packages
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri Aug 14 10:01:38 2009 +0200 (2009-08-14)
parents e01dd228942a
children 4e3fdb23a650
line source
1 #!/bin/sh
2 # get-eclipse-pdt, get and install Eclipse PHP Development tool.
3 #
4 # (C) 2008 SliTaz - GNU General Public License v3.
5 #
6 # Author : Eric Joseph-Alexandre <erjo@slitaz.org>
8 PACKAGE="eclipse-pdt"
9 VERSION="1.0.3"
10 URL="http://www.eclipse.org"
11 TARBALL="pdt-all-in-one-linux-gtk-${VERSION}.tar.gz"
12 WGET_URL="http://www.eclipse.org/downloads/download.php?file=/tools/pdt/downloads/drops/1.0.3/R200806030000/pdt-all-in-one-linux-gtk-1.0.3.tar.gz&url=http://eclipse.ialto.org/tools/pdt/downloads/drops/1.0.3/R200806030000/${TARBALL}&mirror_id=514"
13 TEMP_DIR="/home/slitaz/build/$PACKAGE.$$"
14 SOURCE_DIR="/home/slitaz/src"
15 LOG="/tmp/$(basename $0 .sh).log"
16 ROOT="$1"
18 # Status function with color (supported by Ash).
19 status()
20 {
21 local CHECK=$?
22 echo -en "\\033[70G[ "
23 if [ $CHECK = 0 ]; then
24 echo -en "\\033[1;33mOK"
25 else
26 echo -en "\\033[1;31mFailed"
27 fi
28 echo -e "\\033[0;39m ]"
29 return $CHECK
30 }
32 # Check if user is root to install, or remove packages.
33 check_root()
34 {
35 if test $(id -u) != 0 ; then
36 echo -e "\nYou must be root to run `basename $0` with this option."
37 echo -e "Please use 'su' and root password to become super-user.\n"
38 exit 0
39 fi
40 }
42 check_if_installed()
43 {
44 # Avoid reinstall
45 if [ -d $ROOT/var/lib/tazpkg/installed/$PACKAGE ];then
46 return 1
47 else
48 return 0
49 fi
50 }
52 #We need to bee root
53 check_root
55 #check if package already installed
56 if (check_if_installed $PACKAGE); then
57 echo "$PACKAGE is already installed."
58 [ -n "$ROOT" ] && exit 0
59 echo -n "Would you like to remove and reinstall this package [y/n]? "
60 read answer
61 case "$answer" in
62 y|Y)
63 tazpkg remove $PACKAGE ;;
64 *)
65 exit 0 ;;
66 esac
68 fi
71 # Check if we have the tarball before.
72 if [ ! -f $SOURCE_DIR/$TARBALL ]; then
73 echo "Downloading $PACKAGE tarball (it's time to have a break)... "
74 #Check if $SOURCE_DIR exist
75 test -d $SOURCE_DIR || mkdir -p $SOURCE_DIR
76 # Get the file.
77 wget -c $WGET_URL -O $SOURCE_DIR/$TARBALL
78 status
79 fi
81 if [ ! -f $SOURCE_DIR/$TARBALL ]; then
82 rm -rf $TEMP_DIR
83 rm -rf $PACKAGE-$VERSION
84 echo "Could not download $TARBALL. Exiting."
85 exit 1
86 fi
88 # Creates TEM_DIR and extract tarball
89 mkdir -p $TEMP_DIR
90 echo -n "Extract files from archive..."
91 tar xvzf $SOURCE_DIR/$TARBALL -C $TEMP_DIR > $LOG 2>&1 || \
92 (echo "Failed to extract $TARBALL" ; exit 1)
93 status
96 cd $TEMP_DIR
98 # Make the package
99 mkdir -p $PACKAGE-$VERSION/fs/usr/lib \
100 $PACKAGE-$VERSION/fs/usr/share/pixmaps \
101 $PACKAGE-$VERSION/fs/usr/share/applications
103 cp -a eclipse $PACKAGE-$VERSION/fs/usr/lib/
104 cp -a eclipse/icon.xpm $PACKAGE-$VERSION/fs/usr/share/pixmaps/eclipse.xpm
106 # Create .desktop file
107 cat >> $PACKAGE-$VERSION/fs/usr/share/applications/$PACKAGE.desktop <<EOF
108 [Desktop Entry]
109 Type=Application
110 Version=1.0
111 Name=Eclipse
112 Name[fr]=Eclipse
113 GenericName=Eclipse Integrated Development Environment
114 GenericName[fr]=Environnement de Développement Eclipse
115 Comment=PHP Development Tools
116 Comment[fr]=Outils de developpement PHP
117 Exec=/usr/lib/eclipse/eclipse
118 Icon=eclipse.xpm
119 Terminal=false
120 Categories=GTK;Development;IDE;
121 StartupNotify=true
122 EOF
123 # Create receipt
124 cat > $PACKAGE-$VERSION/receipt <<EOT
125 # SliTaz package receipt.
127 PACKAGE="$PACKAGE"
128 VERSION="$VERSION"
129 CATEGORY="development"
130 SHORT_DESC="PHP Development Tools"
131 WEB_SITE="$URL"
133 EOT
135 # Pack
136 tazpkg pack $PACKAGE-$VERSION
138 # Install pseudo package
139 tazpkg install $PACKAGE-$VERSION.tazpkg --root=$ROOT
141 # Clean
142 rm -rf $TEMP_DIR
143 rm -rf $PACKAGE-$VERSION