]> git.lizzy.rs Git - cheatdb.git/blob - setup.py
Add Minetest version checking to packages API
[cheatdb.git] / setup.py
1 # Content DB
2 # Copyright (C) 2018  rubenwardy
3 #
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
16
17
18 import os, sys, datetime
19
20 if not "FLASK_CONFIG" in os.environ:
21         os.environ["FLASK_CONFIG"] = "../config.cfg"
22
23 delete_db = len(sys.argv) >= 2 and sys.argv[1].strip() == "-d"
24 create_db = not (len(sys.argv) >= 2 and sys.argv[1].strip() == "-o")
25 test_data = len(sys.argv) >= 2 and sys.argv[1].strip() == "-t" or not create_db
26
27 from app.models import *
28 from app.utils import make_flask_user_password
29
30 def defineDummyData(licenses, tags, ruben):
31         ez = User("Shara")
32         ez.github_username = "Ezhh"
33         ez.forums_username = "Shara"
34         ez.rank = UserRank.EDITOR
35         db.session.add(ez)
36
37         not1 = Notification(ruben, ez, "Awards approved", "/packages/rubenwardy/awards/")
38         db.session.add(not1)
39
40         jeija = User("Jeija")
41         jeija.github_username = "Jeija"
42         jeija.forums_username = "Jeija"
43         db.session.add(jeija)
44
45
46         mod = Package()
47         mod.approved = True
48         mod.name = "alpha"
49         mod.title = "Alpha Test"
50         mod.license = licenses["MIT"]
51         mod.type = PackageType.MOD
52         mod.author = ruben
53         mod.tags.append(tags["mapgen"])
54         mod.tags.append(tags["environment"])
55         mod.repo = "https://github.com/ezhh/other_worlds"
56         mod.issueTracker = "https://github.com/ezhh/other_worlds/issues"
57         mod.forums = 16015
58         mod.shortDesc = "The content library should not be used yet as it is still in alpha"
59         mod.desc = "This is the long desc"
60         db.session.add(mod)
61
62         rel = PackageRelease()
63         rel.package = mod
64         rel.title = "v1.0.0"
65         rel.url = "https://github.com/ezhh/handholds/archive/master.zip"
66         rel.approved = True
67         db.session.add(rel)
68
69         mod1 = Package()
70         mod1.approved = True
71         mod1.name = "awards"
72         mod1.title = "Awards"
73         mod1.license = licenses["LGPLv2.1"]
74         mod1.type = PackageType.MOD
75         mod1.author = ruben
76         mod1.tags.append(tags["player_effects"])
77         mod1.repo = "https://github.com/rubenwardy/awards"
78         mod1.issueTracker = "https://github.com/rubenwardy/awards/issues"
79         mod1.forums = 4870
80         mod1.shortDesc = "Adds achievements and an API to register new ones."
81         mod1.desc = """
82 Majority of awards are back ported from Calinou's old fork in Carbone, under same license.
83
84 ```
85 awards.register_achievement("award_mesefind",{
86     title = "First Mese Find",
87     description = "Found some Mese!",
88     trigger = {
89         type   = "dig",          -- award is given when
90         node   = "default:mese", -- this type of node has been dug
91         target = 1,              -- this number of times
92     },
93 })
94 ```
95 """
96
97         rel = PackageRelease()
98         rel.package = mod1
99         rel.title = "v1.0.0"
100         rel.url = "https://github.com/rubenwardy/awards/archive/master.zip"
101         rel.approved = True
102         db.session.add(rel)
103
104         mod2 = Package()
105         mod2.approved = True
106         mod2.name = "mesecons"
107         mod2.title = "Mesecons"
108         mod2.tags.append(tags["tools"])
109         mod2.type = PackageType.MOD
110         mod2.license = licenses["LGPLv3"]
111         mod2.author = jeija
112         mod2.repo = "https://github.com/minetest-mods/mesecons/"
113         mod2.issueTracker = "https://github.com/minetest-mods/mesecons/issues"
114         mod2.forums = 628
115         mod2.shortDesc = "Mesecons adds everything digital, from all kinds of sensors, switches, solar panels, detectors, pistons, lamps, sound blocks to advanced digital circuitry like logic gates and programmable blocks."
116         mod2.desc = """
117     ########################################################################
118     ##  __    __   _____   _____   _____   _____   _____   _   _   _____  ##
119     ## |  \  /  | |  ___| |  ___| |  ___| |  ___| |  _  | | \ | | |  ___| ##
120     ## |   \/   | | |___  | |___  | |___  | |     | | | | |  \| | | |___  ##
121     ## | |\__/| | |  ___| |___  | |  ___| | |     | | | | |     | |___  | ##
122     ## | |    | | | |___   ___| | | |___  | |___  | |_| | | |\  |  ___| | ##
123     ## |_|    |_| |_____| |_____| |_____| |_____| |_____| |_| \_| |_____| ##
124     ##                                                                    ##
125     ########################################################################
126
127 MESECONS by Jeija and contributors
128
129 Mezzee-what?
130 ------------
131 [Mesecons](http://mesecons.net/)! They're yellow, they're conductive, and they'll add a whole new dimension to Minetest's gameplay.
132
133 Mesecons is a mod for [Minetest](http://minetest.net/) that implements a ton of items related to digital circuitry, such as wires, buttons, lights, and even programmable controllers. Among other things, there are also pistons, solar panels, pressure plates, and note blocks.
134
135 Mesecons has a similar goal to Redstone in Minecraft, but works in its own way, with different rules and mechanics.
136
137 OK, I want in.
138 --------------
139 Go get it!
140
141 [DOWNLOAD IT NOW](https://github.com/minetest-mods/mesecons/archive/master.zip)
142
143 Now go ahead and install it like any other Minetest mod. Don't know how? Check out [the wonderful page about it](http://wiki.minetest.com/wiki/Mods) over at the Minetest Wiki. For your convenience, here's a quick summary:
144
145 1. If Mesecons is still in a ZIP file, extract the folder inside to somewhere on the computer.
146 2. Make sure that when you open the folder, you can directly find `README.md` in the listing. If you just see another folder, move that folder up one level and delete the old one.
147 3. Open up the Minetest mods folder - usually `/mods/`. If you see the `minetest` or folder inside of that, that is your mod folder instead.
148 4. Copy the Mesecons folder into the mods folder.
149
150 Don't like some parts of Mesecons? Open up the Mesecons folder and delete the subfolder containing the mod you don't want. If you didn't want movestones, for example, all you have to do is delete the `mesecons_movestones` folder and they will no longer be available.
151
152 There are no dependencies - it will work right after installing!
153
154 How do I use this thing?
155 ------------------------
156 How about a [quick overview video](https://www.youtube.com/watch?v=6kmeQj6iW5k)?
157
158 Or maybe a [comprehensive reference](http://mesecons.net/items.html) is your style?
159
160 An overview for the very newest of new beginners? How does [this one](http://uberi.mesecons.net/projects/MeseconsBasics/index.html) look?
161
162 Want to get more into building? Why not check out the [Mesecons Laboratory](http://uberi.mesecons.net/), a website dedicated to advanced Mesecons builders?
163
164 Want to contribute to Mesecons itself? Check out the [source code](https://github.com/minetest-mods/mesecons)!
165
166 Who wrote it anyways?
167 ---------------------
168 These awesome people made Mesecons possible!
169
170 | Contributor     | Contribution                     |
171 | --------------- | -------------------------------- |
172 | Hawk777         | Code for VoxelManip caching      |
173 | Jat15           | Various tweaks.                  |
174 | Jeija           | **Main developer! Everything.**  |
175 | Jordach         | Noteblock sounds.                |
176 | khonkhortistan  | Code, recipes, textures.         |
177 | Kotolegokot     | Nodeboxes for items.             |
178 | minerd247       | Textures.                        |
179 | Nore/Novatux    | Code.                            |
180 | RealBadAngel    | Fixes, improvements.             |
181 | sfan5           | Code, recipes, textures.         |
182 | suzenako        | Piston sounds.                   |
183 | Uberi/Temperest | Code, textures, documentation.   |
184 | VanessaE        | Code, recipes, textures, design. |
185 | Whiskers75      | Logic gates implementation.      |
186
187 There are also a whole bunch of other people helping with everything from code to testing and feedback. Mesecons would also not be possible without their help!
188
189 Alright, how can I use it?
190 --------------------------
191 All textures in this project are licensed under the CC-BY-SA 3.0 (Creative Commons Attribution-ShareAlike 3.0 Generic). That means you can distribute and remix them as much as you want to, under the condition that you give credit to the authors and the project, and that if you remix and release them, they must be under the same or similar license to this one.
192
193 All code in this project is licensed under the LGPL version 3 or later. That means you have unlimited freedom to distribute and modify the work however you see fit, provided that if you decide to distribute it or any modified versions of it, you must also use the same license. The LGPL also grants the additional freedom to write extensions for the software and distribute them without the extensions being subject to the terms of the LGPL, although the software itself retains its license.
194
195 No warranty is provided, express or implied, for any part of the project.
196
197 """
198
199         db.session.add(mod1)
200         db.session.add(mod2)
201
202         mod = Package()
203         mod.approved = True
204         mod.name = "handholds"
205         mod.title = "Handholds"
206         mod.license = licenses["MIT"]
207         mod.type = PackageType.MOD
208         mod.author = ez
209         mod.tags.append(tags["player_effects"])
210         mod.repo = "https://github.com/ezhh/handholds"
211         mod.issueTracker = "https://github.com/ezhh/handholds/issues"
212         mod.forums = 17069
213         mod.shortDesc = "Adds hand holds and climbing thingies"
214         mod.desc = "This is the long desc"
215         db.session.add(mod)
216
217         rel = PackageRelease()
218         rel.package = mod
219         rel.title = "v1.0.0"
220         rel.url = "https://github.com/ezhh/handholds/archive/master.zip"
221         rel.approved = True
222         db.session.add(rel)
223
224         mod = Package()
225         mod.approved = True
226         mod.name = "other_worlds"
227         mod.title = "Other Worlds"
228         mod.license = licenses["MIT"]
229         mod.type = PackageType.MOD
230         mod.author = ez
231         mod.tags.append(tags["mapgen"])
232         mod.tags.append(tags["environment"])
233         mod.repo = "https://github.com/ezhh/other_worlds"
234         mod.issueTracker = "https://github.com/ezhh/other_worlds/issues"
235         mod.forums = 16015
236         mod.shortDesc = "Adds space with asteroids and comets"
237         mod.desc = "This is the long desc"
238         db.session.add(mod)
239
240         mod = Package()
241         mod.approved = True
242         mod.name = "food"
243         mod.title = "Food"
244         mod.license = licenses["LGPLv2.1"]
245         mod.type = PackageType.MOD
246         mod.author = ruben
247         mod.tags.append(tags["player_effects"])
248         mod.repo = "https://github.com/rubenwardy/food/"
249         mod.issueTracker = "https://github.com/rubenwardy/food/issues/"
250         mod.forums = 2960
251         mod.shortDesc = "Adds lots of food and an API to manage ingredients"
252         mod.desc = "This is the long desc"
253         food = mod
254         db.session.add(mod)
255
256         mod = Package()
257         mod.approved = True
258         mod.name = "food_sweet"
259         mod.title = "Sweet Foods"
260         mod.license = licenses["CC0"]
261         mod.type = PackageType.MOD
262         mod.author = ruben
263         mod.tags.append(tags["player_effects"])
264         mod.repo = "https://github.com/rubenwardy/food_sweet/"
265         mod.issueTracker = "https://github.com/rubenwardy/food_sweet/issues/"
266         mod.forums = 9039
267         mod.shortDesc = "Adds sweet food"
268         mod.desc = "This is the long desc"
269         food_sweet = mod
270         db.session.add(mod)
271
272         game1 = Package()
273         game1.approved = True
274         game1.name = "capturetheflag"
275         game1.title = "Capture The Flag"
276         game1.type = PackageType.GAME
277         game1.license = licenses["LGPLv2.1"]
278         game1.author = ruben
279         game1.tags.append(tags["pvp"])
280         game1.tags.append(tags["survival"])
281         game1.tags.append(tags["multiplayer"])
282         game1.repo = "https://github.com/rubenwardy/capturetheflag"
283         game1.issueTracker = "https://github.com/rubenwardy/capturetheflag/issues"
284         game1.forums = 12835
285         game1.shortDesc = "Two teams battle to snatch and return the enemy's flag, before the enemy takes their own!"
286         game1.desc = """
287 As seen on the Capture the Flag server (minetest.rubenwardy.com:30000)
288
289 Uses the CTF PvP Engine.
290 """
291
292         db.session.add(game1)
293
294         rel = PackageRelease()
295         rel.package = game1
296         rel.title = "v1.0.0"
297         rel.url = "https://github.com/rubenwardy/capturetheflag/archive/master.zip"
298         rel.approved = True
299         db.session.add(rel)
300
301
302         mod = Package()
303         mod.approved = True
304         mod.name = "pixelbox"
305         mod.title = "PixelBOX Reloaded"
306         mod.license = licenses["CC0"]
307         mod.type = PackageType.TXP
308         mod.author = ruben
309         mod.forums = 14132
310         mod.shortDesc = "This is an update of the original PixelBOX texture pack by the brillant artist Gambit"
311         mod.desc = "This is the long desc"
312         db.session.add(mod)
313
314         rel = PackageRelease()
315         rel.package = mod
316         rel.title = "v1.0.0"
317         rel.url = "http://mamadou3.free.fr/Minetest/PixelBOX.zip"
318         rel.approved = True
319         db.session.add(rel)
320
321         db.session.commit()
322
323         metas = {}
324         for package in Package.query.filter_by(type=PackageType.MOD).all():
325                 meta = None
326                 try:
327                         meta = metas[package.name]
328                 except KeyError:
329                         meta = MetaPackage(package.name)
330                         db.session.add(meta)
331                         metas[package.name] = meta
332                 package.provides.append(meta)
333
334         dep = Dependency(food_sweet, meta=metas["food"])
335         db.session.add(dep)
336
337
338 if delete_db and os.path.isfile("db.sqlite"):
339         os.remove("db.sqlite")
340
341
342 if create_db:
343         print("Creating database tables...")
344         db.create_all()
345
346 print("Filling database...")
347
348 ruben = User("rubenwardy")
349 ruben.active = True
350 ruben.password = make_flask_user_password("tuckfrump")
351 ruben.github_username = "rubenwardy"
352 ruben.forums_username = "rubenwardy"
353 ruben.rank = UserRank.ADMIN
354 db.session.add(ruben)
355
356 tags = {}
357 for tag in ["Inventory", "Mapgen", "Building", \
358                 "Mobs and NPCs", "Tools", "Player effects", \
359                 "Environment", "Transport", "Maintenance", "Plants and farming", \
360                 "PvP", "PvE", "Survival", "Creative", "Puzzle", "Multiplayer", "Singleplayer"]:
361         row = Tag(tag)
362         tags[row.name] = row
363         db.session.add(row)
364
365 licenses = {}
366 for license in ["GPLv2.1", "GPLv3", "LGPLv2.1", "LGPLv3", "AGPLv2.1", "AGPLv3",
367                                 "Apache", "BSD 3-Clause", "BSD 2-Clause", "CC0", "CC-BY-SA",
368                                 "CC-BY", "MIT", "ZLib", "Other (Free)"]:
369         row = License(license)
370         licenses[row.name] = row
371         db.session.add(row)
372
373 for license in ["CC-BY-NC-SA", "Other (Non-free)"]:
374         row = License(license, False)
375         licenses[row.name] = row
376         db.session.add(row)
377
378 if test_data:
379         defineDummyData(licenses, tags, ruben)
380
381 db.session.commit()