mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-07-28 13:16:41 +00:00
Merge pull request #1079 from MilhouseVH/distro_tool_filters
distro-tool: Add main/addon and rev/ver filters
This commit is contained in:
commit
3c503a08ec
@ -29,6 +29,8 @@ DRY_RUN=no
|
|||||||
IGNORE_ERRORS=no
|
IGNORE_ERRORS=no
|
||||||
DOGIT=no
|
DOGIT=no
|
||||||
CHECK_NEWER=yes
|
CHECK_NEWER=yes
|
||||||
|
CHECK_FILTER_TYPE=All
|
||||||
|
CHECK_FILTER_CLASS=All
|
||||||
PROGRESS=yes
|
PROGRESS=yes
|
||||||
IS_MIRROR=yes
|
IS_MIRROR=yes
|
||||||
VERBOSE=0
|
VERBOSE=0
|
||||||
@ -410,6 +412,9 @@ class MyUtility(object):
|
|||||||
if not package_url.startswith("https://github.com/"):
|
if not package_url.startswith("https://github.com/"):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if CHECK_FILTER_TYPE == "Ver":
|
||||||
|
return
|
||||||
|
|
||||||
is_git_rev = True
|
is_git_rev = True
|
||||||
|
|
||||||
latestrev = MyUtility.get_latest_commit(msgs, package_url)
|
latestrev = MyUtility.get_latest_commit(msgs, package_url)
|
||||||
@ -420,6 +425,8 @@ class MyUtility(object):
|
|||||||
return
|
return
|
||||||
|
|
||||||
alt_versions.append(latestrev[0:len(package_ver)])
|
alt_versions.append(latestrev[0:len(package_ver)])
|
||||||
|
elif CHECK_FILTER_TYPE == "Rev":
|
||||||
|
return
|
||||||
|
|
||||||
MyUtility.show(msgs, 2 if VERBOSE == 2 else 3, None, "Checking for newer", "%s, current version %s - checking %s" % (package_name, package_ver, ", ".join(alt_versions)))
|
MyUtility.show(msgs, 2 if VERBOSE == 2 else 3, None, "Checking for newer", "%s, current version %s - checking %s" % (package_name, package_ver, ", ".join(alt_versions)))
|
||||||
|
|
||||||
@ -428,7 +435,10 @@ class MyUtility(object):
|
|||||||
for newver in alt_versions:
|
for newver in alt_versions:
|
||||||
url = newurl.replace("@@VER@@", newver)
|
url = newurl.replace("@@VER@@", newver)
|
||||||
if MyUtility.remote_file_exists(msgs, url):
|
if MyUtility.remote_file_exists(msgs, url):
|
||||||
MyUtility.show(msgs, 0, "yellow" if is_git_rev else "magenta", "New package available", "%s (%s => %s) %s" % (package_name, package_ver, newver, url))
|
if is_git_rev:
|
||||||
|
MyUtility.show(msgs, 0, "yellow", "New Rev Pkg available", "%s (%s => %s) %s" % (package_name, package_ver, newver, url))
|
||||||
|
else:
|
||||||
|
MyUtility.show(msgs, 0, "magenta","New Ver Pkg available", "%s (%s => %s) %s" % (package_name, package_ver, newver, url))
|
||||||
break
|
break
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -469,6 +479,7 @@ class MyThread(threading.Thread):
|
|||||||
qItem = self.input_queue.get(block=False)
|
qItem = self.input_queue.get(block=False)
|
||||||
self.input_queue.task_done()
|
self.input_queue.task_done()
|
||||||
|
|
||||||
|
pkg_is_addon = (qItem["PKG_IS_ADDON"] == "Yes")
|
||||||
pkg_name = qItem["PKG_NAME"]
|
pkg_name = qItem["PKG_NAME"]
|
||||||
pkg_version = qItem["PKG_VERSION"]
|
pkg_version = qItem["PKG_VERSION"]
|
||||||
pkg_url = qItem["PKG_URL"]
|
pkg_url = qItem["PKG_URL"]
|
||||||
@ -478,7 +489,7 @@ class MyThread(threading.Thread):
|
|||||||
msgs = []
|
msgs = []
|
||||||
|
|
||||||
if pkg_version == "" or pkg_version == "0.0invalid" or pkg_url == "":
|
if pkg_version == "" or pkg_version == "0.0invalid" or pkg_url == "":
|
||||||
if pkg_section != "virtual":
|
if pkg_section != "virtual" and CHECK_FILTER_CLASS == "All" and CHECK_FILTER_TYPE == "All":
|
||||||
MyUtility.show(msgs, 0, "cyan", "UNKNOWN VER OR URL", "%s (ver [%s], url [%s])" % (pkg_name, pkg_version, pkg_url))
|
MyUtility.show(msgs, 0, "cyan", "UNKNOWN VER OR URL", "%s (ver [%s], url [%s])" % (pkg_name, pkg_version, pkg_url))
|
||||||
self.output_queue.put(msgs)
|
self.output_queue.put(msgs)
|
||||||
continue
|
continue
|
||||||
@ -501,9 +512,12 @@ class MyThread(threading.Thread):
|
|||||||
tDelta_get_package = datetime.datetime.now() - tStart
|
tDelta_get_package = datetime.datetime.now() - tStart
|
||||||
|
|
||||||
if CHECK_NEWER and not stopped.is_set():
|
if CHECK_NEWER and not stopped.is_set():
|
||||||
tStart = datetime.datetime.now()
|
if (CHECK_FILTER_CLASS == "All") or \
|
||||||
MyUtility.check_newer(msgs, pkg_name, pkg_url, pkg_version)
|
(CHECK_FILTER_CLASS == "Main" and pkg_is_addon == False) or \
|
||||||
tDelta_check_newer = datetime.datetime.now() - tStart
|
(CHECK_FILTER_CLASS == "Addons" and pkg_is_addon == True):
|
||||||
|
tStart = datetime.datetime.now()
|
||||||
|
MyUtility.check_newer(msgs, pkg_name, pkg_url, pkg_version)
|
||||||
|
tDelta_check_newer = datetime.datetime.now() - tStart
|
||||||
|
|
||||||
self.output_queue.put([{"stop": True, "name": threading.current_thread().name, "url": pkg_url}])
|
self.output_queue.put([{"stop": True, "name": threading.current_thread().name, "url": pkg_url}])
|
||||||
|
|
||||||
@ -615,7 +629,9 @@ if __name__ == "__main__":
|
|||||||
WORKER_THREADS=int(args[9])
|
WORKER_THREADS=int(args[9])
|
||||||
GIT_USERNAME = args[10]
|
GIT_USERNAME = args[10]
|
||||||
GIT_PASSWORD = args[11]
|
GIT_PASSWORD = args[11]
|
||||||
VERBOSE = int(args[12])
|
CHECK_FILTER_CLASS = args[12]
|
||||||
|
CHECK_FILTER_TYPE = args[13]
|
||||||
|
VERBOSE = int(args[14])
|
||||||
SCRATCH_DIR="%s/.tmp" % DOWNLOAD_DIR
|
SCRATCH_DIR="%s/.tmp" % DOWNLOAD_DIR
|
||||||
|
|
||||||
stopped = threading.Event()
|
stopped = threading.Event()
|
||||||
@ -635,27 +651,32 @@ help() {
|
|||||||
cat <<EOF
|
cat <<EOF
|
||||||
Usage: $(basename $0) -d|--download <path> [-t|--target <path>] [-l|--libreelec <path>]
|
Usage: $(basename $0) -d|--download <path> [-t|--target <path>] [-l|--libreelec <path>]
|
||||||
[-m|--mirror] [-s|--source] [-a|-all] [-p|--package <package_name> [-r|--revision <revision>]]
|
[-m|--mirror] [-s|--source] [-a|-all] [-p|--package <package_name> [-r|--revision <revision>]]
|
||||||
[--git] [-n|--notnewer] [--dry-run] [--noprogress] [-T #|--threads #] [-U|--gituser] [-P|--gitpass]
|
[--git] [-n|--notnewer] [--check-main | --check-addons] [--check-ver | --check-rev]
|
||||||
|
[--noprogress] [-T #|--threads #] [-U|--gituser] [-P|--gitpass] [--dry-run]
|
||||||
[-v|--verbose] [-h|--help]
|
[-v|--verbose] [-h|--help]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-d, --download: Directory path into which new package files will be downloaded - default is $HOME/download[1]
|
-d, --download: Directory path into which new package files will be downloaded - default is $HOME/download[1]
|
||||||
-t, --target: Directory path for existing packages that are to be refreshed, default is /community/sources[2]
|
-t, --target: Directory path for existing packages that are to be refreshed, default is /community/sources[2]
|
||||||
-l, --libreelec: LibreELEC.tv repo, default is ${HOME}/LibreELEC.tv
|
-l, --libreelec: LibreELEC.tv repo, default is ${HOME}/LibreELEC.tv
|
||||||
-m, --mirror: Target is mirror not source - mirror uses a hierarchical per-package folder structure
|
-m, --mirror: Target is mirror not source - mirror uses a hierarchical per-package folder structure
|
||||||
-s, --source: Target is source not mirror - source uses a flattened file structure. Default is mirror
|
-s, --source: Target is source not mirror - source uses a flattened file structure. Default is mirror
|
||||||
-a, --all: Ignore download failures, continue processing all packages
|
-a, --all: Ignore download failures, continue processing all packages
|
||||||
-p, --package: Package to process, otherwise process all packages
|
-p, --package: Package to process, otherwise process all packages
|
||||||
-r, --revision: Version to use in place of PKG_VERSION, only applicable in conjunction with -p
|
-r, --revision: Version to use in place of PKG_VERSION, only applicable in conjunction with -p
|
||||||
--git: Clone (if not available) or pull the LibreELEC.tv repository
|
--git: Clone (if not available) or pull the LibreELEC.tv repository
|
||||||
-n, --notnewer Don't check for newer packages ('X.Y.Z+1' 'X.Y+1.0' 'X+1.0.0')
|
-n, --notnewer: Don't check for newer packages ('X.Y.Z+1' 'X.Y+1.0' 'X+1.0.0')
|
||||||
--dry-run: Don't actually download anything (will still git clone/pull if configured)
|
--check-main: Check newer for main packages, ignore add-on packages
|
||||||
--noprogress: Do not show progress indicator
|
--check-addons: Check newer for add-on packages, ignore main packages
|
||||||
-T, --threads: Number of worker threads, default is 32
|
--check-ver: Check newer for version-based packages, ignore rev-based/github packages
|
||||||
-U, --gituser: Git username (or source from ~/.git.conf) - avoids API limits
|
--check-rev: Check newer for rev-based/github packages, ignore version-based packages
|
||||||
-P, --gitpass: Git password (or source from ~/.git.conf) - avoids API limits
|
--noprogress: Do not show progress indicator
|
||||||
-v, --verbose: Output more verbose sync information. Repeat for more detail
|
-T, --threads: Number of worker threads, default is 32
|
||||||
-h, --help: This message
|
-U, --gituser: Git username (or source from ~/.git.conf) - avoids API limits
|
||||||
|
-P, --gitpass: Git password (or source from ~/.git.conf) - avoids API limits
|
||||||
|
--dry-run: Don't actually download anything (will still git clone/pull if configured)
|
||||||
|
-v, --verbose: Output more verbose sync information. Repeat for more detail
|
||||||
|
-h, --help: This message
|
||||||
|
|
||||||
Note#1. The download directory will have the LibreELEC version appended (eg. /devel) unless it is a mirror, in which case "/mirror" will be appended.
|
Note#1. The download directory will have the LibreELEC version appended (eg. /devel) unless it is a mirror, in which case "/mirror" will be appended.
|
||||||
Note#2. The target directory will have the LibreELEC version appended (eg. /devel) unless it is a mirror, in which case "/mirror" will be appended.
|
Note#2. The target directory will have the LibreELEC version appended (eg. /devel) unless it is a mirror, in which case "/mirror" will be appended.
|
||||||
@ -737,8 +758,8 @@ generate_work_worker() {
|
|||||||
local pcount=$1 worker="$2" revision="$3"
|
local pcount=$1 worker="$2" revision="$3"
|
||||||
local workfile_i="$(printf "%s.%02d" "${WORKFILES_I}" ${worker})"
|
local workfile_i="$(printf "%s.%02d" "${WORKFILES_I}" ${worker})"
|
||||||
local workfile_o="$(printf "%s.%02d" "${WORKFILES_O}" ${worker})"
|
local workfile_o="$(printf "%s.%02d" "${WORKFILES_O}" ${worker})"
|
||||||
local wanted_vars="PKG_NAME PKG_VERSION PKG_URL PKG_SECTION PKG_SOURCE_NAME"
|
local wanted_vars="PKG_NAME PKG_VERSION PKG_URL PKG_SECTION PKG_IS_ADDON PKG_SOURCE_NAME"
|
||||||
local package_name var comma PKG_URL PKG_SOURCE_NAME PKG_VERSION
|
local package_name var comma PKG_URL PKG_SOURCE_NAME PKG_VERSION PKG_IS_ADDON
|
||||||
|
|
||||||
[ -f "${workfile_i}" ] || return 0
|
[ -f "${workfile_i}" ] || return 0
|
||||||
|
|
||||||
@ -761,6 +782,10 @@ generate_work_worker() {
|
|||||||
PKG_VERSION="${revision}"
|
PKG_VERSION="${revision}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
PKG_IS_ADDON=No
|
||||||
|
[[ ${PKG_DIR/${LIBREELEC_DIR}/} =~ ^/packages/addons/.* ]] && PKG_IS_ADDON=Yes
|
||||||
|
[[ ${PKG_DIR/${LIBREELEC_DIR}/} =~ ^/packages/mediacenter/kodi-binary-addons/.* ]] && PKG_IS_ADDON=Yes
|
||||||
|
|
||||||
echo " {" >>${workfile_o}
|
echo " {" >>${workfile_o}
|
||||||
for var in ${wanted_vars}; do
|
for var in ${wanted_vars}; do
|
||||||
[ "${var}" != "PKG_SOURCE_NAME" ] && comma="," || comma=
|
[ "${var}" != "PKG_SOURCE_NAME" ] && comma="," || comma=
|
||||||
@ -830,7 +855,7 @@ exec_worker_prog() {
|
|||||||
python /tmp/distro-tool.py "${DOWNLOAD_DIR}" "${TARGET_DIR}" "${DISTRO_SOURCE}" "${DISTRO_MIRROR}" \
|
python /tmp/distro-tool.py "${DOWNLOAD_DIR}" "${TARGET_DIR}" "${DISTRO_SOURCE}" "${DISTRO_MIRROR}" \
|
||||||
"${IS_MIRROR}" "${IGNORE_ERRORS}" "${DRY_RUN}" "${CHECK_NEWER}" \
|
"${IS_MIRROR}" "${IGNORE_ERRORS}" "${DRY_RUN}" "${CHECK_NEWER}" \
|
||||||
"${PROGRESS}" "${WORKER_THREADS}" "${GIT_USERNAME}" "${GIT_PASSWORD}" \
|
"${PROGRESS}" "${WORKER_THREADS}" "${GIT_USERNAME}" "${GIT_PASSWORD}" \
|
||||||
"${VERBOSE}"
|
"${CHECK_FILTER_CLASS}" "${CHECK_FILTER_TYPE}" "${VERBOSE}"
|
||||||
rm -f /tmp/distro-tool.py
|
rm -f /tmp/distro-tool.py
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -876,6 +901,18 @@ while [ : ]; do
|
|||||||
-n|--notnewer)
|
-n|--notnewer)
|
||||||
CHECK_NEWER=no
|
CHECK_NEWER=no
|
||||||
;;
|
;;
|
||||||
|
--check-ver)
|
||||||
|
CHECK_FILTER_TYPE=Ver
|
||||||
|
;;
|
||||||
|
--check-rev)
|
||||||
|
CHECK_FILTER_TYPE=Rev
|
||||||
|
;;
|
||||||
|
--check-addons)
|
||||||
|
CHECK_FILTER_CLASS=Addons
|
||||||
|
;;
|
||||||
|
--check-main)
|
||||||
|
CHECK_FILTER_CLASS=Main
|
||||||
|
;;
|
||||||
-T|--threads)
|
-T|--threads)
|
||||||
shift
|
shift
|
||||||
[ $1 -gt 0 ] && WORKER_THREADS=$1
|
[ $1 -gt 0 ] && WORKER_THREADS=$1
|
||||||
@ -958,7 +995,7 @@ echo "Distro Source is: ${DISTRO_SOURCE}"
|
|||||||
echo "Distro Mirror is: ${DISTRO_MIRROR}"
|
echo "Distro Mirror is: ${DISTRO_MIRROR}"
|
||||||
echo " Syncing against: ${TARGET_DIR}"
|
echo " Syncing against: ${TARGET_DIR}"
|
||||||
echo " Downloading to: ${DOWNLOAD_DIR}"
|
echo " Downloading to: ${DOWNLOAD_DIR}"
|
||||||
echo " Check Newer: ${CHECK_NEWER^}"
|
echo " Check Newer: ${CHECK_NEWER^} Class/Type: ${CHECK_FILTER_CLASS} / ${CHECK_FILTER_TYPE}"
|
||||||
echo " Dry run: ${DRY_RUN^}"
|
echo " Dry run: ${DRY_RUN^}"
|
||||||
if [ ${VERBOSE} -gt 2 ]; then
|
if [ ${VERBOSE} -gt 2 ]; then
|
||||||
echo " Debugging level: ${VERBOSE} (${DEBUG_LOG})"
|
echo " Debugging level: ${VERBOSE} (${DEBUG_LOG})"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user