From a2c507e48d80ed6c1bd92ba09712a771f2495872 Mon Sep 17 00:00:00 2001 From: Thomas Klaehn Date: Tue, 5 Mar 2019 12:26:15 +0100 Subject: [PATCH] ipkindex: Add tool to index an ipk mirror Signed-off-by: Thomas Klaehn --- ipkindex | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 ipkindex diff --git a/ipkindex b/ipkindex new file mode 100755 index 0000000..c2222f2 --- /dev/null +++ b/ipkindex @@ -0,0 +1,29 @@ +#!/usr/bin/env python + +import argparse +import os +import re +import subprocess +import sys + +parser = argparse.ArgumentParser() +parser.add_argument("base_folder", help="Base folder to be indexed.") +args = parser.parse_args() + +abs_base_folder = os.path.abspath(args.base_folder) +index_folders = list() + +for root, _, files in os.walk(abs_base_folder, topdown=False): + for name in files: + if re.match(r".*.ipk$", name) and not root in index_folders: + index_folders.append(root) + break + +for folder in index_folders: + cmd = "opkg-make-index -p Packages".split() + cmd.append(folder) + print("processing folder {}".format(folder)) + subprocess.call(cmd, cwd=folder) + +sys.exit(0) +