mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-07-11 08:05:59 +08:00
first test
This commit is contained in:
parent
4165bea193
commit
a86ef64352
2
debian/changelog
vendored
2
debian/changelog
vendored
@ -1,4 +1,4 @@
|
||||
spark-store (4.2.11~chocolate) stable; urgency=medium
|
||||
spark-store (4.2.11~in-ace-release) stable; urgency=medium
|
||||
|
||||
* 修复:判断是否安装状态错误
|
||||
|
||||
|
@ -488,7 +488,7 @@ void AppIntoPage::on_pushButton_3_clicked()
|
||||
ui->pushButton_3->setEnabled(false);
|
||||
|
||||
QProcess uninstall;
|
||||
uninstall.start("pkexec", QStringList() << "apt" << "autopurge" << "-y" << info["Pkgname"].toString().toLower());
|
||||
uninstall.start("host-spawn", QStringList() << "pkexec" << "apt" << "autopurge" << "-y" << info["Pkgname"].toString().toLower());
|
||||
uninstall.waitForFinished(-1);
|
||||
|
||||
QProcess check;
|
||||
|
@ -175,7 +175,7 @@ void DownloadItem::slotAsyncInstall(int t)
|
||||
switch (t)
|
||||
{
|
||||
case 0:
|
||||
installer.start("pkexec", QStringList() << "/usr/local/bin/ssinstall"
|
||||
installer.start("host-spawn", QStringList() << "pkexec" << "/usr/local/bin/ssinstall"
|
||||
<< "/tmp/spark-store/" + ui->label_filename->text().toUtf8() << "--delete-after-install");
|
||||
break;
|
||||
case 1:
|
||||
|
@ -1,14 +0,0 @@
|
||||
Debug::RunScripts true;
|
||||
Dir::Cache::archives "/var/cache/apt/archives";
|
||||
Dir::Cache "/var/lib/aptss/";
|
||||
Dir::Etc::SourceParts "/opt/durapps/spark-store/bin/apt-fast-conf/sources.list.d/";
|
||||
Dir::State::lists "/var/lib/aptss/lists/";
|
||||
|
||||
APT::Get::Fix-Broken true;
|
||||
APT::Get::List-Cleanup="0";
|
||||
|
||||
#clear APT::Update::Post-Invoke-Success;
|
||||
|
||||
#clear DPkg::Post-Invoke;
|
||||
|
||||
#clear DPkg::Pre-Install-Pkgs;
|
@ -1,677 +0,0 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# apt-fast v1.9
|
||||
# Use this just like aptitude or apt-get for faster package downloading.
|
||||
#
|
||||
# Copyright: 2008-2012 Matt Parnell, http://www.mattparnell.com
|
||||
# Improvements, maintenance, revisions - 2012, 2017-2018 Dominique Lasserre
|
||||
#
|
||||
# You may distribute this file under the terms of the GNU General
|
||||
# Public License as published by the Free Software Foundation; either
|
||||
# version 3 of the License, or (at your option) any later version.
|
||||
#
|
||||
[ -n "$DEBUG" ] && set -xv
|
||||
|
||||
# Print colored messages.
|
||||
# Usage: msg "message text" "message type" "optional: err"
|
||||
# Message types are 'normal', 'hint' or 'warning'. Warnings and messages with a
|
||||
# third argument are piped to stderr.
|
||||
msg(){
|
||||
msg_options=()
|
||||
case "$2" in
|
||||
normal) beginColor="$cGreen";;
|
||||
hint) beginColor="$cBlue";;
|
||||
warning) beginColor="$cRed";;
|
||||
question) beginColor="$cRed"; msg_options=(-n);;
|
||||
*) beginColor= ;;
|
||||
esac
|
||||
|
||||
if [ -z "$3" ] && [ "$2" != "warning" ]; then
|
||||
echo -e "${msg_options[@]}" "${aptfast_prefix}${beginColor}$1${endColor}"
|
||||
else
|
||||
echo -e "${msg_options[@]}" "${aptfast_prefix}${beginColor}$1${endColor}" >&2
|
||||
fi
|
||||
}
|
||||
|
||||
# Search for known options and decide if root privileges are needed.
|
||||
root=1 # default value: we need root privileges
|
||||
option=
|
||||
for argument in "$@"; do
|
||||
case "$argument" in
|
||||
upgrade | full-upgrade | install | dist-upgrade | build-dep)
|
||||
option="install"
|
||||
;;
|
||||
clean | autoclean)
|
||||
option="clean"
|
||||
;;
|
||||
download)
|
||||
option="download"
|
||||
root=0
|
||||
;;
|
||||
source)
|
||||
option="source"
|
||||
root=0
|
||||
;;
|
||||
changelog)
|
||||
root=0
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# To handle priority of options correctly (environment over config file vars)
|
||||
# we need to preserve all interesting env variables. As this wouldn't be
|
||||
# difficult enough we have to preserve complete env vars (especially if value
|
||||
# ist set (even empty) or not) when changing context (sudo)...
|
||||
# Set a 'random' string to all unset variables.
|
||||
TMP_RANDOM="13979853562951413"
|
||||
TMP_LCK_FILE="${LCK_FILE-${TMP_RANDOM}}"
|
||||
TMP_DOWNLOADBEFORE="${DOWNLOADBEFORE-${TMP_RANDOM}}"
|
||||
TMP__APTMGR="${_APTMGR-${TMP_RANDOM}}"
|
||||
TMP_APTCACHE="${APTCACHE-${TMP_RANDOM}}"
|
||||
TMP_DLDIR="${DLDIR-${TMP_RANDOM}}"
|
||||
TMP_DLLIST="${DLLIST-${TMP_RANDOM}}"
|
||||
TMP_LISTDIR="${LISTDIR-${TMP_RANDOM}}"
|
||||
TMP__MAXNUM="${MAXNUM-${TMP_RANDOM}}"
|
||||
TMP__MAXCONPERSRV="${MAXCONPERSRV-${TMP_RANDOM}}"
|
||||
TMP__SPLITCON="${SPLITCON-${TMP_RANDOM}}"
|
||||
TMP__MINSPLITSZ=${MINSPLITSZ-${TMP_RANDOM}}
|
||||
TMP__PIECEALGO=${PIECEALGO-${TMP_RANDOM}}
|
||||
TMP_aptfast_prefix="${aptfast_prefix-${TMP_RANDOM}}"
|
||||
TMP_APT_FAST_TIMEOUT="${APT_FAST_TIMEOUT-${TMP_RANDOM}}"
|
||||
TMP_VERBOSE_OUTPUT="${VERBOSE_OUTPUT-${TMP_RANDOM}}"
|
||||
TMP_ftp_proxy="${ftp_proxy-${TMP_RANDOM}}"
|
||||
TMP_http_proxy="${http_proxy-${TMP_RANDOM}}"
|
||||
TMP_https_proxy="${https_proxy-${TMP_RANDOM}}"
|
||||
|
||||
# Check for proper privileges.
|
||||
# Call explicitly with environment variables to get them into root conext.
|
||||
if [ "$root" = 1 ] && [ "$UID" != 0 ]; then
|
||||
exec sudo DEBUG="$DEBUG" \
|
||||
LCK_FILE="$TMP_LCK_FILE" \
|
||||
DOWNLOADBEFORE="$TMP_DOWNLOADBEFORE" \
|
||||
_APTMGR="$TMP__APTMGR" \
|
||||
APTCACHE="$TMP_APTCACHE" \
|
||||
DLDIR="$TMP_DLDIR" \
|
||||
DLLIST="$TMP_DLLIST" \
|
||||
LISTDIR="$TMP_LISTDIR" \
|
||||
_MAXNUM="$TMP__MAXNUM" \
|
||||
_MAXCONPERSRV="$TMP__MAXCONPERSRV" \
|
||||
_SPLITCON="$TMP__SPLITCON" \
|
||||
_MINSPLITSZ="$TMP__MINSPLITSZ" \
|
||||
_PIECEALGO="$TMP__PIECEALGO" \
|
||||
aptfast_prefix="$TMP_aptfast_prefix" \
|
||||
APT_FAST_TIMEOUT="$TMP_APT_FAST_TIMEOUT" \
|
||||
VERBOSE_OUTPUT="$TMP_VERBOSE_OUTPUT" \
|
||||
ftp_proxy="$TMP_ftp_proxy" \
|
||||
http_proxy="$TMP_http_proxy" \
|
||||
https_proxy="$TMP_https_proxy" \
|
||||
"$0" "$@"
|
||||
fi
|
||||
|
||||
|
||||
# Define lockfile.
|
||||
# Use /tmp as directory because everybody (not only root) has to have write
|
||||
# permissions.
|
||||
# We need lock for non-root commands too, because we only have one download
|
||||
# list file.
|
||||
if [ "$IS_ACE_ENV" != "" ];then
|
||||
LCK_FILE="/tmp/apt-fast-in-container.lock"
|
||||
else
|
||||
LCK_FILE="/tmp/apt-fast.lock"
|
||||
fi
|
||||
LCK_FD=99
|
||||
|
||||
# Set default package manager, APT cache, temporary download dir,
|
||||
# temporary download list file, and maximal parallel downloads
|
||||
_APTMGR=apt-get
|
||||
eval "$(apt-config shell APTCACHE Dir::Cache::archives/d)"
|
||||
# Check if APT config option Dir::Cache::archives::apt-fast-partial is set.
|
||||
eval "$(apt-config shell apt_fast_partial Dir::Cache::archives::apt-fast-partial/d)"
|
||||
if [ -z "$apt_fast_partial" ]; then
|
||||
eval "$(apt-config -o Dir::Cache::archives::apt-fast-partial=apt-fast shell DLDIR Dir::Cache::archives::apt-fast-partial/d)"
|
||||
else
|
||||
eval "$(apt-config shell DLDIR Dir::Cache::archives::apt-fast-partial/d)"
|
||||
fi
|
||||
# Currently not needed.
|
||||
eval "$(apt-config shell LISTDIR Dir::State::lists/d)"
|
||||
if [ "$IS_ACE_ENV" != "" ];then
|
||||
DLLIST="/tmp/apt-fast-in-container.list"
|
||||
else
|
||||
DLLIST="/tmp/apt-fast.list"
|
||||
fi
|
||||
_MAXNUM=5
|
||||
_MAXCONPERSRV=10
|
||||
_SPLITCON=8
|
||||
_MINSPLITSZ="1M"
|
||||
_PIECEALGO="default"
|
||||
|
||||
# Prefix in front of apt-fast output:
|
||||
aptfast_prefix=
|
||||
# aptfast_prefix="$(date '+%b %_d %T.%N') apt-fast: "
|
||||
|
||||
# Set color variables.
|
||||
cGreen='\e[0;32m'
|
||||
cRed='\e[0;31m'
|
||||
cBlue='\e[0;34m'
|
||||
endColor='\e[0m'
|
||||
|
||||
# Set timout value for apt-fast download confirmation dialog.
|
||||
# Value is in seconds.
|
||||
APT_FAST_TIMEOUT=60
|
||||
|
||||
# Ask for download confirmation if unset
|
||||
DOWNLOADBEFORE=
|
||||
|
||||
# Formatted package list in download confirmation if unset
|
||||
VERBOSE_OUTPUT=
|
||||
|
||||
# Download command.
|
||||
_DOWNLOADER='aria2c --no-conf -c -j ${_MAXNUM} -x ${_MAXCONPERSRV} -s ${_SPLITCON} -i ${DLLIST} --min-split-size=${_MINSPLITSZ} --stream-piece-selector=${_PIECEALGO} --connect-timeout=60 --timeout=600 -m0'
|
||||
|
||||
# Load config file.
|
||||
CONFFILE="/tmp/aptss-conf/apt-fast.conf"
|
||||
#### Spark Store apt-fast conf is in /tmp
|
||||
if [ -e "$CONFFILE" ]; then
|
||||
source "$CONFFILE"
|
||||
fi
|
||||
|
||||
# no proxy as default
|
||||
ftp_proxy=
|
||||
http_proxy=
|
||||
https_proxy=
|
||||
|
||||
# Now overwrite with preserved values if values were set before (compare with
|
||||
# 'random' string).
|
||||
[ "$TMP_LCK_FILE" = "$TMP_RANDOM" ] || LCK_FILE="$TMP_LCK_FILE"
|
||||
[ "$TMP_DOWNLOADBEFORE" = "$TMP_RANDOM" ] || DOWNLOADBEFORE="$TMP_DOWNLOADBEFORE"
|
||||
[ "$TMP__APTMGR" = "$TMP_RANDOM" ] || _APTMGR="$TMP__APTMGR"
|
||||
[ "$TMP_APTCACHE" = "$TMP_RANDOM" ] || APTCACHE="$TMP_APTCACHE"
|
||||
[ "$TMP_DLDIR" = "$TMP_RANDOM" ] || DLDIR="$TMP_DLDIR"
|
||||
[ "$TMP_DLLIST" = "$TMP_RANDOM" ] || DLLIST="$TMP_DLLIST"
|
||||
[ "$TMP_LISTDIR" = "$TMP_RANDOM" ] || LISTDIR="$TMP_LISTDIR"
|
||||
[ "$TMP__MAXNUM" = "$TMP_RANDOM" ] || _MAXNUM="$TMP__MAXNUM"
|
||||
[ "$TMP__MAXCONPERSRV" = "$TMP_RANDOM" ] || _MAXCONPERSRV="$TMP__MAXCONPERSRV"
|
||||
[ "$TMP__SPLITCON" = "$TMP_RANDOM" ] || _SPLITCON="$TMP__SPLITCON"
|
||||
[ "$TMP__MINSPLITSZ" = "$TMP_RANDOM" ] || _MINSPLITSZ="$TMP__MINSPLITSZ"
|
||||
[ "$TMP__PIECEALGO" = "$TMP_RANDOM" ] || _PIECEALGO="$TMP__PIECEALGO"
|
||||
[ "$TMP_aptfast_prefix" = "$TMP_RANDOM" ] || aptfast_prefix="$TMP_aptfast_prefix"
|
||||
[ "$TMP_APT_FAST_TIMEOUT" = "$TMP_RANDOM" ] || APT_FAST_TIMEOUT="$TMP_APT_FAST_TIMEOUT"
|
||||
[ "$TMP_VERBOSE_OUTPUT" = "$TMP_RANDOM" ] || VERBOSE_OUTPUT="$TMP_VERBOSE_OUTPUT"
|
||||
[ "$TMP_ftp_proxy" = "$TMP_RANDOM" ] || ftp_proxy="$TMP_ftp_proxy"
|
||||
[ "$TMP_http_proxy" = "$TMP_RANDOM" ] || http_proxy="$TMP_http_proxy"
|
||||
[ "$TMP_https_proxy" = "$TMP_RANDOM" ] || https_proxy="$TMP_https_proxy"
|
||||
|
||||
|
||||
# Disable colors if not executed in terminal.
|
||||
if [ ! -t 1 ]; then
|
||||
cGreen=
|
||||
cRed=
|
||||
cBlue=
|
||||
endColor=
|
||||
#FIXME: Time not updated.
|
||||
[ -z "$aptfast_prefix" ] && aptfast_prefix="[apt-fast $(date +"%T")]"
|
||||
fi
|
||||
|
||||
|
||||
msg_already_running()
|
||||
{
|
||||
msg "Other aptss is running. Waited $timer senconds..." "normal"
|
||||
msg "有其他的aptss正在运行。已经等待了$timer秒" "normal"
|
||||
}
|
||||
|
||||
# Check if a lock file exists.
|
||||
#if [ -f "$LCK_FILE.lock" ]; then
|
||||
# msg_already_running
|
||||
# exit 1
|
||||
#fi
|
||||
|
||||
|
||||
# create the lock file and lock it, die on failure
|
||||
_create_lock()
|
||||
{
|
||||
eval "exec $LCK_FD>\"$LCK_FILE.lock\""
|
||||
|
||||
# trap "cleanup_aptfast; exit_cleanup_state" EXIT
|
||||
# This will hide the exit code
|
||||
trap "cleanup_aptfast" EXIT
|
||||
trap "cleanup_aptfast; exit 1" INT TERM
|
||||
timer=0
|
||||
until $(flock -xn $LCK_FD);do
|
||||
msg_already_running
|
||||
sleep 1
|
||||
let timer+=1
|
||||
done
|
||||
unset timer
|
||||
}
|
||||
|
||||
# unlock and remove the lock file
|
||||
_remove_lock()
|
||||
{
|
||||
flock -u "$LCK_FD" 2>/dev/null
|
||||
rm -f "$LCK_FILE.lock"
|
||||
}
|
||||
|
||||
# Move download file away so missing permissions won't stop usage.
|
||||
CLEANUP_STATE=0
|
||||
cleanup_dllist()
|
||||
{
|
||||
if [ -f "$DLLIST" ]
|
||||
then
|
||||
if ! mv -- "$DLLIST{,.old}" 2>/dev/null
|
||||
then
|
||||
if ! rm -f -- "$DLLIST" 2>/dev/null
|
||||
then
|
||||
msg "Could not clean up download list file." "warning"
|
||||
msg "无法清除下载列表文件." "warning"
|
||||
CLEANUP_STATE=1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
cleanup_aptfast()
|
||||
{
|
||||
[ "$CLEANUP_STATE" -eq 0 ] && CLEANUP_STATE=$?
|
||||
cleanup_dllist
|
||||
_remove_lock
|
||||
}
|
||||
|
||||
exit_cleanup_state()
|
||||
{
|
||||
exit $CLEANUP_STATE
|
||||
}
|
||||
|
||||
# decode url string
|
||||
# translates %xx but must not convert '+' in spaces
|
||||
urldecode()
|
||||
{
|
||||
printf '%b' "${1//%/\\x}"
|
||||
}
|
||||
|
||||
# Check if mirrors are available. And if so add all mirrors to download list.
|
||||
get_mirrors(){
|
||||
# Check all mirror lists.
|
||||
for mirrorstr in "${MIRRORS[@]}"; do
|
||||
# Build mirrors array from comma separated string.
|
||||
IFS=", " read -r -a mirrors <<< "$mirrorstr"
|
||||
# Check for all mirrors if URI of $1 is from mirror. If so add all other
|
||||
# mirrors to (resmirror) list and break all loops.
|
||||
for mirror in "${mirrors[@]}"; do
|
||||
# Real expension.
|
||||
if [[ "$1" == "$mirror"* ]]; then
|
||||
filepath=${1#${mirror}}
|
||||
# Build list for aria download list.
|
||||
list="${mirrors[*]}"
|
||||
echo -e "${list// /${filepath}\\t}$filepath\n"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
done
|
||||
# No other mirrors found.
|
||||
echo "$1"
|
||||
}
|
||||
|
||||
# Globals to save package name, version, size and overall size.
|
||||
DOWNLOAD_DISPLAY=
|
||||
DOWNLOAD_SIZE=0
|
||||
|
||||
# Get the package URLs.
|
||||
get_uris(){
|
||||
|
||||
if [ ! -d "$(dirname "$DLLIST")" ]
|
||||
then
|
||||
if ! mkdir -p -- "$(dirname "$DLLIST")"
|
||||
then
|
||||
msg "Could not create download file directory." "warning"
|
||||
msg "无法创建下载文件夹" "warning"
|
||||
exit 1
|
||||
fi
|
||||
elif [ -f "$DLLIST" ]; then
|
||||
if ! rm -f -- "$DLLIST" 2>/dev/null && ! touch -- "$DLLIST" 2>/dev/null
|
||||
then
|
||||
msg "Unable to write to download file. Try restarting with root permissions or run 'aptss clean' first." "warning"
|
||||
msg "无法下载文件。尝试使用root权限,或者运行 'aptss clean'" "warning"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Add header to overwrite file.
|
||||
echo "# apt-fast mirror list: $(date)" > "$DLLIST"
|
||||
#NOTE: aptitude doesn't have this functionality, so we use apt-get to get
|
||||
# package URIs.
|
||||
# case "$_APTMGR" in
|
||||
# apt|apt-get) uri_mgr=$_APTMGR;;
|
||||
# *) uri_mgr=apt-get;;
|
||||
# esac
|
||||
# NOTE:apt可能出现变动,不建议在脚本中使用,因此在此统一改用apt-get
|
||||
uri_mgr=apt-get
|
||||
uris_full="$("$uri_mgr" "${APT_SCRIPT_WARNING[@]}" -y --print-uris "$@")"
|
||||
uris_full_ret="$?"
|
||||
if [ "$uris_full_ret" -ne 0 ]
|
||||
then
|
||||
msg "Package manager quit with exit code.Here is the log" "warning"
|
||||
msg "包管理器以错误代码退出.日志如下" "warning"
|
||||
msg "${uris_full}"
|
||||
exit "$uris_full_ret"
|
||||
fi
|
||||
while read -r pkg_uri_info
|
||||
do
|
||||
[ -z "$pkg_uri_info" ] && continue
|
||||
## --print-uris format is:
|
||||
# 'fileurl' filename filesize checksum_hint:filechecksum
|
||||
uri="$(echo "$pkg_uri_info" | cut -d' ' -f1 | tr -d "'")"
|
||||
filename="$(echo "$pkg_uri_info" | cut -d' ' -f2)"
|
||||
filesize="$(echo "$pkg_uri_info" | cut -d' ' -f3)"
|
||||
checksum_string="$(echo "$pkg_uri_info" | cut -d' ' -f4)"
|
||||
hash_algo="$(echo "$checksum_string" | cut -d':' -f1)"
|
||||
checksum="$(echo "$checksum_string" | cut -d':' -f2)"
|
||||
|
||||
filename_decoded="$(urldecode "$filename")"
|
||||
DOWNLOAD_DISPLAY="${DOWNLOAD_DISPLAY}$(echo "$filename_decoded" | cut -d'_' -f1)"
|
||||
DOWNLOAD_DISPLAY="${DOWNLOAD_DISPLAY} $(echo "$filename_decoded" | cut -d'_' -f2)"
|
||||
DOWNLOAD_DISPLAY="${DOWNLOAD_DISPLAY} $(echo "$filesize" | numfmt --to=iec-i --suffix=B)\n"
|
||||
DOWNLOAD_SIZE=$((DOWNLOAD_SIZE + filesize))
|
||||
|
||||
## whole uri comes encoded (urlencoded). Filename must NOT be decoded because
|
||||
# plain aptitude do not decode it when download and install it. Therefore, we
|
||||
# will have ugly named packages at /var/cache/apt/archives but is the standard
|
||||
# behavior.
|
||||
# But package version must be decoded, otherways package=version calls will
|
||||
# not work.
|
||||
|
||||
if [ -n "$HASH_SUPPORTED" ]; then
|
||||
case "$hash_algo" in
|
||||
SHA512) [ -z "$SHA512_SUPPORTED" ] && hash_algo= || hash_algo=sha-512 ;;
|
||||
SHA256) [ -z "$SHA256_SUPPORTED" ] && hash_algo= || hash_algo=sha-256 ;;
|
||||
SHA1) [ -z "$SHA1_SUPPORTED" ] && hash_algo= || hash_algo=sha-1 ;;
|
||||
MD5Sum) [ -z "$MD5sum_SUPPORTED" ] && hash_algo= || hash_algo=md5 ;;
|
||||
*) hash_algo=
|
||||
esac
|
||||
|
||||
# Using apt-cache show package=version to ensure recover single and
|
||||
# correct package version.
|
||||
# Warning: assuming that package naming uses '_' as field separator.
|
||||
# Therefore, this code expects package-name_version_arch.deb Otherways
|
||||
# below code will fail resoundingly
|
||||
if [ -z "$hash_algo" ]; then
|
||||
pkg_name="$(echo "$filename" | cut -d'_' -f1)"
|
||||
pkg_version="$(echo "$filename" | cut -d'_' -f2)"
|
||||
pkg_version="$(urldecode "$pkg_version")"
|
||||
package_info="$(apt-cache show "$pkg_name=$pkg_version")"
|
||||
|
||||
patch_checksum=
|
||||
if [ -n "$SHA512_SUPPORTED" ]; then
|
||||
patch_checksum="$(echo "$package_info" | grep SHA512 | head -n 1)"
|
||||
[ -n "$patch_checksum" ] && hash_algo="sha-512"
|
||||
fi
|
||||
if [ -z "$patch_checksum" ] && [ -n "$SHA256_SUPPORTED" ]; then
|
||||
patch_checksum="$(echo "$package_info" | grep SHA256 | head -n 1)"
|
||||
[ -n "$patch_checksum" ] && hash_algo="sha-256"
|
||||
fi
|
||||
if [ -z "$patch_checksum" ] && [ -n "$SHA1_SUPPORTED" ]; then
|
||||
patch_checksum="$(echo "$package_info" | grep SHA1 | head -n 1)"
|
||||
[ -n "$patch_checksum" ] && hash_algo="sha-1"
|
||||
fi
|
||||
if [ -z "$patch_checksum" ] && [ -n "$MD5sum_SUPPORTED" ]; then
|
||||
patch_checksum="$(echo "$package_info" | grep MD5sum | head -n 1)"
|
||||
[ -n "$patch_checksum" ] && hash_algo="md5"
|
||||
fi
|
||||
|
||||
if [ -n "$patch_checksum" ]; then
|
||||
checksum="$(echo "$patch_checksum" | cut -d' ' -f2)"
|
||||
else
|
||||
msg "Couldn't get supported checksum for $pkg_name ($pkg_version)." "warning"
|
||||
msg "无法获得 $pkg_name ($pkg_version) 的受支持的散列验证值" "warning"
|
||||
REMOVE_WORKING_MESSAGE=
|
||||
fi
|
||||
fi
|
||||
else
|
||||
hash_algo=
|
||||
fi
|
||||
|
||||
{
|
||||
get_mirrors "$uri"
|
||||
#echo " dir=$DLDIR"
|
||||
if [ -n "$hash_algo" ]; then
|
||||
echo " checksum=$hash_algo=$checksum"
|
||||
fi
|
||||
echo " out=$filename"
|
||||
} >> "$DLLIST"
|
||||
done <<<"$(echo "$uris_full" | grep -E "^'(http(s|)|(s|)ftp)://")"
|
||||
|
||||
#cat "$DLLIST"
|
||||
#LCK_RM
|
||||
#exit
|
||||
}
|
||||
|
||||
display_downloadfile(){
|
||||
if [ -n "$VERBOSE_OUTPUT" ]; then
|
||||
cat "$DLLIST"
|
||||
else
|
||||
DISPLAY_SORT_OPTIONS=(-k 1,1)
|
||||
# Sort output after package download size (decreasing):
|
||||
#DISPLAY_SORT_OPTIONS=(-k 3,3 -hr)
|
||||
while read -r line; do
|
||||
[ -z "$line" ] && continue
|
||||
pkg="$(echo "$line" | cut -d' ' -f1)"
|
||||
ver="$(echo "$line" | cut -d' ' -f2)"
|
||||
size="$(echo "$line" | cut -d' ' -f3)"
|
||||
printf '%s%-40s %-20s %10s\n' "$aptfast_prefix" "$pkg" "$ver" "$size"
|
||||
done <<<"$(echo -e "$DOWNLOAD_DISPLAY" | sort "${DISPLAY_SORT_OPTIONS[@]}")"
|
||||
fi
|
||||
msg "Download size: $(echo "$DOWNLOAD_SIZE" | numfmt --to=iec-i --suffix=B)" "normal"
|
||||
msg "下载大小: $(echo "$DOWNLOAD_SIZE" | numfmt --to=iec-i --suffix=B)" "normal"
|
||||
}
|
||||
|
||||
# Create and insert a PID number to lockfile.
|
||||
|
||||
_create_lock
|
||||
|
||||
# Make sure aria2c (in general first parameter from _DOWNLOADER) is available.
|
||||
CMD="$(echo "$_DOWNLOADER" | sed 's/^\s*\([^ ]\+\).*$/\1/')"
|
||||
if [ ! "$(command -v "$CMD")" ]; then
|
||||
msg "Command not found: $CMD" "normal" "err"
|
||||
msg "You must configure $CONFFILE to use aria2c or another supported download manager" "normal" "err"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Make sure package manager is available.
|
||||
if [ ! "$(command -v "$_APTMGR")" ]; then
|
||||
msg "\`$_APTMGR\` command not available." "warning"
|
||||
msg "You must configure $CONFFILE to use either apt-get or aptitude." "normal" "err"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Disable script warning if apt is used.
|
||||
APT_SCRIPT_WARNING=()
|
||||
if [ "$_APTMGR" == "apt" ]; then
|
||||
APT_SCRIPT_WARNING=(-o "Apt::Cmd::Disable-Script-Warning=true")
|
||||
fi
|
||||
|
||||
# Set supported hash algorithms by aria2c (and also by Debian repository).
|
||||
SHA512_SUPPORTED=
|
||||
SHA256_SUPPORTED=
|
||||
SHA1_SUPPORTED=
|
||||
MD5sum_SUPPORTED=
|
||||
HASH_SUPPORTED=
|
||||
if [ "$CMD" == "aria2c" ]; then
|
||||
for supported_hash in $(LC_ALL=C aria2c -v | sed '/^Hash Algorithms:/!d; s/\(^Hash Algorithms: \|,\)\+//g'); do
|
||||
case "$supported_hash" in
|
||||
sha-512) SHA512_SUPPORTED=y; HASH_SUPPORTED=y ;;
|
||||
sha-256) SHA256_SUPPORTED=y; HASH_SUPPORTED=y ;;
|
||||
sha-1) SHA1_SUPPORTED=y; HASH_SUPPORTED=y ;;
|
||||
md5) MD5sum_SUPPORTED=y; HASH_SUPPORTED=y ;;
|
||||
esac
|
||||
done
|
||||
if [ -z "$HASH_SUPPORTED" ]; then
|
||||
msg "Couldn't find supported checksum algorithm from aria2c. Checksums disabled." "warning"
|
||||
msg "无法找到aria2c支持的散列验证算法. 散列验证已被禁用." "warning"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check if "assume yes" switch is enabled and if yes enable $DOWNLOADBEFORE.
|
||||
# Also check if "download only" switch is enabled.
|
||||
#TODO: Get real value over APT items APT::Get::Assume-Yes and
|
||||
# APT::Get::Assume-No .
|
||||
# Respectively Aptitude::CmdLine::Download-Only and APT::Get::Download-Only.
|
||||
DOWNLOAD_ONLY=
|
||||
while true; do
|
||||
while getopts ":dy-:" optchar; do
|
||||
case "${optchar}" in
|
||||
-)
|
||||
case "${OPTARG}" in
|
||||
yes | assume-yes) DOWNLOADBEFORE=true ;;
|
||||
assume-no) DOWNLOADBEFORE= ;;
|
||||
download-only) DOWNLOAD_ONLY=true ;;
|
||||
esac
|
||||
;;
|
||||
y)
|
||||
DOWNLOADBEFORE=true
|
||||
;;
|
||||
d)
|
||||
DOWNLOAD_ONLY=true
|
||||
;;
|
||||
esac
|
||||
done
|
||||
((OPTIND++))
|
||||
[ $OPTIND -gt $# ] && break
|
||||
done
|
||||
|
||||
# Configure proxies. Use apt values over environment variables.
|
||||
# Note: If proxy setting is not set, there is no apt-config output.
|
||||
# Therefore variable doesn't get overriden, which is intended.
|
||||
# Export the variables to make them available in subshells (aka the
|
||||
# downloader command).
|
||||
eval "$(apt-config shell ftp_proxy Acquire::ftp::proxy)"
|
||||
export ftp_proxy
|
||||
eval "$(apt-config shell http_proxy Acquire::http::proxy)"
|
||||
export http_proxy
|
||||
eval "$(apt-config shell https_proxy Acquire::https::proxy)"
|
||||
export https_proxy
|
||||
|
||||
# aria2 has no socks support (see https://github.com/aria2/aria2/issues/153)
|
||||
if echo "$http_proxy" | grep -q "^socks5h://" || echo "$https_proxy" | grep -q "^socks5h://"; then
|
||||
msg "Socks proxy detected. Falling back to ${_APTMGR}" "hint"
|
||||
"${_APTMGR}" "${APT_SCRIPT_WARNING[@]}" "$@"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Run actions.
|
||||
if [ "$option" == "install" ]; then
|
||||
msg
|
||||
msg "Working... this may take a while." "normal"
|
||||
msg "正在工作中,请稍等" "normal"
|
||||
REMOVE_WORKING_MESSAGE=y
|
||||
|
||||
get_uris "$@"
|
||||
[ -t 1 ] && [ -n "$REMOVE_WORKING_MESSAGE" ] && tput cuu 1 && tput el && tput cuu 1
|
||||
# Test /tmp/apt-fast.list file exists and not just the apt-fast comment line.
|
||||
# Then download all files from the list.
|
||||
if [ -f "$DLLIST" ] && [ "$(wc -l "$DLLIST" | cut -d' ' -f1)" -gt 1 ] && [ ! "$DOWNLOADBEFORE" ]; then
|
||||
display_downloadfile
|
||||
msg
|
||||
msg "Do you want to download the packages? [Y/n] " "question"
|
||||
|
||||
while ((!updsys)); do
|
||||
read -r -sn1 -t "$APT_FAST_TIMEOUT" answer || { msg; msg "Timed out." "warning"; exit 1; }
|
||||
case "$answer" in
|
||||
[JjYy]) result=1; updsys=1 ;;
|
||||
[Nn]) result=0; updsys=1 ;;
|
||||
"") result=1; updsys=1 ;;
|
||||
*) updsys=0 ;;
|
||||
esac
|
||||
done
|
||||
else
|
||||
result=1
|
||||
fi
|
||||
|
||||
if ((DOWNLOAD_SIZE)); then
|
||||
msg
|
||||
# Continue if answer was right or DOWNLOADBEFORE is enabled.
|
||||
if ((result)); then
|
||||
if [ -s "$DLLIST" ]; then
|
||||
# Test if apt-fast directory is present where we put packages.
|
||||
if [ ! -d "$DLDIR" ]; then
|
||||
mkdir -p -- "$DLDIR"
|
||||
fi
|
||||
|
||||
cd "$DLDIR" &>/dev/null || exit 1
|
||||
|
||||
eval "${_DOWNLOADER}" # execute downloadhelper command
|
||||
if [ "$(find "$DLDIR" -printf . | wc -c)" -gt 1 ]; then
|
||||
# Move all packages to the apt install directory by force to ensure
|
||||
# already existing debs which may be incomplete are replaced
|
||||
find . -type f -name "*.deb" -execdir mv -ft "$APTCACHE" {} \+
|
||||
fi
|
||||
cd - &>/dev/null || msg "Failed to change back directory" "warning"
|
||||
fi
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
[ -t 1 ] && tput el
|
||||
fi
|
||||
|
||||
if [ -z "$DOWNLOAD_ONLY" ] || [ "$_APTMGR" == "aptitude" ]; then
|
||||
"${_APTMGR}" "${APT_SCRIPT_WARNING[@]}" "$@"
|
||||
fi
|
||||
|
||||
|
||||
elif [ "$option" == "clean" ]; then
|
||||
"${_APTMGR}" "${APT_SCRIPT_WARNING[@]}" "$@" && {
|
||||
find "$DLDIR" -maxdepth 1 -type f -delete
|
||||
CLEANUP_STATE="$?"
|
||||
[ -f "$DLLIST" ] && rm -f -- "$DLLIST"* || true
|
||||
}
|
||||
|
||||
elif [ "$option" == "download" ]; then
|
||||
msg
|
||||
msg "Working... this may take a while." "normal"
|
||||
msg "正在工作中,请稍等" "normal"
|
||||
REMOVE_WORKING_MESSAGE=y
|
||||
|
||||
get_uris "$@"
|
||||
|
||||
[ -t 1 ] && [ -n "$REMOVE_WORKING_MESSAGE" ] && tput cuu 1 && tput el && tput cuu 1
|
||||
|
||||
if [ -f "$DLLIST" ] && [ "$(wc -l "$DLLIST" | cut -d' ' -f1)" -gt 1 ]; then
|
||||
display_downloadfile
|
||||
eval "${_DOWNLOADER}"
|
||||
fi
|
||||
|
||||
if [ "$_APTMGR" == "aptitude" ]; then
|
||||
"${_APTMGR}" "$@"
|
||||
fi
|
||||
|
||||
elif [ "$option" == "source" ]; then
|
||||
msg
|
||||
msg "Working... this may take a while." "normal"
|
||||
msg "正在工作中,请稍等" "normal"
|
||||
REMOVE_WORKING_MESSAGE=y
|
||||
|
||||
get_uris "$@"
|
||||
|
||||
[ -t 1 ] && [ -n "$REMOVE_WORKING_MESSAGE" ] && tput cuu 1 && tput el && tput cuu 1
|
||||
|
||||
if [ -f "$DLLIST" ] && [ "$(wc -l "$DLLIST" | cut -d' ' -f1)" -gt 1 ]; then
|
||||
display_downloadfile
|
||||
eval "${_DOWNLOADER}"
|
||||
fi
|
||||
# We use APT manager here to provide more verbose output. This method is
|
||||
# slightly slower then extractiong packages manually after download but also
|
||||
# more hardened (e.g. some options like --compile are available).
|
||||
"${_APTMGR}" "${APT_SCRIPT_WARNING[@]}" "$@"
|
||||
# Uncomment following snippet to extract source directly and comment
|
||||
# both lines before.
|
||||
#while read srcfile; do
|
||||
# # extract only .dsc files
|
||||
# echo "$srcfile" | grep -q '\.dsc$' || continue
|
||||
# dpkg-source -x "$(basename "$srcfile")"
|
||||
#done < "$DLLIST"
|
||||
|
||||
# Execute package manager directly if unknown options are passed.
|
||||
else
|
||||
"${_APTMGR}" "${APT_SCRIPT_WARNING[@]}" "$@"
|
||||
fi
|
||||
|
||||
# After error or all done remove our lockfile (done with EXIT trap)
|
132
tool/aptss
132
tool/aptss
@ -1,132 +1,2 @@
|
||||
#!/bin/bash
|
||||
|
||||
SPARK_DOWNLOAD_SERVER_URL="http://127.0.0.1:8000"
|
||||
SPARK_DOWNLOAD_SERVER_URL_NO_PROTOCOL="127.0.0.1:8000"
|
||||
source /opt/durapps/spark-store/bin/bashimport/transhell.amber
|
||||
load_transhell
|
||||
|
||||
case `arch` in
|
||||
x86_64)
|
||||
STORE_URL="store"
|
||||
STORE_LIST_URL=""
|
||||
;;
|
||||
aarch64)
|
||||
STORE_URL="aarch64-store"
|
||||
STORE_LIST_URL="-aarch64"
|
||||
;;
|
||||
loongarch64)
|
||||
STORE_URL="loong64-store"
|
||||
STORE_LIST_URL="-loong64"
|
||||
;;
|
||||
esac
|
||||
SS_APT_FAST="/opt/durapps/spark-store/bin/apt-fast/ss-apt-fast"
|
||||
|
||||
|
||||
is_empty_dir(){
|
||||
return `ls -A $1|wc -w`
|
||||
}
|
||||
|
||||
|
||||
|
||||
if [ "$(id -u)" != "0" ];then
|
||||
#############################无root权限时
|
||||
echo -e "\e[1;32m${TRANSHELL_CONTENT_RUNNING_IN_NOT_ROOT_USER}\e[0m"
|
||||
|
||||
else
|
||||
|
||||
|
||||
ln -sf /etc/apt/sources.list.d/* /opt/durapps/spark-store/bin/apt-fast-conf/sources.list.d
|
||||
###让这里和系统同步,先链接,然后清除无效链接
|
||||
find /opt/durapps/spark-store/bin/apt-fast-conf/sources.list.d -xtype l -delete
|
||||
|
||||
fi
|
||||
|
||||
if [ ! -e "/tmp/aptss-conf/apt-fast.conf" ];then
|
||||
###刷新apt-fast配置
|
||||
mkdir -p /tmp/aptss-conf/
|
||||
echo -e "\e[1;32m${TRANSHELL_CONTENT_GETTING_SERVER_CONFIG_AND_MIRROR_LIST}\e[0m"
|
||||
echo
|
||||
curl --progress-bar -o /tmp/aptss-conf/apt-fast.conf "${SPARK_DOWNLOAD_SERVER_URL}/apt-fast.conf"
|
||||
chmod -R 755 /tmp/aptss-conf
|
||||
|
||||
fi
|
||||
|
||||
|
||||
if [ ! -e "/var/lib/aptss/lists/${SPARK_DOWNLOAD_SERVER_URL_NO_PROTOCOL}_${STORE_URL}_Packages" ] && [ ! -e "/var/lib/aptss/lists/d.store.deepinos.org.cn_${STORE_URL}_Packages" ] && [ ! -e "/var/lib/aptss/lists/mirrors.sdu.edu.cn_spark-store-repository_${STORE_URL}_Packages" ];then
|
||||
|
||||
mkdir -p /tmp/aptss-conf/
|
||||
echo -e "\e[1;32m${TRANSHELL_CONTENT_GETTING_SERVER_CONFIG_AND_MIRROR_LIST}\e[0m"
|
||||
echo
|
||||
curl --silent -o /tmp/aptss-conf/apt-fast.conf "${SPARK_DOWNLOAD_SERVER_URL}/apt-fast.conf"
|
||||
chmod -R 755 /tmp/aptss-conf
|
||||
|
||||
curl --silent -o /opt/durapps/spark-store/bin/apt-fast-conf/sources.list.d/sparkstore.list "${SPARK_DOWNLOAD_SERVER_URL}/sparkstore${STORE_LIST_URL}.list"
|
||||
/usr/bin/apt update -c /opt/durapps/spark-store/bin/apt-fast-conf/aptss-apt.conf
|
||||
|
||||
#只更新星火源
|
||||
|
||||
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if [ "$1" = "install" ] || [ "$1" = "upgrade" ] || [ "$1" = "full-upgrade" ] ; then
|
||||
|
||||
|
||||
|
||||
###执行
|
||||
|
||||
${SS_APT_FAST} "$@" --allow-downgrades -c /opt/durapps/spark-store/bin/apt-fast-conf/aptss-apt.conf
|
||||
ret="$?"
|
||||
if [ "$ret" -ne 0 ];then
|
||||
echo -e "\e[1;33m$TRANSHELL_CONTENT_PLEASE_USE_APTSS_INSTEAD_OF_APT\e[0m"
|
||||
exit $ret
|
||||
fi
|
||||
|
||||
|
||||
elif [ "$1" = "download" ];then
|
||||
|
||||
###执行
|
||||
|
||||
${SS_APT_FAST} "$@" --allow-downgrades -c /opt/durapps/spark-store/bin/apt-fast-conf/aptss-apt.conf
|
||||
|
||||
|
||||
elif [ "$1" = "policy" ] || [ "$1" = "search" ];then
|
||||
|
||||
|
||||
|
||||
###执行
|
||||
/usr/bin/apt "$@" -c /opt/durapps/spark-store/bin/apt-fast-conf/aptss-apt.conf
|
||||
|
||||
elif [ "$1" = "ssupdate" ];then
|
||||
|
||||
mkdir -p /tmp/aptss-conf/
|
||||
echo -e "\e[1;32m${TRANSHELL_CONTENT_GETTING_SERVER_CONFIG_AND_MIRROR_LIST}\e[0m"
|
||||
echo
|
||||
curl --silent -o /tmp/aptss-conf/apt-fast.conf "${SPARK_DOWNLOAD_SERVER_URL}/apt-fast.conf"
|
||||
chmod -R 755 /tmp/aptss-conf
|
||||
|
||||
curl --silent -o /opt/durapps/spark-store/bin/apt-fast-conf/sources.list.d/sparkstore.list "${SPARK_DOWNLOAD_SERVER_URL}/sparkstore${STORE_LIST_URL}.list"
|
||||
|
||||
|
||||
/usr/bin/apt update -c /opt/durapps/spark-store/bin/apt-fast-conf/aptss-apt.conf -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0" -o Dir::Etc::sourcelist="/opt/durapps/spark-store/bin/apt-fast-conf/sources.list.d/sparkstore.list"
|
||||
|
||||
#只更新星火源
|
||||
|
||||
elif [ "$1" = "update" ];then
|
||||
echo -e "\e[1;32m${TRANSHELL_CONTENT_GETTING_SERVER_CONFIG_AND_MIRROR_LIST}\e[0m"
|
||||
echo
|
||||
curl --progress-bar -o /opt/durapps/spark-store/bin/apt-fast-conf/sources.list.d/sparkstore.list "${SPARK_DOWNLOAD_SERVER_URL}/sparkstore${STORE_LIST_URL}.list"
|
||||
mkdir -p /tmp/aptss-conf/
|
||||
curl --progress-bar -o /tmp/aptss-conf/apt-fast.conf "${SPARK_DOWNLOAD_SERVER_URL}/apt-fast.conf"
|
||||
chmod -R 755 /tmp/aptss-conf
|
||||
### 额外一份拿来给aptss自动补全用
|
||||
/usr/bin/apt "$@" -c /opt/durapps/spark-store/bin/apt-fast-conf/aptss-apt.conf
|
||||
|
||||
else
|
||||
/usr/bin/apt "$@" -c /opt/durapps/spark-store/bin/apt-fast-conf/aptss-apt.conf
|
||||
fi
|
||||
|
||||
|
||||
host-spawn $0 $@
|
||||
|
@ -1,18 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE policyconfig PUBLIC "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
|
||||
"http://www.freedesktop.org/standards/PolicyKit/1/policyconfig.dtd">
|
||||
<policyconfig>
|
||||
<vendor>Spark Store</vendor>
|
||||
<icon_name>x-package-repository</icon_name>
|
||||
<action id="store.spark-app.ssinstall">
|
||||
<description>运行ssinstall需要权限</description>
|
||||
<message>要使用ssinstall需要权限</message>
|
||||
<defaults>
|
||||
<allow_any>yes</allow_any>
|
||||
<allow_inactive>yes</allow_inactive>
|
||||
<allow_active>yes</allow_active>
|
||||
</defaults>
|
||||
<annotate key="org.freedesktop.policykit.exec.path">/usr/local/bin/ssinstall</annotate>
|
||||
<annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
|
||||
</action>
|
||||
</policyconfig>
|
@ -1,28 +0,0 @@
|
||||
#!/bin/bash
|
||||
source /opt/durapps/spark-store/bin/bashimport/transhell.amber
|
||||
load_transhell
|
||||
# 检查是否传入了路径参数
|
||||
if [ -z "$1" ]; then
|
||||
echo "${TRANSHELL_CONTENT_PLEASE_PROVIDE_FILE_PATH}"
|
||||
exit 1
|
||||
fi
|
||||
DESKTOP_FILE_PATH=$1
|
||||
if [[ $DESKTOP_FILE_PATH == file://* ]]; then
|
||||
# 如果是,移除 'file://' 部分并输出结果
|
||||
DESKTOP_FILE_PATH="${DESKTOP_FILE_PATH#file://}"
|
||||
fi
|
||||
|
||||
# 获取文件内容中Exec=后的命令
|
||||
exec_command=$(grep -oP "(?<=Exec=).*" "$DESKTOP_FILE_PATH")
|
||||
|
||||
# 打印提取的命令
|
||||
echo "$exec_command"
|
||||
|
||||
# 在默认终端执行命令
|
||||
eval "$exec_command"
|
||||
|
||||
echo --------------------------------------
|
||||
echo "${TRANSHELL_CONTENT_ABOVE_IS_TERMINAL_OUTPUT}"
|
||||
echo "${TRANSHELL_CONTENT_PRESS_ENTER_TO_FINISH}"
|
||||
read
|
||||
|
@ -1,5 +0,0 @@
|
||||
#!/bin/bash
|
||||
TRANSHELL_CONTENT_PLEASE_PROVIDE_FILE_PATH="Please provide a file path as an argument"
|
||||
TRANSHELL_CONTENT_ABOVE_IS_TERMINAL_OUTPUT="The above is the output executed in the terminal. Please copy and paste it when providing feedback."
|
||||
TRANSHELL_CONTENT_PRESS_ENTER_TO_FINISH="Press Enter to finish"
|
||||
|
@ -1,5 +0,0 @@
|
||||
#!/bin/bash
|
||||
TRANSHELL_CONTENT_PLEASE_PROVIDE_FILE_PATH="请传入文件路径作为参数"
|
||||
TRANSHELL_CONTENT_ABOVE_IS_TERMINAL_OUTPUT="以上是在终端中执行的输出,请在反馈问题的时候完整复制并贴上"
|
||||
TRANSHELL_CONTENT_PRESS_ENTER_TO_FINISH="按回车结束"
|
||||
|
@ -1,53 +1,2 @@
|
||||
#!/bin/bash
|
||||
SPARK_CORE_SERVER_URL="http://127.0.0.1:38324"
|
||||
|
||||
#用法:sender.sh 下载链接 HD70642
|
||||
|
||||
case `arch` in
|
||||
x86_64)
|
||||
STORE_URL="store"
|
||||
;;
|
||||
aarch64)
|
||||
STORE_URL="aarch64-store"
|
||||
;;
|
||||
loongarch64)
|
||||
STORE_URL="loong64-store"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -z $1 ] || [ "$2" != "HD70642" ];then
|
||||
echo "Segment fault"
|
||||
# 假的段错误
|
||||
exit -1
|
||||
fi
|
||||
|
||||
|
||||
APP_LOCATION=${1#*/$STORE_URL/}
|
||||
APP_LOCATION=${APP_LOCATION%/*}
|
||||
echo $APP_LOCATION
|
||||
|
||||
APP_METALINK_FILE_NAME=${1##*/}
|
||||
#echo $APP_METALINK_FILE_NAME
|
||||
|
||||
|
||||
PIDS=$(pidof "spark-store")
|
||||
# 检查 metalink以防止未下载时刷分
|
||||
|
||||
if [ ! -f /tmp/spark-store/$APP_METALINK_FILE_NAME ] || [ "$PIDS" = "" ];then
|
||||
sleep 1
|
||||
echo "发送!成功"
|
||||
exit
|
||||
# 其实是发送不成功的意思lolol
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
echo $STORE_URL/$APP_LOCATION
|
||||
curl -X POST -H "Content-Type: application/json" -d '{"path": "'"${STORE_URL}/${APP_LOCATION}"'"}' ${SPARK_CORE_SERVER_URL}/handle_post
|
||||
|
||||
|
||||
|
||||
|
||||
echo "Finished"
|
||||
host-spawn $0 $@
|
||||
|
148
tool/ssaudit
148
tool/ssaudit
@ -1,148 +1,2 @@
|
||||
#!/bin/bash
|
||||
|
||||
source /opt/durapps/spark-store/bin/bashimport/transhell.amber
|
||||
load_transhell_debug
|
||||
|
||||
case $(arch) in
|
||||
x86_64)
|
||||
STORE_URL="store"
|
||||
;;
|
||||
aarch64)
|
||||
STORE_URL="aarch64-store"
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "Spark Store Install script. 星火商店审核脚本"
|
||||
|
||||
function pkexec_as_current_user() {
|
||||
local user=$(who | awk '{print $1}' | head -n 1)
|
||||
local uid=$(id -u "$user")
|
||||
sudo -u "$user" DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/"$uid"/bus pkexec "$@"
|
||||
}
|
||||
function create_desktop_file() {
|
||||
local user=$(who | awk '{print $1}' | head -n 1)
|
||||
if [ -e $(sudo -u "$user" xdg-user-dir)/.config/spark-union/spark-store/ssshell-config-do-not-create-desktop ];then
|
||||
echo "It is configured that do not create desktop file. Give up"
|
||||
else
|
||||
exec_create_desktop_file
|
||||
fi
|
||||
}
|
||||
function exec_create_desktop_file() {
|
||||
local user=$(who | awk '{print $1}' | head -n 1)
|
||||
for desktop_file_path in $(dpkg -L "$package_name" |grep /usr/share/applications/ | awk '/\.desktop$/ {print}'); do
|
||||
if [ "$(cat $desktop_file_path | grep NoDisplay=true)" = "" ];then
|
||||
echo $desktop_file_path is checked and will be installed to desktop
|
||||
sudo -u "$user" cp "$desktop_file_path" "$(sudo -u "$user" xdg-user-dir DESKTOP)/"
|
||||
fi
|
||||
done
|
||||
for desktop_file_path in $(dpkg -L "$package_name" |grep /opt/apps/$package_name/entries/applications | awk '/\.desktop$/ {print}'); do
|
||||
if [ "$(cat $desktop_file_path | grep NoDisplay=true)" = "" ];then
|
||||
echo $desktop_file_path is checked and will be installed to desktop
|
||||
chmod +x $desktop_file_path
|
||||
sudo -u "$user" cp "$desktop_file_path" "$(sudo -u "$user" xdg-user-dir DESKTOP)/"
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
}
|
||||
|
||||
function zenity() {
|
||||
local user=$(who | awk '{print $1}' | head -n 1)
|
||||
local uid=$(id -u "$user")
|
||||
sudo -u "$user" DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/"$uid"/bus zenity "$@"
|
||||
}
|
||||
|
||||
function hash_check() {
|
||||
if [ ! -e "/var/lib/aptss/lists/cdn.d.store.deepinos.org.cn_${STORE_URL}_Packages" ] && \
|
||||
[ ! -e "/var/lib/aptss/lists/d.store.deepinos.org.cn_${STORE_URL}_Packages" ] && \
|
||||
[ ! -e "/var/lib/aptss/lists/mirrors.sdu.edu.cn_spark-store-repository_${STORE_URL}_Packages" ]; then
|
||||
echo "接收星火仓库软件信息中..."
|
||||
aptss ssupdate
|
||||
fi
|
||||
|
||||
if [ -e "/var/lib/aptss/lists/cdn.d.store.deepinos.org.cn_${STORE_URL}_Packages" ]; then
|
||||
PACKAGES_DATA_PATH="/var/lib/aptss/lists/cdn.d.store.deepinos.org.cn_${STORE_URL}_Packages"
|
||||
echo "星火仓库的Packages位置为 $PACKAGES_DATA_PATH,是星火域名单目录仓库配置"
|
||||
elif [ -e "/var/lib/aptss/lists/d.store.deepinos.org.cn_${STORE_URL}_Packages" ]; then
|
||||
PACKAGES_DATA_PATH="/var/lib/aptss/lists/d.store.deepinos.org.cn_${STORE_URL}_Packages"
|
||||
echo "星火仓库的Packages位置为 $PACKAGES_DATA_PATH,是星火域名单目录仓库配置"
|
||||
else
|
||||
PACKAGES_DATA_PATH="/var/lib/aptss/lists/mirrors.sdu.edu.cn_spark-store-repository_${STORE_URL}_Packages"
|
||||
echo "星火仓库的Packages位置为 $PACKAGES_DATA_PATH,是SDU镜像仓库配置"
|
||||
fi
|
||||
|
||||
echo "正在运行包验证..."
|
||||
echo "Running Spark Package Verify..."
|
||||
|
||||
DEB_SHA512SUM=$(sha512sum "$1" | cut -d ' ' -f 1)
|
||||
IS_SHA512SUM_CHECKED=$(cat "$PACKAGES_DATA_PATH" | grep "$DEB_SHA512SUM")
|
||||
}
|
||||
|
||||
|
||||
|
||||
####################################
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "没有接收到参数,退出"
|
||||
echo "用法:$0 deb路径"
|
||||
echo "OMG-IT-GOES-WRONG"
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ ! -f "$1" ]; then
|
||||
echo "${TRANSHELL_CONTENT_FILE_NOT_EXIST}"
|
||||
echo "OMG-IT-GOES-WRONG"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$(id -u)" != "0" ]; then
|
||||
echo "${TRANSHELL_CONTENT_PLEASE_RUN_AS_ROOT}"
|
||||
echo "OMG-IT-GOES-WRONG"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
DEBPATH=$(realpath "$1")
|
||||
|
||||
|
||||
|
||||
package_name=$(dpkg-deb -f "$DEBPATH" Package)
|
||||
echo "Package name is $package_name"
|
||||
|
||||
try_run_output=$(/opt/durapps/spark-store/bin/update-upgrade/ss-do-upgrade-worker.sh test-install-app "$DEBPATH")
|
||||
try_run_ret="$?"
|
||||
if [ "$try_run_ret" -ne 0 ]; then
|
||||
aptss update
|
||||
try_run_output=$(/opt/durapps/spark-store/bin/update-upgrade/ss-do-upgrade-worker.sh test-install-app "$DEBPATH")
|
||||
try_run_ret="$?"
|
||||
fi
|
||||
|
||||
if [ "$try_run_ret" -ne 0 ]; then
|
||||
echo "OMG-IT-GOES-WRONG"
|
||||
echo -e "${try_run_output}"
|
||||
exit "$try_run_ret"
|
||||
fi
|
||||
|
||||
dpkg -i "$DEBPATH" || aptss install -yf
|
||||
|
||||
if [ "$?" = "0" ] && [ "$2" = "--delete-after-install" ]; then
|
||||
if dpkg -s "$package_name" >/dev/null 2>&1; then
|
||||
echo "软件包已安装:$package_name"
|
||||
create_desktop_file
|
||||
rm "$DEBPATH"
|
||||
echo "${TRANSHELL_CONTENT_DEB_IS_DELETED}"
|
||||
else
|
||||
echo "软件包未安装:$package_name"
|
||||
echo "安装异常!抛出错误"
|
||||
echo "OMG-IT-GOES-WRONG"
|
||||
fi
|
||||
else
|
||||
echo "${TRANSHELL_CONTENT_WILL_NOT_DELETE_DEB}"
|
||||
if dpkg -s "$package_name" >/dev/null 2>&1; then
|
||||
echo "软件包已安装:$package_name"
|
||||
create_desktop_file
|
||||
else
|
||||
echo "软件包未安装:$package_name"
|
||||
echo "安装异常!抛出错误"
|
||||
echo "OMG-IT-GOES-WRONG"
|
||||
fi
|
||||
fi
|
||||
host-spawn $0 $@
|
||||
|
171
tool/ssinstall
171
tool/ssinstall
@ -1,171 +1,2 @@
|
||||
#!/bin/bash
|
||||
SPARK_DOWNLOAD_SERVER_URL="http://127.0.0.1:8000"
|
||||
SPARK_DOWNLOAD_SERVER_URL_NO_PROTOCOL="127.0.0.1:8000"
|
||||
source /opt/durapps/spark-store/bin/bashimport/transhell.amber
|
||||
load_transhell_debug
|
||||
|
||||
case $(arch) in
|
||||
x86_64)
|
||||
STORE_URL="store"
|
||||
;;
|
||||
aarch64)
|
||||
STORE_URL="aarch64-store"
|
||||
;;
|
||||
loongarch64)
|
||||
STORE_URL="loong64-store"
|
||||
STORE_LIST_URL="-loong64"
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "Spark Store Install script. 星火商店安装脚本"
|
||||
|
||||
function pkexec_as_current_user() {
|
||||
local user=$(who | awk '{print $1}' | head -n 1)
|
||||
local uid=$(id -u "$user")
|
||||
sudo -u "$user" DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/"$uid"/bus pkexec "$@"
|
||||
}
|
||||
function create_desktop_file() {
|
||||
local user=$(who | awk '{print $1}' | head -n 1)
|
||||
if [ -e $(sudo -u "$user" xdg-user-dir)/.config/spark-union/spark-store/ssshell-config-do-not-create-desktop ];then
|
||||
echo "It is configured that do not create desktop file. Give up"
|
||||
else
|
||||
exec_create_desktop_file
|
||||
fi
|
||||
}
|
||||
function exec_create_desktop_file() {
|
||||
local user=$(who | awk '{print $1}' | head -n 1)
|
||||
for desktop_file_path in $(dpkg -L "$package_name" |grep /usr/share/applications/ | awk '/\.desktop$/ {print}'); do
|
||||
if [ "$(grep -m 1 '^NoDisplay=' "$desktop_file_path" | cut -d '=' -f 2)" = "true" ] || [ "$(grep -m 1 '^NoDisplay=' "$desktop_file_path" | cut -d '=' -f 2)" = "True" ];then
|
||||
echo $desktop_file_path is checked and will be installed to desktop
|
||||
sudo -u "$user" cp "$desktop_file_path" "$(sudo -u "$user" xdg-user-dir DESKTOP)/"
|
||||
fi
|
||||
done
|
||||
for desktop_file_path in $(dpkg -L "$package_name" |grep /opt/apps/$package_name/entries/applications | awk '/\.desktop$/ {print}'); do
|
||||
if [ "$(grep -m 1 '^NoDisplay=' "$desktop_file_path" | cut -d '=' -f 2)" = "true" ] || [ "$(grep -m 1 '^NoDisplay=' "$desktop_file_path" | cut -d '=' -f 2)" = "True" ];then
|
||||
echo $desktop_file_path is checked and will be installed to desktop
|
||||
chmod +x $desktop_file_path
|
||||
sudo -u "$user" cp "$desktop_file_path" "$(sudo -u "$user" xdg-user-dir DESKTOP)/"
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
}
|
||||
|
||||
function zenity() {
|
||||
local user=$(who | awk '{print $1}' | head -n 1)
|
||||
local uid=$(id -u "$user")
|
||||
sudo -u "$user" DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/"$uid"/bus zenity "$@"
|
||||
}
|
||||
|
||||
function hash_check() {
|
||||
if [ ! -e "/var/lib/aptss/lists/${SPARK_DOWNLOAD_SERVER_URL_NO_PROTOCOL}_${STORE_URL}_Packages" ] && \
|
||||
[ ! -e "/var/lib/aptss/lists/d.store.deepinos.org.cn_${STORE_URL}_Packages" ] && \
|
||||
[ ! -e "/var/lib/aptss/lists/mirrors.sdu.edu.cn_spark-store-repository_${STORE_URL}_Packages" ]; then
|
||||
echo "接收星火仓库软件信息中..."
|
||||
aptss ssupdate
|
||||
fi
|
||||
|
||||
if [ -e "/var/lib/aptss/lists/${SPARK_DOWNLOAD_SERVER_URL_NO_PROTOCOL}_${STORE_URL}_Packages" ]; then
|
||||
PACKAGES_DATA_PATH="/var/lib/aptss/lists/${SPARK_DOWNLOAD_SERVER_URL_NO_PROTOCOL}_${STORE_URL}_Packages"
|
||||
echo "星火仓库的Packages位置为 $PACKAGES_DATA_PATH,是星火域名仓库配置"
|
||||
elif [ -e "/var/lib/aptss/lists/d.store.deepinos.org.cn_${STORE_URL}_Packages" ]; then
|
||||
PACKAGES_DATA_PATH="/var/lib/aptss/lists/d.store.deepinos.org.cn_${STORE_URL}_Packages"
|
||||
echo "星火仓库的Packages位置为 $PACKAGES_DATA_PATH,是d域名单目录仓库配置"
|
||||
else
|
||||
PACKAGES_DATA_PATH="/var/lib/aptss/lists/mirrors.sdu.edu.cn_spark-store-repository_${STORE_URL}_Packages"
|
||||
echo "星火仓库的Packages位置为 $PACKAGES_DATA_PATH,是SDU镜像仓库配置"
|
||||
fi
|
||||
|
||||
echo "正在运行包验证..."
|
||||
echo "Running Spark Package Verify..."
|
||||
|
||||
DEB_SHA512SUM=$(sha512sum "$1" | cut -d ' ' -f 1)
|
||||
unset IS_SHA512SUM_CHECKED
|
||||
IS_SHA512SUM_CHECKED=$(cat "$PACKAGES_DATA_PATH" | grep "$DEB_SHA512SUM")
|
||||
}
|
||||
|
||||
|
||||
|
||||
####################################
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "没有接收到参数,退出"
|
||||
echo "用法:$0 deb路径"
|
||||
echo "OMG-IT-GOES-WRONG"
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ ! -f "$1" ]; then
|
||||
echo "${TRANSHELL_CONTENT_FILE_NOT_EXIST}"
|
||||
echo "OMG-IT-GOES-WRONG"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$(id -u)" != "0" ]; then
|
||||
echo "${TRANSHELL_CONTENT_PLEASE_RUN_AS_ROOT}"
|
||||
echo "OMG-IT-GOES-WRONG"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
DEBPATH=$(realpath "$1")
|
||||
|
||||
hash_check "$DEBPATH"
|
||||
|
||||
if [ -z "$IS_SHA512SUM_CHECKED" ]; then
|
||||
echo "尝试更新仓库信息重新校验"
|
||||
aptss ssupdate
|
||||
hash_check "$DEBPATH"
|
||||
if [ -z "$IS_SHA512SUM_CHECKED" ]; then
|
||||
echo -e "$TRANSHELL_CONTENT_HASH_CHECK_FAILED"
|
||||
zenity --info --icon-name=spark-store --height 270 --width 500 --text "$TRANSHELL_CONTENT_HASH_CHECK_FAILED"
|
||||
echo "OMG-IT-GOES-WRONG"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -z "$IS_SHA512SUM_CHECKED" ]; then
|
||||
echo "校验成功,开始安装"
|
||||
echo "----------------------------------------------------------------------------------"
|
||||
package_name=$(dpkg-deb -f "$DEBPATH" Package)
|
||||
echo "Package name is $package_name"
|
||||
try_run_output=$(/opt/durapps/spark-store/bin/update-upgrade/ss-do-upgrade-worker.sh test-install-app "$DEBPATH")
|
||||
try_run_ret="$?"
|
||||
|
||||
if [ "$try_run_ret" -ne 0 ]; then
|
||||
aptss update
|
||||
try_run_output=$(/opt/durapps/spark-store/bin/update-upgrade/ss-do-upgrade-worker.sh test-install-app "$DEBPATH")
|
||||
try_run_ret="$?"
|
||||
fi
|
||||
|
||||
if [ "$try_run_ret" -ne 0 ]; then
|
||||
echo "OMG-IT-GOES-WRONG"
|
||||
echo -e "${try_run_output}"
|
||||
exit "$try_run_ret"
|
||||
fi
|
||||
|
||||
dpkg -i "$DEBPATH" || aptss install -yf
|
||||
|
||||
if [ "$?" = "0" ] && [ "$2" = "--delete-after-install" ]; then
|
||||
if dpkg -s "$package_name" >/dev/null 2>&1; then
|
||||
echo "软件包已安装:$package_name"
|
||||
create_desktop_file
|
||||
rm "$DEBPATH"
|
||||
echo "${TRANSHELL_CONTENT_DEB_IS_DELETED}"
|
||||
else
|
||||
echo "软件包未安装:$package_name"
|
||||
echo "安装异常!抛出错误"
|
||||
echo "OMG-IT-GOES-WRONG"
|
||||
fi
|
||||
else
|
||||
echo "${TRANSHELL_CONTENT_WILL_NOT_DELETE_DEB}"
|
||||
if dpkg -s "$package_name" >/dev/null 2>&1; then
|
||||
echo "软件包已安装:$package_name"
|
||||
create_desktop_file
|
||||
else
|
||||
echo "软件包未安装:$package_name"
|
||||
echo "安装异常!抛出错误"
|
||||
echo "OMG-IT-GOES-WRONG"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
host-spawn $0 $@
|
||||
|
@ -1,2 +1,2 @@
|
||||
#!/bin/bash
|
||||
dpkg -l | grep "^ii" | grep -w "$1" > /dev/null
|
||||
host-spawn $0 $@
|
||||
|
@ -1,82 +1,2 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
case $1 in
|
||||
ssupdate)
|
||||
if [ "$(id -u)" != "0" ] ; then
|
||||
pkexec "$0" "$@"
|
||||
exit
|
||||
fi
|
||||
aptss ssupdate 2>&1 | tee /tmp/spark-store-app-ssupdate-log.txt
|
||||
IS_SSUPDATE_ERROR=`cat /tmp/spark-store-app-ssupdate-log.txt | grep "E: "`
|
||||
echo "$IS_SSUPDATE_ERROR" > /tmp/spark-store-app-ssupdate-status.txt
|
||||
chmod 777 /tmp/spark-store-app-ssupdate-status.txt
|
||||
chmod 777 /tmp/spark-store-app-ssupdate-log.txt
|
||||
;;
|
||||
|
||||
upgradable-list)
|
||||
output=$(env LANGUAGE=en_US /usr/bin/apt -c /opt/durapps/spark-store/bin/apt-fast-conf/aptss-apt.conf list --upgradable -o Dir::Etc::sourcelist="/opt/durapps/spark-store/bin/apt-fast-conf/sources.list.d/sparkstore.list" -o Dir::Etc::sourceparts="/dev/null" -o APT::Get::List-Cleanup="0" | awk NR\>1)
|
||||
|
||||
IFS_OLD="$IFS"
|
||||
IFS=$'\n'
|
||||
|
||||
for line in $output ; do
|
||||
PKG_NAME=$(echo $line | awk -F '/' '{print $1}')
|
||||
PKG_NEW_VER=$(echo $line | awk -F ' ' '{print $2}')
|
||||
PKG_CUR_VER=$(echo $line | awk -F ' ' '{print $6}' | awk -F ']' '{print $1}')
|
||||
echo "${PKG_NAME} ${PKG_NEW_VER} ${PKG_CUR_VER}"
|
||||
done
|
||||
|
||||
IFS="$IFS_OLD"
|
||||
;;
|
||||
|
||||
upgrade-app)
|
||||
if [ "$(id -u)" != "0" ] ; then
|
||||
pkexec "$0" "$@"
|
||||
exit
|
||||
fi
|
||||
|
||||
aptss install "${@:2}" --only-upgrade 2>&1 | tee /tmp/spark-store-app-upgrade-log.txt
|
||||
chmod 777 /tmp/spark-store-app-upgrade-log.txt
|
||||
IS_UPGRADE_ERROR=`cat /tmp/spark-store-app-upgrade-log.txt | grep "Package manager quit with exit code."`
|
||||
echo "$IS_UPGRADE_ERROR" > /tmp/spark-store-app-upgrade-status.txt
|
||||
;;
|
||||
test-install-app)
|
||||
if [ "$(id -u)" != "0" ] ; then
|
||||
pkexec "$0" "$@"
|
||||
exit
|
||||
fi
|
||||
|
||||
try_run_output=$(aptss --dry-run install $2)
|
||||
try_run_ret="$?"
|
||||
|
||||
if [ "$try_run_ret" -ne 0 ]
|
||||
then
|
||||
echo "Package manager quit with exit code.Here is the log"
|
||||
echo "包管理器以错误代码退出.日志如下"
|
||||
echo
|
||||
echo -e "${try_run_output}"
|
||||
echo "Will try after run aptss update"
|
||||
echo "将会在aptss update之后再次尝试"
|
||||
aptss update
|
||||
echo ----------------------------------------------------------------------------
|
||||
try_run_output=$(aptss --dry-run install $2)
|
||||
try_run_ret="$?"
|
||||
if [ "$try_run_ret" -ne 0 ]
|
||||
then
|
||||
echo "Package manager quit with exit code.Here is the log"
|
||||
echo "包管理器以错误代码退出.日志如下"
|
||||
echo
|
||||
echo -e "${try_run_output}"
|
||||
exit "$try_run_ret"
|
||||
fi
|
||||
|
||||
fi
|
||||
exit 0
|
||||
;;
|
||||
|
||||
clean-log)
|
||||
|
||||
rm -f /tmp/spark-store-app-ssupdate-status.txt /tmp/spark-store-app-ssupdate-log.txt /tmp/spark-store-app-upgrade-log.txt /tmp/spark-store-app-upgrade-status.txt
|
||||
;;
|
||||
esac
|
||||
host-spawn $0 $@
|
||||
|
@ -1,130 +1,2 @@
|
||||
#!/bin/bash
|
||||
|
||||
source /opt/durapps/spark-store/bin/bashimport/transhell.amber
|
||||
load_transhell_debug
|
||||
|
||||
function get_name_from_desktop_file() {
|
||||
local app_name_in_desktop
|
||||
local name_orig
|
||||
local name_i18n
|
||||
local package_name
|
||||
package_name=$1
|
||||
for desktop_file_path in $(dpkg -L "$package_name" |grep /usr/share/applications/ | awk '/\.desktop$/ {print}'); do
|
||||
if [ "$(grep -m 1 '^NoDisplay=' "$desktop_file_path" | cut -d '=' -f 2)" = "true" ] || [ "$(grep -m 1 '^NoDisplay=' "$desktop_file_path" | cut -d '=' -f 2)" = "True" ];then
|
||||
continue
|
||||
else
|
||||
name_orig=$(grep -m 1 '^Name=' "$desktop_file_path" | cut -d '=' -f 2)
|
||||
name_i18n=$(grep -m 1 "^Name\[${LANGUAGE}\]\=" "$desktop_file_path" | cut -d '=' -f 2)
|
||||
if [ -z "$name_i18n" ] ;then
|
||||
app_name_in_desktop=$name_orig
|
||||
else
|
||||
app_name_in_desktop=$name_i18n
|
||||
fi
|
||||
|
||||
fi
|
||||
done
|
||||
for desktop_file_path in $(dpkg -L "$package_name" |grep /opt/apps/$package_name/entries/applications | awk '/\.desktop$/ {print}'); do
|
||||
if [ "$(grep -m 1 '^NoDisplay=' "$desktop_file_path" | cut -d '=' -f 2)" = "true" ] || [ "$(grep -m 1 '^NoDisplay=' "$desktop_file_path" | cut -d '=' -f 2)" = "True" ];then
|
||||
continue
|
||||
else
|
||||
name_orig=$(grep -m 1 '^Name=' "$desktop_file_path" | cut -d '=' -f 2)
|
||||
name_i18n=$(grep -m 1 "^Name\[${LANGUAGE}\]\=" "$desktop_file_path" | cut -d '=' -f 2)
|
||||
if [ -z "$name_i18n" ] ;then
|
||||
app_name_in_desktop=$name_orig
|
||||
else
|
||||
app_name_in_desktop=$name_i18n
|
||||
fi
|
||||
|
||||
fi
|
||||
done
|
||||
if [ -z "$app_name_in_desktop" ] ;then
|
||||
app_name_in_desktop=${package_name}
|
||||
fi
|
||||
echo ${app_name_in_desktop}
|
||||
|
||||
}
|
||||
touch /tmp/spark-store/upgradeStatus.txt
|
||||
|
||||
# 执行 apt update
|
||||
pkexec /opt/durapps/spark-store/bin/update-upgrade/ss-do-upgrade-worker.sh ssupdate | zenity --progress --auto-close --pulsate --no-cancel --text="${TRANSHELL_CONTENT_UPDATE_CHEKING_PLEASE_WAIT}" --height 70 --width 400 --title="${TRANSHELL_CONTENT_SPARK_STORE_UPGRADE_MODEL}" --window-icon=/usr/share/icons/hicolor/scalable/apps/spark-store.svg
|
||||
|
||||
if [ -z `cat /tmp/spark-store-app-ssupdate-status.txt` ] ; then
|
||||
/opt/durapps/spark-store/bin/update-upgrade/ss-do-upgrade-worker.sh clean-log
|
||||
else
|
||||
zenity --error --text "${TRANSHELL_CONTENT_CHECK_UPDATE_PROCESS_ERROR_PRESS_CONFIRM_TO_CHECK}" --title "${TRANSHELL_CONTENT_SPARK_STORE_UPGRADE_MODEL}" --height 200 --width 350 --window-icon=/usr/share/icons/hicolor/scalable/apps/spark-store.svg
|
||||
zenity --text-info --filename=/tmp/spark-store-app-ssupdate-log.txt --checkbox="${TRANSHELL_CONTENT_I_ALREDY_COPIED_THE_LOG_HERE_AND_WILL_USE_IT_TO_FEEDBACK}" --title="${TRANSHELL_CONTENT_FEEDBACK_CAN_BE_FOUND_IN_THE_SETTINGS}" --window-icon=/usr/share/icons/hicolor/scalable/apps/spark-store.svg
|
||||
/opt/durapps/spark-store/bin/update-upgrade/ss-do-upgrade-worker.sh clean-log
|
||||
rm -f /tmp/spark-store/upgradeStatus.txt
|
||||
exit
|
||||
fi
|
||||
|
||||
# 获取可更新应用列表
|
||||
PKG_LIST="$(/opt/durapps/spark-store/bin/update-upgrade/ss-do-upgrade-worker.sh upgradable-list)"
|
||||
## 如果没更新,就弹出不需要更新
|
||||
if [ -z "$PKG_LIST" ] ; then
|
||||
zenity --info --text "${TRANSHELL_CONTENT_NO_NEED_TO_UPGRADE}" --title "${TRANSHELL_CONTENT_SPARK_STORE_UPGRADE_MODEL}" --height 150 --width 300 --window-icon=/usr/share/icons/hicolor/scalable/apps/spark-store.svg
|
||||
else
|
||||
## 获取用户选择的要更新的应用
|
||||
### 指定分隔符为 \n
|
||||
IFS_OLD="$IFS"
|
||||
IFS=$'\n'
|
||||
|
||||
PKG_UPGRADE_LIST=$(for line in $PKG_LIST ; do
|
||||
PKG_NAME=$(echo $line | awk -F ' ' '{print $1}')
|
||||
PKG_NEW_VER=$(echo $line | awk -F ' ' '{print $2}')
|
||||
PKG_CUR_VER=$(echo $line | awk -F ' ' '{print $3}')
|
||||
|
||||
dpkg --compare-versions $PKG_NEW_VER le $PKG_CUR_VER
|
||||
if [ $? -eq 0 ] ; then
|
||||
continue
|
||||
fi
|
||||
APP_NAME=$(get_name_from_desktop_file $PKG_NAME)
|
||||
#### 检测是否是 hold 状态
|
||||
PKG_STA=$(dpkg-query -W -f='${db:Status-Want}' $PKG_NAME)
|
||||
if [ "$PKG_STA" != "hold" ] ; then
|
||||
echo "true"
|
||||
echo "$APP_NAME"
|
||||
echo "$PKG_NEW_VER"
|
||||
echo "$PKG_CUR_VER"
|
||||
echo "$PKG_NAME"
|
||||
else
|
||||
echo "false"
|
||||
echo "$APP_NAME${TRANSHELL_CONTENT_CAN_NOT_UPGRADE_FOR_BEING_HOLD}"
|
||||
echo "$PKG_NEW_VER"
|
||||
echo "$PKG_CUR_VER"
|
||||
echo "$PKG_NAME"
|
||||
fi
|
||||
done)
|
||||
|
||||
### 还原分隔符
|
||||
IFS="$IFS_OLD"
|
||||
|
||||
## 如果没有应用需要更新,则直接退出
|
||||
if [ -z "$PKG_UPGRADE_LIST" ] ; then
|
||||
zenity --info --text "${TRANSHELL_CONTENT_NO_NEED_TO_UPGRADE}" --title "${TRANSHELL_CONTENT_SPARK_STORE_UPGRADE_MODEL}" --height 150 --width 300 --window-icon=/usr/share/icons/hicolor/scalable/apps/spark-store.svg
|
||||
else
|
||||
PKG_UPGRADE_LIST=$(echo "$PKG_UPGRADE_LIST" | zenity --list --text="${TRANSHELL_CONTENT_CHOOSE_APP_TO_UPGRADE}" --column="${TRANSHELL_CONTENT_CHOOSE}" --column="${TRANSHELL_CONTENT_APP_NAME}" --column="${TRANSHELL_CONTENT_NEW_VERSION}" --column="${TRANSHELL_CONTENT_UPGRADE_FROM}" --column="${TRANSHELL_CONTENT_PKG_NAME}" --separator=" " --checklist --multiple --print-column=5 --height 350 --width 650 --window-icon=/usr/share/icons/hicolor/scalable/apps/spark-store.svg)
|
||||
## 如果没有选择,则直接退出
|
||||
if [ -z "$PKG_UPGRADE_LIST" ] ; then
|
||||
zenity --info --text "${TRANSHELL_CONTENT_NO_APP_IS_CHOSEN}" --title "${TRANSHELL_CONTENT_SPARK_STORE_UPGRADE_MODEL}" --height 150 --width 300 --window-icon=/usr/share/icons/hicolor/scalable/apps/spark-store.svg
|
||||
else
|
||||
### 更新用户选择的应用
|
||||
for PKG_UPGRADE in $PKG_UPGRADE_LIST;do
|
||||
APP_UPGRADE="$(get_name_from_desktop_file $PKG_UPGRADE)"
|
||||
update_transhell
|
||||
pkexec /opt/durapps/spark-store/bin/update-upgrade/ss-do-upgrade-worker.sh upgrade-app $PKG_UPGRADE -y | zenity --progress --auto-close --no-cancel --pulsate --text="${TRANSHELL_CONTENT_UPGRADING_PLEASE_WAIT}" --height 70 --width 400 --title="${TRANSHELL_CONTENT_SPARK_STORE_UPGRADE_MODEL}" --window-icon=/usr/share/icons/hicolor/scalable/apps/spark-store.svg
|
||||
done
|
||||
#### 更新成功
|
||||
if [ -z "`cat /tmp/spark-store-app-upgrade-status.txt`" ] ; then
|
||||
zenity --info --text "${TRANSHELL_CONTENT_CHOSEN_APP_UPGRADE_FINISHED}" --title "${TRANSHELL_CONTENT_SPARK_STORE_UPGRADE_MODEL}" --height 150 --width 300 --window-icon=/usr/share/icons/hicolor/scalable/apps/spark-store.svg
|
||||
else
|
||||
#### 更新异常
|
||||
zenity --error --text "${TRANSHELL_CONTENT_APP_UGRADE_PROCESS_ERROR_PRESS_CONFIRM_TO_CHECK}" --title "${TRANSHELL_CONTENT_SPARK_STORE_UPGRADE_MODEL}" --height 200 --width 350 --window-icon=/usr/share/icons/hicolor/scalable/apps/spark-store.svg
|
||||
zenity --text-info --filename=/tmp/spark-store-app-upgrade-log.txt --checkbox="${TRANSHELL_CONTENT_I_ALREDY_COPIED_THE_LOG_HERE_AND_WILL_USE_IT_TO_FEEDBACK}" --title="${TRANSHELL_CONTENT_FEEDBACK_CAN_BE_FOUND_IN_THE_SETTINGS}" --window-icon=/usr/share/icons/hicolor/scalable/apps/spark-store.svg
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
rm -f /tmp/spark-store/upgradeStatus.txt
|
||||
# 从最开头
|
||||
host-spawn $0 $@
|
||||
|
@ -1,61 +1,2 @@
|
||||
#!/bin/bash
|
||||
|
||||
source /opt/durapps/spark-store/bin/bashimport/transhell.amber
|
||||
load_transhell_debug
|
||||
|
||||
endloop=0
|
||||
|
||||
#####################检测是否启动过了更新检测工具
|
||||
while [ $endloop -eq 0 ] ;do
|
||||
|
||||
if [ ! -e $HOME/.config/spark-union/spark-store/ssshell-config-do-not-show-upgrade-notify ];then
|
||||
text_update_open="${TRANSHELL_CONTENT_CLOSE}"
|
||||
#已经开启了就显示关闭
|
||||
else
|
||||
text_update_open="${TRANSHELL_CONTENT_OPEN}"
|
||||
fi
|
||||
|
||||
if [ ! -e $HOME/.config/spark-union/spark-store/ssshell-config-do-not-create-desktop ];then
|
||||
CONTENT_SET_CREATE_DESKTOP="${TRANSHELL_CONTENT_CLOSE_CREATE_DESKTOP}"
|
||||
#已经开启了就显示关闭
|
||||
else
|
||||
CONTENT_SET_CREATE_DESKTOP="${TRANSHELL_CONTENT_OPEN_CREATE_DESKTOP}"
|
||||
fi
|
||||
|
||||
update_transhell
|
||||
|
||||
option=$(zenity --list --text="${TRANSHELL_CONTENT_WELCOME_AND_CHOOSE_ONE_TO_RUN}" --column 数字 --column=${TRANSHELL_CONTENT_OPTIONS} --print-column=2 --height 350 --width 760 0 "${TRANSHELL_CONTENT_OPEN_OR_CLOSE_UPGRADE_CHECK}" 1 "${CONTENT_SET_CREATE_DESKTOP}" 2 "${TRANSHELL_CONTENT_CHECK_FOR_UPDATE}" 3 "${TRANSHELL_CONTENT_EXIT}" --hide-column=1 --print-column=1)
|
||||
|
||||
case $option in
|
||||
0)
|
||||
if [ ! -e $HOME/.config/spark-union/spark-store/ssshell-config-do-not-show-upgrade-notify ];then
|
||||
mkdir -p $HOME/.config/spark-union/spark-store/
|
||||
touch $HOME/.config/spark-union/spark-store/ssshell-config-do-not-show-upgrade-notify
|
||||
zenity --info --icon-name=spark-store --height 150 --width 200 --text "${TRANSHELL_CONTENT_CLOSED}" --timeout=2
|
||||
else
|
||||
rm -f $HOME/.config/spark-union/spark-store/ssshell-config-do-not-show-upgrade-notify
|
||||
zenity --info --icon-name=spark-store --height 150 --width 200 --text "${TRANSHELL_CONTENT_OPENED}" --timeout=2
|
||||
fi
|
||||
;;
|
||||
1)
|
||||
if [ ! -e $HOME/.config/spark-union/spark-store/ssshell-config-do-not-create-desktop ];then
|
||||
mkdir -p $HOME/.config/spark-union/spark-store/
|
||||
touch $HOME/.config/spark-union/spark-store/ssshell-config-do-not-create-desktop
|
||||
zenity --info --icon-name=spark-store --height 150 --width 200 --text "${TRANSHELL_CONTENT_CLOSED}" --timeout=2
|
||||
else
|
||||
rm -f $HOME/.config/spark-union/spark-store/ssshell-config-do-not-create-desktop
|
||||
zenity --info --icon-name=spark-store --height 150 --width 200 --text "${TRANSHELL_CONTENT_OPENED}" --timeout=2
|
||||
fi
|
||||
;;
|
||||
2)
|
||||
/opt/durapps/spark-store/bin/update-upgrade/ss-do-upgrade.sh
|
||||
;;
|
||||
|
||||
3)
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
exit 0
|
||||
esac
|
||||
|
||||
done
|
||||
host-spawn $0 $@
|
||||
|
@ -1,123 +1,2 @@
|
||||
#!/bin/bash
|
||||
LANGUAGE=en_US
|
||||
|
||||
source /opt/durapps/spark-store/bin/bashimport/transhell.amber
|
||||
load_transhell_debug
|
||||
|
||||
#############################################################
|
||||
|
||||
|
||||
# 发送通知
|
||||
function notify-send() {
|
||||
|
||||
|
||||
# Detect user using the display
|
||||
local user=$(who | awk '{print $1}' | head -n 1)
|
||||
|
||||
# Detect uid of the user
|
||||
local uid=$(id -u $user)
|
||||
|
||||
sudo -u $user DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/${uid}/bus notify-send "$@"
|
||||
}
|
||||
|
||||
|
||||
|
||||
# 检测网络链接畅通
|
||||
function network-check()
|
||||
{
|
||||
# 超时时间
|
||||
local timeout=15
|
||||
|
||||
# 目标网站
|
||||
local target=www.baidu.com
|
||||
|
||||
# 获取响应状态码
|
||||
local ret_code=`curl -I -s --connect-timeout ${timeout} ${target} -w %{http_code} | tail -n1`
|
||||
|
||||
if [ "x$ret_code" = "x200" ] ; then
|
||||
# 网络畅通
|
||||
return 0
|
||||
else
|
||||
# 网络不畅通
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
network-check
|
||||
if [ $? -ne 0 ] ; then
|
||||
echo "$TRANSHELL_CONTENT_NETWORK_FAIL"
|
||||
exit -1
|
||||
fi
|
||||
|
||||
# The code above is modified from https://blog.csdn.net/yaxuan88521/article/details/120516298
|
||||
|
||||
# 每日更新星火源文件
|
||||
|
||||
aptss update
|
||||
|
||||
updatetext=`aptss ssupdate 2>&1`
|
||||
|
||||
until [ "`echo $updatetext | grep E: `" = "" ];do
|
||||
echo "${TRANSHELL_CONTENT_UPDATE_ERROR_AND_WAIT_15_SEC}"
|
||||
sleep 15
|
||||
updatetext=`aptss ssupdate 2>&1`
|
||||
|
||||
|
||||
|
||||
done
|
||||
|
||||
isupdate=`echo ${updatetext: -5}`
|
||||
if [ "$isupdate" = "date." ] ; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
## 从这里开始,只有检测到了更新才会进行
|
||||
update_app_number=`echo ${updatetext%package*} #从右向左截取第一个 src 后的字符串`
|
||||
update_app_number=`echo ${update_app_number##*information...}`
|
||||
|
||||
# 获取用户选择的要更新的应用
|
||||
PKG_LIST="$(/opt/durapps/spark-store/bin/update-upgrade/ss-do-upgrade-worker.sh upgradable-list)"
|
||||
# 指定分隔符为 \n
|
||||
IFS_OLD="$IFS"
|
||||
IFS=$'\n'
|
||||
|
||||
for line in $PKG_LIST ; do
|
||||
PKG_NAME=$(echo $line | awk -F ' ' '{print $1}')
|
||||
PKG_NEW_VER=$(echo $line | awk -F ' ' '{print $2}')
|
||||
PKG_CUR_VER=$(echo $line | awk -F ' ' '{print $3}')
|
||||
|
||||
dpkg --compare-versions $PKG_NEW_VER le $PKG_CUR_VER
|
||||
|
||||
if [ $? -eq 0 ] ; then
|
||||
let update_app_number=$update_app_number-1
|
||||
continue
|
||||
fi
|
||||
|
||||
## 检测是否是 hold 状态
|
||||
PKG_STA=$(dpkg-query -W -f='${db:Status-Want}' $PKG_NAME)
|
||||
if [ "$PKG_STA" = "hold" ] ; then
|
||||
let update_app_number=$update_app_number-1
|
||||
fi
|
||||
done
|
||||
|
||||
# 还原分隔符
|
||||
IFS="$IFS_OLD"
|
||||
if [ $update_app_number -le 0 ] ; then
|
||||
exit 0
|
||||
fi
|
||||
update_transhell
|
||||
|
||||
## 如果都是hold或者版本一致的那就直接退出,否则把剩余的给提醒了
|
||||
|
||||
##TODO:除了apt-mark hold之外额外有一个禁止检查列表
|
||||
|
||||
## 如果不想提示就不提示
|
||||
|
||||
user=$(who | awk '{print $1}' | head -n 1)
|
||||
if [ -e "/home/$user/.config/spark-union/spark-store/ssshell-config-do-not-show-upgrade-notify" ];then
|
||||
echo "他不想站在世界之巅,好吧"
|
||||
echo "Okay he don't want to be at the top of the world, okay"
|
||||
exit
|
||||
else
|
||||
notify-send -a spark-store "${TRANSHELL_CONTENT_SPARK_STORE_UPGRADE_NOTIFY}" "${TRANSHELL_CONTENT_THERE_ARE_APPS_TO_UPGRADE}"
|
||||
fi
|
||||
host-spawn $0 $@
|
||||
|
Loading…
x
Reference in New Issue
Block a user