763 |
764 | |
765 |
766 |
767 |
768 | |
769 |
770 |
771 |
772 |
773 |
774 |
950 | |
951 |
952 |
953 | |
954 | |
955 |
956 |
957 |
958 |
959 |
960 |
961 |
--------------------------------------------------------------------------------
/build.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # _*_ coding:utf-8 _*_
3 |
4 | import os
5 | import sys
6 | import json
7 | import codecs
8 | import hashlib
9 | from string import Template
10 |
11 | if sys.getdefaultencoding() != 'gbk':
12 | reload(sys)
13 | sys.setdefaultencoding('gbk')
14 |
15 | parent_path = os.path.dirname(os.path.realpath(__file__))
16 |
17 | def md5sum(full_path):
18 | with open(full_path, 'rb') as rf:
19 | return hashlib.md5(rf.read()).hexdigest()
20 |
21 | def get_or_create():
22 | conf_path = os.path.join(parent_path, "config.json.js")
23 | conf = {}
24 | if not os.path.isfile(conf_path):
25 | print u"config.json.js not found,build.py is root path. auto write config.json.js"
26 | module_name = os.path.basename(parent_path)
27 | conf["module"] = module_name
28 | conf["version"] = "0.0.1"
29 | conf["home_url"] = ("Module_%s.asp" % module_name)
30 | conf["title"] = "title of " + module_name
31 | conf["description"] = "description of " + module_name
32 | else:
33 | with codecs.open(conf_path, "r", "utf-8") as fc:
34 | conf = json.loads(fc.read())
35 | return conf
36 |
37 | def build_module():
38 | try:
39 | conf = get_or_create()
40 | except:
41 | print u"config.json.js file format is incorrect"
42 | traceback.print_exc()
43 | if "module" not in conf:
44 | print u" module is not in config.json.js"
45 | return
46 | module_path = os.path.join(parent_path, conf["module"])
47 | if not os.path.isdir(module_path):
48 | print u"not found %s dir,check config.json.js is module ?" % module_path
49 | return
50 | install_path = os.path.join(parent_path, conf["module"], "install.sh")
51 | if not os.path.isfile(install_path):
52 | print u"not found %s file,check install.sh file"
53 | return
54 | print u"build..."
55 |
56 | open(parent_path + "/" + conf["module"] + "/" +"version", "w").write(conf["version"])
57 |
58 | t = Template("cd $parent_path && rm -f $module.tar.gz && tar -zcf $module.tar.gz $module")
59 | os.system(t.substitute({"parent_path": parent_path, "module": conf["module"]}))
60 | conf["md5"] = md5sum(os.path.join(parent_path, conf["module"] + ".tar.gz"))
61 | conf_path = os.path.join(parent_path, "config.json.js")
62 | with codecs.open(conf_path, "w", "utf-8") as fw:
63 | json.dump(conf, fw, sort_keys = True, indent = 4, ensure_ascii=False, encoding='utf8')
64 | print u"build done", conf["module"] + ".tar.gz"
65 | #hook_path = os.path.join(parent_path, "backup.sh")
66 | #if os.path.isfile(hook_path):
67 | # os.system(hook_path)
68 |
69 | build_module()
70 |
71 |
--------------------------------------------------------------------------------
/config.json.js:
--------------------------------------------------------------------------------
1 | {
2 | "author": "fiswonder, sadog",
3 | "description": "Alist. 一个支持多种存储的文件列表程序,使用 Gin 和 Solidjs",
4 | "home_url": "Module_alist.asp",
5 | "link": "https://github.com/everstu/Koolcenter_alist",
6 | "md5": "9263476a21bba333f27aa01e535ed509",
7 | "module": "alist",
8 | "tags": "云同步",
9 | "title": "Alist 文件列表",
10 | "version": "2.2.9"
11 | }
--------------------------------------------------------------------------------