wok view get-litecoin/stuff/get-litecoin @ rev 25037

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