wok annotate get-litecoin/stuff/get-litecoin @ rev 22876

web-applications: localize wikipedia
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri Feb 21 18:28:59 2020 +0100 (2020-02-21)
parents c07aaa614a02
children
rev   line source
Hans-G?nter@22839 1 #!/bin/sh
Hans-G?nter@22839 2 #
Hans-G?nter@22839 3 # get-litecoin - create and install SliTaz package litecoin
Hans-G?nter@22839 4 #
Hans-G?nter@22839 5 # (C) 2020 SliTaz - GNU General Public License v3.
Hans-G?nter@22839 6 # Author : Pascal Bellard
Hans-G?nter@22839 7 # modified by HGT on 2020-02-11
Hans-G?nter@22839 8 #
pascal@14503 9
Hans-G?nter@22839 10 # === Initialisations ===
Hans-G?nter@22839 11
Hans-G?nter@22839 12 PKGS_DB="/var/lib/tazpkg" # packages database directory
Hans-G?nter@22839 13 PACKAGE="litecoin"
pascal@14503 14 CATEGORY="misc"
pascal@14503 15 SHORT_DESC="New digital currency for instant payments to anyone, anywhere."
pascal@14503 16 MAINTAINER="somebody@$PACKAGE.org"
Hans-G?nter@22839 17 WEB_SITE="https://litecoin.org/"
pascal@14503 18 DEPENDS="libQtGui bzlib"
pascal@14503 19
Hans-G?nter@22839 20 # Declare functions check_root, status, ...
Hans-G?nter@22839 21 . /lib/libtaz.sh
Hans-G?nter@22839 22 # and make commandline options (if any) available as variables
pascal@14503 23
Hans-G?nter@22839 24 is_installed()
Hans-G?nter@22839 25 {
Hans-G?nter@22839 26 if [ -d $ROOT$PKGS_DB/installed/$PACKAGE ]
Hans-G?nter@22839 27 then #package is deemed to be installed
Hans-G?nter@22839 28 return 0
Hans-G?nter@22839 29 else
Hans-G?nter@22839 30 return 1
Hans-G?nter@22839 31 fi
Hans-G?nter@22839 32 }
Hans-G?nter@22839 33
Hans-G?nter@22839 34 # Show commandline options, if requested by --help
Hans-G?nter@22839 35 if [ "$help" == "yes" ]
Hans-G?nter@22839 36 then
Hans-G?nter@22839 37 echo "Commandline options:
Hans-G?nter@22839 38 $0
Hans-G?nter@22839 39 --version=<version>
Hans-G?nter@22839 40 --root=<path-to-root>
Hans-G?nter@22839 41 --install=yes|no
Hans-G?nter@22839 42 --keep=no|yes
Hans-G?nter@22839 43 --tmpdir=<directory-to-build-package>"
Hans-G?nter@22839 44 exit
pascal@14503 45 fi
pascal@14503 46
Hans-G?nter@22839 47 # Check for system administrator privileges
Hans-G?nter@22839 48 check_root
Hans-G?nter@22839 49
Hans-G?nter@22839 50 title "Package $PACKAGE will be build as SliTaz package and installed"
Hans-G?nter@22839 51
Hans-G?nter@22839 52 # Fetch latest version, unless version is set by option --version
Hans-G?nter@22839 53 [ -z "$version" ] && version="latest"
Hans-G?nter@22839 54
Hans-G?nter@22839 55 # Install SliTaz package, unless inhibited by option --install=no
Hans-G?nter@22839 56 [ -z "$install" ] && install="yes"
Hans-G?nter@22839 57
Hans-G?nter@22839 58 # Delete SliTaz package file $PACKAGE-$VERSION.tazpkg after installation,
Hans-G?nter@22839 59 # unless option --keep=yes is given
Hans-G?nter@22839 60 [ -z "$keep" ] && keep="no"
Hans-G?nter@22839 61
Hans-G?nter@22839 62 # Directory for temporary files
Hans-G?nter@22839 63 TMP_DIR="$tmpdir"
Hans-G?nter@22839 64 [ -z "$tmpdir" ] && TMP_DIR="/tmp/get-$PACKAGE"
Hans-G?nter@22839 65
Hans-G?nter@22839 66 # Logging file (unused by now)
Hans-G?nter@22839 67 LOG="$logfile"
Hans-G?nter@22839 68 [ -z "$logfile" ] && LOG=$TMP_DIR/get-$PACKAGE.log
Hans-G?nter@22839 69
Hans-G?nter@22839 70 cat <<EOT
Hans-G?nter@22839 71 Options in use:
Hans-G?nter@22839 72 root : $root/
Hans-G?nter@22839 73 version : $version
Hans-G?nter@22839 74 install package: $install
Hans-G?nter@22839 75 keep tazpkg : $keep
Hans-G?nter@22839 76 build directory: $TMP_DIR
Hans-G?nter@22839 77
Hans-G?nter@22839 78 EOT
Hans-G?nter@22839 79
Hans-G?nter@22839 80 separator; newline
Hans-G?nter@22839 81
Hans-G?nter@22839 82 # === Remove package, if installed ===
Hans-G?nter@22839 83 if is_installed
Hans-G?nter@22839 84 then
Hans-G?nter@22839 85 echo "$PACKAGE is already installed."
Hans-G?nter@22839 86 echo -n "Would you like to remove and reinstall this package [y/n]? "
Hans-G?nter@22839 87 read answer
Hans-G?nter@22839 88 case "$answer" in
Hans-G?nter@22839 89 y|Y)
Hans-G?nter@22839 90 action "Removing installed version..."
Hans-G?nter@22839 91 tazpkg remove $PACKAGE --root="$root/"
Hans-G?nter@22839 92 [ ! is_installed ] &&
Hans-G?nter@22839 93 die "Can't remove installed version. Exiting."
Hans-G?nter@22839 94 ;;
Hans-G?nter@22839 95 *)
Hans-G?nter@22839 96 echo "Leaving $PACKAGE untouched."
Hans-G?nter@22839 97 exit 0
Hans-G?nter@22839 98 ;;
Hans-G?nter@22839 99 esac
pascal@14503 100 fi
pascal@14503 101
Hans-G?nter@22839 102 # === Fetch archive file, if not existing ===
Hans-G?nter@22839 103 if [ "$version" == "latest" ]
Hans-G?nter@22839 104 then
Hans-G?nter@22839 105 WGET_URL=$(wget --no-check-certificate -O - $WEB_SITE | \
Hans-G?nter@22839 106 sed '/i686-pc-linux-gnu.tar/!d;;s/.*href="\([^"]*\).*/\1/')
Hans-G?nter@22839 107 FILE="$(basename $WGET_URL)"
Hans-G?nter@22839 108 VERSION="$(echo $WGET_URL | sed 's|.*coin-\(.*\)/linux.*|\1|')"
Hans-G?nter@22839 109 else
Hans-G?nter@22839 110 FILE="litecoin-${version}-i686-pc-linux-gnu.tar.gz"
Hans-G?nter@22839 111 WGET_URL="https://download.litecoin.org/litecoin-$version/linux/$FILE"
Hans-G?nter@22839 112 VERSION=$version
pascal@14503 113 fi
pascal@14503 114
Hans-G?nter@22839 115 CUR_DIR=$(pwd)
Hans-G?nter@22839 116 mkdir -p $TMP_DIR
Hans-G?nter@22839 117 cd $TMP_DIR
Hans-G?nter@22839 118 if [ -f $FILE ]
Hans-G?nter@22839 119 then
Hans-G?nter@22839 120 echo "Using existing archive file $FILE"
Hans-G?nter@22839 121 else
Hans-G?nter@22839 122 action "Fetching the archive"
Hans-G?nter@22839 123 newline
Hans-G?nter@22839 124 wget --no-check-certificate $WGET_URL
Hans-G?nter@22839 125 if [ ! -f $FILE ]
Hans-G?nter@22839 126 then
Hans-G?nter@22839 127 cd $CUR_DIR
Hans-G?nter@22839 128 rm -rf $TMP_DIR
Hans-G?nter@22839 129 echo "Could not transfer $FILE from $WGET_URL. Exiting."
Hans-G?nter@22839 130 exit 1
Hans-G?nter@22839 131 fi
Hans-G?nter@22839 132 fi
Hans-G?nter@22839 133
Hans-G?nter@22839 134 # === Extract files from archive ===
Hans-G?nter@22839 135 action "Extracting the archive"
Hans-G?nter@22839 136 newline
Hans-G?nter@22839 137 set -x
pascal@14503 138 mkdir -p $PACKAGE-$VERSION/fs/usr/bin
pascal@22456 139 busybox tar xf $FILE
Hans-G?nter@22839 140 mv $PACKAGE-$VERSION/bin/* $PACKAGE-$VERSION/fs/usr/bin
pascal@14503 141
Hans-G?nter@22839 142 # Remove archive file
pascal@14503 143 rm -f $FILE
pascal@14503 144
pascal@14503 145 cd $PACKAGE-$VERSION/fs
pascal@14503 146
Hans-G?nter@22839 147 # Create desktop file
pascal@14503 148 mkdir -p usr/share/applications
pascal@14503 149 cat > usr/share/applications/$PACKAGE.desktop <<EOT
pascal@14503 150 [Desktop Entry]
pascal@14503 151 Version=1.0
pascal@14503 152 Encoding=UTF-8
pascal@14503 153 Name=$PACKAGE
pascal@14503 154 Exec=/usr/bin/$PACKAGE-qt
pascal@14503 155 Icon=stock_certificate.png
pascal@14503 156 Terminal=false
pascal@14503 157 Categories=Application
pascal@14503 158 Comment=$SHORT_DESC
pascal@14503 159 Type=Application
pascal@14503 160 Categories=Office;
pascal@14503 161 EOT
Hans-G?nter@22839 162
pascal@14503 163 cd ../..
pascal@14503 164
Hans-G?nter@22839 165 # Create recipe for SliTaz package
pascal@14503 166 cat > $PACKAGE-$VERSION/receipt <<EOT
Hans-G?nter@22839 167 # SliTaz package receipt.
Hans-G?nter@22839 168
pascal@14503 169 PACKAGE="$PACKAGE"
pascal@14503 170 VERSION="$VERSION"
pascal@14503 171 CATEGORY="$CATEGORY"
pascal@14503 172 SHORT_DESC="$SHORT_DESC"
pascal@14503 173 MAINTAINER="$MAINTAINER"
Hans-G?nter@22839 174 WEB_SITE="$WEB_SITE"
Hans-G?nter@22839 175
pascal@14503 176 DEPENDS="$DEPENDS"
pascal@14503 177 EOT
pascal@14503 178
Hans-G?nter@22839 179 action "Creating the package $PACKAGE..."
pascal@14503 180 # Pack
pascal@14503 181 tazpkg pack $PACKAGE-$VERSION
Hans-G?nter@22839 182 # Remove package tree
pascal@14503 183 rm -rf $PACKAGE-$VERSION
pascal@14503 184
Hans-G?nter@22839 185 # === Install the SliTaz package ===
Hans-G?nter@22839 186 [ "$install" == "yes" ] &&
Hans-G?nter@22839 187 tazpkg install $PACKAGE-$VERSION.tazpkg --root="$root"
pascal@14503 188
Hans-G?nter@22839 189 # === Cleanup ===
Hans-G?nter@22839 190 # Preserve package file, if requested
Hans-G?nter@22839 191 [ "$keep" == "yes" ] &&
Hans-G?nter@22839 192 ( mv $PACKAGE-$VERSION.tazpkg $CUR_DIR &&
Hans-G?nter@22839 193 echo Saved $PACKAGE-$VERSION.tazpkg to $CUR_DIR )
Hans-G?nter@22839 194
Hans-G?nter@22839 195 # Remove temporary build directory
pascal@14503 196 cd $CUR_DIR
pascal@14503 197 rm -rf $TMP_DIR