From d51045ef79db9abef2578e8c21c9eb9c49eb2057 Mon Sep 17 00:00:00 2001 From: Botspot Date: Thu, 24 Sep 2020 09:47:21 -0500 Subject: [PATCH] major updates --- apps/Cool Retro Term/installed-packages | 1 - apps/FreeCAD (precompiled)/install | 4 +- apps/FreeCAD/install | 2 +- apps/TBOPlayer/description | 43 +++++ apps/TBOPlayer/icon-24.png | Bin 0 -> 999 bytes apps/TBOPlayer/icon-64.png | Bin 0 -> 2321 bytes apps/TBOPlayer/install | 13 ++ apps/TBOPlayer/uninstall | 12 ++ apps/TBOPlayer/website | 1 + apps/template/install | 1 - .../installed-packages/Arduino | 0 data/installed-packages/TBOPlayer | 2 + data/{apps => status}/Arduino | 0 data/{apps => status}/BalenaEtcher | 0 data/{apps => status}/Chromium Media Edition | 0 data/{apps/FreeCAD => status/CommanderPi} | 0 data/{apps => status}/Cool Retro Term | 0 data/{apps => status}/Cura | 0 data/status/FreeCAD | 1 + data/{apps => status}/FreeCAD (precompiled) | 0 data/{apps => status}/Pi Power Tools | 0 data/{apps => status}/Raspi2png | 0 data/{apps/CommanderPi => status/TBOPlayer} | 0 gui | 23 ++- manage | 149 +++++++++++++++--- pi-apps.desktop | 8 + pkg-install | 41 ++--- purge-installed | 28 ++-- update/pi-apps | 1 + 29 files changed, 265 insertions(+), 65 deletions(-) delete mode 100644 apps/Cool Retro Term/installed-packages create mode 100644 apps/TBOPlayer/description create mode 100644 apps/TBOPlayer/icon-24.png create mode 100644 apps/TBOPlayer/icon-64.png create mode 100755 apps/TBOPlayer/install create mode 100755 apps/TBOPlayer/uninstall create mode 100644 apps/TBOPlayer/website rename apps/CommanderPi/installed-packages => data/installed-packages/Arduino (100%) create mode 100644 data/installed-packages/TBOPlayer rename data/{apps => status}/Arduino (100%) rename data/{apps => status}/BalenaEtcher (100%) rename data/{apps => status}/Chromium Media Edition (100%) rename data/{apps/FreeCAD => status/CommanderPi} (100%) rename data/{apps => status}/Cool Retro Term (100%) rename data/{apps => status}/Cura (100%) create mode 100644 data/status/FreeCAD rename data/{apps => status}/FreeCAD (precompiled) (100%) rename data/{apps => status}/Pi Power Tools (100%) rename data/{apps => status}/Raspi2png (100%) rename data/{apps/CommanderPi => status/TBOPlayer} (100%) create mode 100644 pi-apps.desktop create mode 160000 update/pi-apps diff --git a/apps/Cool Retro Term/installed-packages b/apps/Cool Retro Term/installed-packages deleted file mode 100644 index 8b13789..0000000 --- a/apps/Cool Retro Term/installed-packages +++ /dev/null @@ -1 +0,0 @@ - diff --git a/apps/FreeCAD (precompiled)/install b/apps/FreeCAD (precompiled)/install index 6e771d6..b3ff66e 100755 --- a/apps/FreeCAD (precompiled)/install +++ b/apps/FreeCAD (precompiled)/install @@ -15,7 +15,9 @@ wget --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download rm -f /tmp/cookies.txt || echo "Warning: failed to remove cookies.txt." -unzip ~/freecad-precompiled.zip || error "Failed to extract archive!" +rm -rf freecad-build FreeCAD-0.18.4 || error "Failed to delete freecad-build and FreeCAD-0.18.4 folders!" + +unzip -q ~/freecad-precompiled.zip || error "Failed to extract archive!" rm -f ~/freecad-precompiled.zip || error "Failed to delete archive!" cd freecad-build || error "Failed to enter directory!" diff --git a/apps/FreeCAD/install b/apps/FreeCAD/install index 2acde3f..ffe22b9 100755 --- a/apps/FreeCAD/install +++ b/apps/FreeCAD/install @@ -19,7 +19,7 @@ wget https://github.com/FreeCAD/FreeCAD/archive/0.18.4.zip || error "failed to d #ensure there's no directory in there already rm -rf ~/FreeCAD-0.18.4 ~/freecad-build 2>/dev/null -unzip 0.18.4.zip || error "failed to extract ZIP file!" +unzip -q 0.18.4.zip || error "failed to extract ZIP file!" rm 0.18.4.zip || error "failed to delete ZIP file!" diff --git a/apps/TBOPlayer/description b/apps/TBOPlayer/description new file mode 100644 index 0000000..3a0e743 --- /dev/null +++ b/apps/TBOPlayer/description @@ -0,0 +1,43 @@ +Python-powered GUI for OMXPlayer with YouTube functionality. +To run: Menu -> Sound & Video -> TBOPlayer +To run in a terminal: python /opt/tboplayer/tboplayer.py + +Buttons: +• ADD - duplicates the Track>Add menu item +• ADD DIR - duplicates the Track>Add Dir menu item +• EDIT - duplicates the Track>Edit menu item +• OPEN/SAVE/CLEAR LIST - duplicates the Playlist>Open,Save,Clear menu item +• PLAY/PAUSE - play the selected track or pause if playing +• STOP - stop playing, operational only during playing +• PREVIOUS - play previous track, operational only after played some track +• NEXT - play next track, up to mode that you set +• - VOL + - minus/plus volume control +• Playlist - can be clicked over to play a track, and can be used to add tracks by 'drag and dropping' files over +• Progress bar - show/Seek position +• Resize video - at the bottom right side of the video progress bar, allows resizing video + +Menus: +• Track - add tracks (for selecting multiple tracks, hold ctrl when clicking) or directories, edit or remove tracks (or URLs) from the current playlist +• Playlist - save the current playlist or open a saved one or load youtube playlist +• OMX - display the track information for the last played track +• Options - see below: + +Options: +• Audio Output - play sound to hdmi, local, both or ALSA device. +• Mode - play the Single selected track, Repeat the single track, rotate around the Playlist starting from the selected track, randomly play a track from the Playlist. +• Initial directory for tracks - where Add Track starts looking. +• Initial directory for playlists - where Open Playlist starts looking +• Enable subtitles - download and use subtitles from streamming services +• OMXPlayer location - path to omxplayer binary +• OMXplayer options - add your own (no validation so be careful) +• Download from Youtube - defines whether to download video and audio or audio only from Youtube (other online video services will always be asked for "video and audio") +• Download actual media URL [when] - defines when to extract the actual media from the given URL, either upon adding the URL or when playing it +• Youtube media quality - lets you choose among "small", "medium" and "high" qualities (Youtube only feature) +• youtube-dl location - path to youtube-dl binary +• Interface language - change GUI active language, requires restart +• Start/End track paused - pauses the track both in the beginning and in the end of the track +• Autoplay at start up - if TBOPlayer has just been opened and has some file in the playlist, automatically start playing the first file in the list +• Keep youtube-dl up-to-date - upon start, check if there is a newer version of youtube-dl, and if there is, install it +• Forbid windowed mode - if enabled will make videos always show in full screen, disabling the video window mode and video progress bar - may be useful if you're using tboplayer through a remote desktop +• Find lyrics - if enabled, TBOPlayer will try to fetch lyrics for playing track - defaults to off - more details below +• Debug - prints some debug text to the command line/log file (requires you to close and restart tboplayer) \ No newline at end of file diff --git a/apps/TBOPlayer/icon-24.png b/apps/TBOPlayer/icon-24.png new file mode 100644 index 0000000000000000000000000000000000000000..bf22185e135e3b6300adf872b27183f1aa68d548 GIT binary patch literal 999 zcmVOOhcs*}|qNBqS}_7bhDH5z!#{ zphzA>L0YWZiXgNg2*n#pA4JyIXh90zQ1nei1PLVs5y9YYA_R;<+qHxyE%p+kxol>> zBD{1B1Yzssj8VBEG6#iRhY0)KR`6NvKRFlX(Yt8^HJdBe7WQ8xcWO zEpQ2VFQ3oPM&9nrK{*l&psJ`U#+W!T1SCY{Ctw2jD5ASB<7Ee?l8y*9{6EH+bD_bj zHShNApemZE6IH$6TDubRUq#gRok2Y6BrI^*I3hA-jCn2yg5N}B68K_dWMsrzdkT06 z=mC7-PhiSgdtrWlKH3=7sn&t$sI@i=bgQaAJUslRwe}YgdC9=hdv z81qLalX+`=e7tPe#`l1zsH(q)q9Nd-h&&=9&-83<@#4w~B)e@~>2%rw#=Cu=`_|Wy zFiHXB#0g|+2|0Tfah$5V$8O#v+yaj_8W@{MBo2y5qHlAPa(`*$)V4OrX3>QObYh|+ zKeWA#V=W@m*ASv02#l&$($bm}!rAHSg2RVVQ_`$tBVrmt)ZX5{3iy9FH&;I_e?b7} z&m)6_$mAqqEds1M4%;P&t~7*bW@e@c{JiQoEVQèmEdLDB6G-SJ53C8|xe$9d#S&{}14I Vbzg&0Y`_2j002ovPDHLkV1jM`%t8PF literal 0 HcmV?d00001 diff --git a/apps/TBOPlayer/icon-64.png b/apps/TBOPlayer/icon-64.png new file mode 100644 index 0000000000000000000000000000000000000000..8529dfa5a5dec361ec0199fdbb2cdf9cf27f4568 GIT binary patch literal 2321 zcmV+s3GViZP)-b#TCbYXVvI7R6#`>iU1)~Bvc|=(IPdXK}ftr1GGg=3k@w*Li11?;@Oa(Vj?Ha z!({VtlC7U>d%dS0yr%2Bcm2HA4k~}iANHJ?b7uZ`9%s&s;r|?Bj4{Af9@%TO*1qSF zt#LsPutr3F;*q`I1D`7b0u$YUiN+TMOmqV#8lDoMs$QBK7vun&fo(3j)xajVN~-#z zi2Tw;)$C#0#s!j1QC(fV4tU*7r>aj`YagzzuAZl=_labhQPm{S3LFD$GMW6>fddDU z-Za}go{Lcxu-+I`IF3GtgdbDjG|-f?T`3}Y03uQd+^?$Tz^%ivWsI2& zlmjIxdvTyyL{8P$*LQo-UO%S5*82MT2LOyQ<*K?XH7)vai!o-Qwf3;Ht}$i~um-pe zs1cDlZa!2sVT@@2{sFuTY`507ji$Yx6OayTZIdx(J8)0GOhi!CCBR_-V@v?}CU75c zt=qZ62@%NwmZbjfRMie+%p1Tn*4l$3X``=eKvh*$4q#kV2>@fvY9JyaZ;8mTI`0M% zDHM_K0v{S<-ZaL{A8uVg)__&j)z#0aY96pcM3y@A04IzwzY&pdd+9qx;BBh9#u)Rc zs{SGpi3}Qa`LPC60ab&1&BMT3j&;EmQxXZvySkW`NRX>aJP_bqZZ0SD^XUm>AG{(` z0Q?-d&KR@aS{ut&*4H(_2~|x13$v1=N>y7Mt1n*UnwA!3cXhcYEP6!vxUi7j#l`%2 z`gEfC`L5l45ouANt9RV>Ec(I^W$JBPHHtIE>$ zc9yocbI++$>?|qaxw0~jPMVZaRz#Mn>fekpE3LI>o%+EDh?70V)tc(uK49)(HhOz| zn}fk%C9tPICP+u9yPL<39pjqT)?r1?O{fGjyu@oVE7eblG@> z!kgSWzakdn*~UgsI}h;X_I6%qXdu+>8YtdljJZBt;Ohu5#?$~GIOqKpZEb8me3*P6 z)96PF3fQn{5p6jGXSu2#1unPN#=-v)u*uo^X+1q`I&#F<&I8Pk$EiDh92|Z`WIk|r z|8L(2FveUZBG)?Q51u^9j6}jOw*ycci*fyh3vQ|hjWK!P?+CcpDY&Aojc;7MICRZr z%V73wPa1Lmr=OCa92g9WNI89nE`JCx#uNazIprIo(cvvRS6>Yc4NzAHE_?e(FtewJ zHRsQ}sn&ykBVd(?OimZf>gr;7OUv*r6c)nckE0C@aQp3JYRs+Y&bf(K8)NePB4DLc za9u1mDz;_L9N4-QcI^V=cCZ{83p+cR9Ul2)3B<1sjJIPT;@3es+#9K^h`}8{0TW1EP!p>(CyoyvU1R(#qJ+q zsvlDz!=~TirYv6$H{392nJjGxc%BbPBogu5+}vdPjZnuR*_$yTnS_^Kf=3>K)29b5 z+8zwLi90-R*`Y&+k~s1Rt-&DeUX!qQZ(qQ)VZ)G}2RP$$JO{f30=;%P7cmftJg4bTlIOPq6$doB=;)8w> zu*WHQzocYzmQ>-5H=wc-sjGug#1j{CayVF2d+pLI0 zVCBlbv%vA=qi)RGrKKb@ld=1(wHJILz*>7+RsTLfD8ehVW@V}2Kyx$Pbr;ms^qm35 zfNl}C&YbC{dL8^ti$4#nN*Da8w3Iu}oT0*TFv-Byt)4aF^_ep{;|Q5k4>eu|e`A#2 zs_LMq_~+EAoXF4Ts+Jb=JV=u_78G#bf(0CO54vK&YHRI) z{Fv_q07RqF55wVbo``(ascS4O46<|DG~S&)on8@Ub$3&g9Q-k<0u6ymF698b0`8x25hzv6{963^v=y$BOCk87wA+NSm|6F;w zs%}XgN<4$AUQpHV1GPhS9wul6q{A4q7s7$kw|2SLq;Yp83NLA<&{?!h{zIPF?~;Er}4k1vghb~ rZ}d?h5NO=LfBz-(zXxC7^N9ZfhT#!uMHyBB00000NkvXXu0mjf)#XpA literal 0 HcmV?d00001 diff --git a/apps/TBOPlayer/install b/apps/TBOPlayer/install new file mode 100755 index 0000000..bca7134 --- /dev/null +++ b/apps/TBOPlayer/install @@ -0,0 +1,13 @@ +#!/bin/bash + +function error { + echo -e "\e[31m$1\e[39m" + exit 1 +} + +# Get dependencies +DIRECTORY="$(dirname "$(dirname "$(dirname "$0")")")" +"${DIRECTORY}/pkg-install" "python-pip python-gobject-2 python-dbus python-tk python-gtk2 python-requests tkdnd" "$(dirname "$0")" || exit 1 + +cd ~ && wget https://github.com/KenT2/tboplayer/tarball/py2_version -O - | tar xz || error "Failed to download!" +cd KenT2-tboplayer-* && chmod +x setup.sh && ./setup.sh || error "failed to run setup.sh!" diff --git a/apps/TBOPlayer/uninstall b/apps/TBOPlayer/uninstall new file mode 100755 index 0000000..876edce --- /dev/null +++ b/apps/TBOPlayer/uninstall @@ -0,0 +1,12 @@ +#!/bin/bash + +function error { + echo -e "\e[31m$1\e[39m" + exit 1 +} + +DIRECTORY="$(dirname "$(dirname "$(dirname "$0")")")" +"${DIRECTORY}/purge-installed" "$(dirname "$0")" || exit 1 + +#run uninstall script, saying 'yes' to the first question, and 'no' to the second question +echo -e "y\nn" | /opt/tboplayer/setup.sh uninstall || error "failed to uninstall!" diff --git a/apps/TBOPlayer/website b/apps/TBOPlayer/website new file mode 100644 index 0000000..134ad21 --- /dev/null +++ b/apps/TBOPlayer/website @@ -0,0 +1 @@ +https://github.com/KenT2/tboplayer/tree/py2_version diff --git a/apps/template/install b/apps/template/install index e578f42..48de87a 100755 --- a/apps/template/install +++ b/apps/template/install @@ -8,4 +8,3 @@ function error { # Get dependencies DIRECTORY="$(dirname "$(dirname "$(dirname "$0")")")" #"${DIRECTORY}/pkg-install" "" "$(dirname "$0")" || exit 1 -read enter diff --git a/apps/CommanderPi/installed-packages b/data/installed-packages/Arduino similarity index 100% rename from apps/CommanderPi/installed-packages rename to data/installed-packages/Arduino diff --git a/data/installed-packages/TBOPlayer b/data/installed-packages/TBOPlayer new file mode 100644 index 0000000..36552a6 --- /dev/null +++ b/data/installed-packages/TBOPlayer @@ -0,0 +1,2 @@ + libav-tools + diff --git a/data/apps/Arduino b/data/status/Arduino similarity index 100% rename from data/apps/Arduino rename to data/status/Arduino diff --git a/data/apps/BalenaEtcher b/data/status/BalenaEtcher similarity index 100% rename from data/apps/BalenaEtcher rename to data/status/BalenaEtcher diff --git a/data/apps/Chromium Media Edition b/data/status/Chromium Media Edition similarity index 100% rename from data/apps/Chromium Media Edition rename to data/status/Chromium Media Edition diff --git a/data/apps/FreeCAD b/data/status/CommanderPi similarity index 100% rename from data/apps/FreeCAD rename to data/status/CommanderPi diff --git a/data/apps/Cool Retro Term b/data/status/Cool Retro Term similarity index 100% rename from data/apps/Cool Retro Term rename to data/status/Cool Retro Term diff --git a/data/apps/Cura b/data/status/Cura similarity index 100% rename from data/apps/Cura rename to data/status/Cura diff --git a/data/status/FreeCAD b/data/status/FreeCAD new file mode 100644 index 0000000..6e88c9b --- /dev/null +++ b/data/status/FreeCAD @@ -0,0 +1 @@ +uninstalled diff --git a/data/apps/FreeCAD (precompiled) b/data/status/FreeCAD (precompiled) similarity index 100% rename from data/apps/FreeCAD (precompiled) rename to data/status/FreeCAD (precompiled) diff --git a/data/apps/Pi Power Tools b/data/status/Pi Power Tools similarity index 100% rename from data/apps/Pi Power Tools rename to data/status/Pi Power Tools diff --git a/data/apps/Raspi2png b/data/status/Raspi2png similarity index 100% rename from data/apps/Raspi2png rename to data/status/Raspi2png diff --git a/data/apps/CommanderPi b/data/status/TBOPlayer similarity index 100% rename from data/apps/CommanderPi rename to data/status/TBOPlayer diff --git a/gui b/gui index 5ef13ff..823d26c 100755 --- a/gui +++ b/gui @@ -11,15 +11,15 @@ while true;do APPS="$(echo "$APPS" | tr '\n' '|')" PREIFS="$IFS" - IFS=$"|" + IFS="|" LIST='' for i in $APPS do - LIST="$LIST$(echo "${DIRECTORY}/icons/$(cat "${DIRECTORY}/data/apps/${i}" || echo "none").png") + LIST="$LIST$(echo "${DIRECTORY}/icons/$(cat "${DIRECTORY}/data/status/${i}" || echo "none").png") ${DIRECTORY}/apps/${i}/icon-24.png $i -"\("$(cat "${DIRECTORY}/data/apps/${i}" || echo "Unknown state")"\)" $(echo "$(cat "${DIRECTORY}/apps/${i}/description" || echo "Description unavailable")" | head -n1) +"\("$(cat "${DIRECTORY}/data/status/${i}" || echo "Unknown state")"\)" $(echo "$(cat "${DIRECTORY}/apps/${i}/description" || echo "Description unavailable")" | head -n1) " done IFS="$PREIFS" @@ -50,7 +50,20 @@ $i 0) echo "Details" + + info="$(if [ -f "${DIRECTORY}/data/status/${output}" ];then + echo -n "Current status: " + cat "${DIRECTORY}/data/status/${output}" + fi + + if [ ! -z "$(cat "${DIRECTORY}/data/installed-packages/${output}")" ];then + echo -n "This app installed these packages: " + cat "${DIRECTORY}/data/installed-packages/${output}" | tr '\n' ' ' + fi + )" + text="$(echo "$(cat "${DIRECTORY}/apps/${output}/description" || echo "Description unavailable")" | head -n1) +$info Website: $(cat "${DIRECTORY}/apps/${output}/website" || echo "unavailable") $(echo "$(cat "${DIRECTORY}/apps/${output}/description" || echo "Description unavailable")" | grep -v "$(echo "$(cat "${DIRECTORY}/apps/${output}/description" || echo "Description unavailable")" | head -n1)")" echo "$text" | yad --text-info --fontname=12 --wrap --show-uri \ @@ -63,11 +76,11 @@ $(echo "$(cat "${DIRECTORY}/apps/${output}/description" || echo "Description una 2) echo "Uninstall" - "${DIRECTORY}/manage" "$output" uninstall + "${DIRECTORY}/manage" uninstall "$output" ;; 4) echo "Install" - "${DIRECTORY}/manage" "$output" install + "${DIRECTORY}/manage" install "$output" ;; esac done diff --git a/manage b/manage index ae2c277..e80cecd 100755 --- a/manage +++ b/manage @@ -1,54 +1,67 @@ #!/bin/bash -#$1 is name of software, like Arduino -#$2 is install/uninstall +#$1 is an action, like install +#$2 is app name, like Arduino DIRECTORY="$(readlink -f "$(dirname "$0")")" function error { - echo -e "\e[31m$1\e[39m" + echo -e "\e[91m$1\e[39m" exit 1 } if [ -z "$1" ];then - error "You need to specify which app, and which action to apply to it. (install/uninstall)" -elif [ ! -d "${DIRECTORY}/apps/$1" ];then - error "${DIRECTORY}/apps/$1 does not exist!" + error "You need to specify an operation, and in most cases, which app to operate on." fi -if [ "$2" == 'install' ];then +if [ "$1" == 'install' ];then + #for this operation, a program name must be specified. + if [ -z "$2" ];then + error "For this operation, you must specify which app to operate on." + elif [ ! -d "${DIRECTORY}/apps/$2" ];then + error "${DIRECTORY}/apps/$2 does not exist!" + fi + #INSTALL #ensure an install script is not already running if ps -C install ;then echo "An install script is already running. -Pi-Apps will wait until that one finishes before starting this one." | yad --text-info \ +Pi-Apps will wait until that one finishes before installing $2." | yad --text-info \ --title="Waiting" --window-icon="${DIRECTORY}/icons/logo.png" --center --width=500 --height=100 \ --button=OK!"${DIRECTORY}/icons/check.png":0 --fontname=12 --timeout=10 --timeout-indicator=top while ps -C install ;do sleep 1; done fi #if already installed then ask for confirmation - if [ "$(cat "${DIRECTORY}/data/apps/${1}" )" == 'installed' ];then - yad --text="$1 is already installed. Are you sure you want to install it again?" \ + if [ "$(cat "${DIRECTORY}/data/status/${2}" )" == 'installed' ];then + yad --text="$2 is already installed. Are you sure you want to install it again?" \ --text-align=center --center --title='Quick question' --window-icon="${DIRECTORY}/icons/logo.png" \ --button=No!"${DIRECTORY}/icons/exit.png":1 --button=Yes!"${DIRECTORY}/icons/check.png":0 || exit 0 fi - lxterminal --title="Installing $1" -e " + lxterminal --title="Installing $2" -e " cd $HOME - echo 'corrupted' > \"${DIRECTORY}/data/apps/${1}\" - if \"${DIRECTORY}/apps/${1}/install\" ; then - echo 'installed' > \"${DIRECTORY}/data/apps/${1}\" + echo 'corrupted' > \"${DIRECTORY}/data/status/${2}\" + if \"${DIRECTORY}/apps/${2}/install\" ; then + echo 'installed' > \"${DIRECTORY}/data/status/${2}\" echo -en '\n\e[42m\e[30mCommand succeeded.\e[39m\e[49m\nClose this window to exit.' read enter #technically you could press Enter to exit. else - echo 'corrupted' > \"${DIRECTORY}/data/apps/${1}\" + echo 'corrupted' > \"${DIRECTORY}/data/status/${2}\" echo -en '\n\e[41m\e[30mCommand failed!\e[39m\e[49m\nClose this window to exit.' read enter #technically you could press Enter to exit. fi" #wait until script is done before this command exits sleep 2 while ps -C install >/dev/null;do sleep 1; done -elif [ "$2" == 'uninstall' ];then + +elif [ "$1" == 'uninstall' ];then + #for this operation, a program name must be specified. + if [ -z "$2" ];then + error "For this operation, you must specify which app to operate on." + elif [ ! -d "${DIRECTORY}/apps/$2" ];then + error "${DIRECTORY}/apps/$2 does not exist!" + fi + #UNINSTALL #ensure an uninstall script is not already running if ps -C install ;then echo "An uninstall script is already running. @@ -59,27 +72,115 @@ Pi-Apps will wait until that one finishes before starting this one." | yad --tex fi #if already uninstalled then ask for confirmation - if [ "$(cat "${DIRECTORY}/data/apps/${1}" )" == 'uninstalled' ];then - yad --text="$1 is already uninstalled. Are you sure you want to uninstall it again?" \ + if [ "$(cat "${DIRECTORY}/data/status/${2}" )" == 'uninstalled' ];then + yad --text="$2 is already uninstalled. Are you sure you want to uninstall it again?" \ --text-align=center --center --title='Quick question' --window-icon="${DIRECTORY}/icons/logo.png" \ --button=No!"${DIRECTORY}/icons/exit.png":1 --button=Yes!"${DIRECTORY}/icons/check.png":0 || exit 0 fi - lxterminal --title="Uninstalling $1" -e " + lxterminal --title="Uninstalling $2" -e " cd $HOME - echo 'corrupted' > \"${DIRECTORY}/data/apps/${1}\" - if \"${DIRECTORY}/apps/${1}/uninstall\" ; then - echo 'uninstalled' > \"${DIRECTORY}/data/apps/${1}\" + echo 'corrupted' > \"${DIRECTORY}/data/status/${2}\" + if \"${DIRECTORY}/apps/${2}/uninstall\" ; then + echo 'uninstalled' > \"${DIRECTORY}/data/status/${2}\" echo -en '\n\e[42m\e[30mCommand succeeded.\e[39m\e[49m\nClose this window to exit.' read enter #technically you could press Enter to exit. else - echo 'corrupted' > \"${DIRECTORY}/data/apps/${1}\" + echo 'corrupted' > \"${DIRECTORY}/data/status/${2}\" echo -en '\n\e[41m\e[30mCommand failed!\e[39m\e[49m\nClose this window to exit.' read enter #technically you could press Enter to exit. fi" #wait until script is done before this command exits sleep 2 while ps -C uninstall >/dev/null;do sleep 1; done +elif [ "$1" == 'update' ];then + #for this operation, a program name must be specified. + if [ -z "$2" ];then + error "For this operation, you must specify which app to operate on." + fi + #UPDATE + + rm -rf "${DIRECTORY}/update" && mkdir "${DIRECTORY}/update" && cd "${DIRECTORY}/update" || error "failed to enter the update directory!" + git clone https://github.com/Botspot/pi-apps || error "failed to clone repository!" + + newhash=$(find "${DIRECTORY}/update/pi-apps/apps/${2}" -type f -print0 | xargs -0 sha1sum | awk '{print $1}' | sha1sum | awk '{print $1}') + oldhash=$(find "${DIRECTORY}/apps/${2}" -type f -print0 | xargs -0 sha1sum | awk '{print $1}' | sha1sum | awk '{print $1}') + + echo -e "newhash: $newhash\noldhash: $oldhash" + + if [ "$newhash" == "$oldhash" ];then + echo "$2 is identical to the online version. Nothing to do!" + exit 0 + else + echo "$2 is not identical to the online version. Reinstalling..." + fi + #else + #if installed already + if [ "$(cat "${DIRECTORY}/data/status/${2}")" == 'installed' ];then + installback=yes + #uninstall it using a recursive script instance + "${DIRECTORY}/manage" uninstall "$2" + else + installback=no + fi + + #move old program to trash + gio trash "${DIRECTORY}/apps/${2}" + + #copy new version to apps/ + cp -rf "${DIRECTORY}/update/pi-apps/apps/${2}" "${DIRECTORY}/apps/${2}" + + if [ "$installback" == 'yes' ];then + echo "$2 was originally installed before updating. Reinstalling the new version now." + #install it using a recursive script instance + "${DIRECTORY}/manage" install "$2" + fi +elif [ "$1" == 'check-all' ];then + #for this operation, a program name cannot be specified. + #CHECK-ALL + + rm -rf "${DIRECTORY}/update" && mkdir "${DIRECTORY}/update" && cd "${DIRECTORY}/update" || error "failed to enter the update directory!" + git clone https://github.com/Botspot/pi-apps || error "failed to clone repository!" + + updatable='' + echo "app list: $(echo "$(ls "${DIRECTORY}/update/pi-apps/apps")" | grep -v 'template')" + + PREIFS="$IFS" + IFS="|" + newapps="$(echo "$(ls "${DIRECTORY}/update/pi-apps/apps")" | grep -v 'template' | tr '\n' '|')" + for newapp in $newapps + do + echo "newapp: $newapp" + newhash=$(find "${DIRECTORY}/update/pi-apps/apps/${newapp}" -type f -print0 | xargs -0 sha1sum | awk '{print $1}' | sha1sum | awk '{print $1}') + oldhash=$(find "${DIRECTORY}/apps/${newapp}" -type f -print0 | xargs -0 sha1sum | awk '{print $1}' | sha1sum | awk '{print $1}') + echo -e "newhash: $newhash\noldhash: $oldhash" + + if [ "$newhash" == "$oldhash" ];then + echo "${newapp} is identical to the online version. Nothing to do!" + else + echo "${newapp} is not identical to the online version. Adding to updatable list..." + updatable="${updatable}|${newapp}" + fi + done + #remove initial '|' character + updatable="${updatable:1}" + + IFS="$PREIFS" + echo -e "These apps can be updated:\n${updatable}" +elif [ "$1" == 'update-all' ];then + #for this operation, a program name cannot be specified. + PREIFS="$IFS" + IFS='|' + updatable="$("${DIRECTORY}/manage" check-all | tail -1)" + echo "Updatable: ${updatable}EOU" + for updateapp in $updatable + do + echo "updating $updateapp" + #update it using a recursive script instance + echo "${DIRECTORY}/manage update $updateapp" + "${DIRECTORY}/manage" update "$updateapp" + done + IFS="$PREIFS" else - error "Did not understand $2. It must be either "\'"install"\'" or "\'"uninstall"\'"." + error "Did not understand ${1}. It must be either "\'"install"\'", "\'"uninstall"\'", "\'"update"\'", or "\'"check-all"\'"." fi diff --git a/pi-apps.desktop b/pi-apps.desktop new file mode 100644 index 0000000..c0baa15 --- /dev/null +++ b/pi-apps.desktop @@ -0,0 +1,8 @@ +[Desktop Entry] +Name=Pi-Apps +Comment=Simple RPI App Store for projects not in the repositories +Exec=/home/pi/pi-apps/gui +Icon=/home/pi/pi-apps/icons/logo.png +Terminal=false +Type=Application +Categories=Utility; diff --git a/pkg-install b/pkg-install index ed88830..1f14a1a 100755 --- a/pkg-install +++ b/pkg-install @@ -1,39 +1,42 @@ #!/bin/bash #$1 is a quotation-marked, space-seperated list of package names. -#$2 is the path to the program folder being installed. For example, /home/pi/pi-apps/apps/Arduino +#$2 is the path to the program folder being installed. #Example usage: ~/pi-apps/pkg-install "gparted buffer expect" ~/pi-apps/apps/Arduino PKG_LIST="$1" -PRG_DIR="$2" +PRG="$(echo "$2" | tr '/' '\n' | tail -1)" + +DIRECTORY="$(readlink -f "$(dirname "$0")")" + +function error { + echo -e "\e[91m$1\e[39m" + exit 1 +} + +echo "Running pkg-install..." if [ -z "$PKG_LIST" ];then echo -e "\e[91mNo packages were specified!\e[39m" - exit=1 + exit=yes fi -if [ -z "$PRG_DIR" ];then +if [ -z "$PRG" ];then echo -e "\e[91mNo program directory specified!\e[39m" - exit=1 -elif [ ! -d "$PRG_DIR" ];then - echo -e "\e[91m$PRG_DIR does not exist!\e[39m" - exit=1 -elif [ -z "$(echo "$PRG_DIR" | grep "pi-apps/apps")" ];then - echo -e "\e[33mWarning: That program directory ($PRG_DIR) is located outside of pi-apps.\e[39m" + exitcode=1 +elif [ ! -d "$2" ];then + echo -e "\e[91m$2 does not exist!\e[39m" + exitcode=1 +elif [ -z "$(echo "$2" | grep "pi-apps/apps")" ];then + echo -e "\e[33mWarning: That program directory ($PRG) is located outside of pi-apps.\e[39m" fi -if [ ! -z $exit ];then +if [ ! -z $exitcode ];then echo -e '$1 is a quotation-marked, space-seperated list of package names.\n$2 is the path to the program folder being installed.\nExample usage: ~/pi-apps/pkg-install '\"'gparted buffer expect'\"' ~/pi-apps/apps/Arduino' echo -e "\e[91mExiting now.\e[39m" exit 1 fi -if [ "$PRG_DIR" == "*/" ]; then # ensure there is no trailing slash - PRG_DIR=${PRG_DIR: :-1} -fi - -echo "Running pkg-install..." - output="$(sudo apt update 2>&1)" exitcode=$? @@ -59,7 +62,7 @@ do done #save that list of installed packages in the program directory for future removal -echo $INSTALL_LIST >> "$PRG_DIR/installed-packages" +echo "$INSTALL_LIST" >> "${DIRECTORY}/data/installed-packages/${PRG}" if [ ! -z "$INSTALL_LIST" ];then echo -e "These packages will be installed: \e[2m$INSTALL_LIST\e[22m" @@ -75,7 +78,7 @@ if [ ! -z "$INSTALL_LIST" ];then INSTALL_LIST='' for i in $PKG_LIST do - PKG_OK="$(dpkg-query -W --showformat='${Status}\n' "$i" 2>/dev/null |grep "install ok installed")" + PKG_OK="$(dpkg-query -W --showformat='${Status}\n' "$i" 2>/dev/null | grep "install ok installed")" if [ "" == "$PKG_OK" ]; then INSTALL_LIST="${INSTALL_LIST} ${i}" #add package to install list fi diff --git a/purge-installed b/purge-installed index b5d7aeb..77c302a 100755 --- a/purge-installed +++ b/purge-installed @@ -3,36 +3,38 @@ #$1 is the path to the program folder being installed. For example, /home/pi/pi-apps/apps/Arduino #Example usage: ~/pi-apps/uninstall-installed ~/pi-apps/apps/Arduino -PRG_DIR="$1" +PRG="$(echo "$1" | tr '/' '\n' | tail -1)" -if [ -z "$PRG_DIR" ];then +DIRECTORY="$(readlink -f "$(dirname "$0")")" + +if [ -z "$PRG" ];then echo -e "\e[91mNo program directory specified!\e[39m" exitcode=1 -elif [ ! -d "$PRG_DIR" ];then - echo -e "\e[91m$PRG_DIR does not exist!\e[39m" +elif [ ! -d "$1" ];then + echo -e "\e[91m$1 does not exist!\e[39m" exitcode=1 -elif [ -z "$(echo "$PRG_DIR" | grep "pi-apps/apps")" ];then - echo -e "\e[33mWarning: That program directory ($PRG_DIR) is located outside of pi-apps.\e[39m" +elif [ -z "$(echo "$1" | grep "pi-apps/apps")" ];then + echo -e "\e[33mWarning: That program directory ($1) is located outside of pi-apps.\e[39m" fi if [ ! -z $exitcode ];then echo -e "\e[91mExiting now.\e[39m" - exit $exit + exit 1 fi function error { - echo -e "\e[31m$1\e[39m" + echo -e "\e[91m$1\e[39m" exit 1 } echo "Running purge-installed..." -PKG_LIST="$(cat "$PRG_DIR/installed-packages")" +PKG_LIST="$(cat "${DIRECTORY}/data/installed-packages/${PRG}")" -if [ ! -f "$PRG_DIR/installed-packages" ];then - echo -e "\e[33mDoes $PRG_DIR/installed-packages exist?\e[39m" +if [ ! -f "${DIRECTORY}/data/installed-packages/${PRG}" ];then + echo -e "\e[33mDoes ${DIRECTORY}/data/installed-packages/${PRG} exist?\e[39m" exit 0 fi -if [ -z "$PRG_DIR/installed-packages" ];then +if [ -z "${DIRECTORY}/data/installed-packages/${PRG}" ];then echo "Nothing to purge. Exiting now." exit 0 fi @@ -71,5 +73,5 @@ if [ ! -z "$INSTALL_LIST" ];then error "\e[91mAPT did not exit with an error, but these packages are still installed somehow: $INSTALL_LIST\e[39m" else echo -e "\e[32mAll packages were purged succesfully.\e[39m" - rm "$PRG_DIR/installed-packages" + gio trash "${DIRECTORY}/data/installed-packages/${PRG}" fi diff --git a/update/pi-apps b/update/pi-apps new file mode 160000 index 0000000..637d24d --- /dev/null +++ b/update/pi-apps @@ -0,0 +1 @@ +Subproject commit 637d24d884a25d46012a5b5ab6fb876686fe6bdf