User:Bugman/model dependencies
From FlightGear wiki
Jump to navigation
Jump to search
Contents
Finding the files
Shell command: Unix shell command for finding all model dependencies.
This is for finding dependencies on $FG_ROOT/Models/*
for all text files recursively in the current directory.
grep -rI "Models/3ds\|Models/Agriculture\|Models/StreetFurniture\|Models/Structures\|Models/Sport\|Models/Power\|Models/Misc\|Models/Aircraft\|Models/Airport\|Models/Boundaries\|Models/Communications\|Models/Fauna\|Models/Military\|Models/Transport\|Models/Trees\|Models/Industrial\|Models/Residential"
Shell script: Unix shell script for finding and listing all unique model dependencies.
This is for finding dependencies on $FG_ROOT/Models/*
for all text files recursively in the current directory.
FG_ROOT=/flightgear/flightgear-fgdata
grep -rI "Models/3ds\|Models/Agriculture\|Models/StreetFurniture\|Models/Structures\|Models/Sport\|Models/Power\|Models/Misc\|Models/Aircraft\|Models/Airport\|Models/Boundaries\|Models/Communications\|Models/Fauna\|Models/Military\|Models/Transport\|Models/Trees\|Models/Industrial\|Models/Residential" \
| sed -s "s/<\/model>.*//g" \
| sed -s "s/<\/path>.*//g" \
| sed -s "s/.*<path>//g" \
| sed -s "s/.*<model>//g" \
| sed -s "s/.*\"M/M/g" \
| sed -s "s/.*\"\/M/\/M/g" \
| sed -s "s/\".*//g" \
| sed -s "s/.*\# //g" \
| sed -s "s/\:.*//g" \
| sed -s "s/).*//g" \
| sed -s "s/.* M/M/g" \
| sed -s "s/,.*//g" \
| sort -u \
| xargs -I % ls -alh $FG_ROOT/% > /dev/null
Restoring the files
For restoring the file, use:
cd $FG_ROOT
git checkout f739a7 Models/path_to_file
The commit f739a7
was the commit prior to the purging of the Models directories. Use the shell script above and repeat the operation until no files are listed as missing.
Restored files:
The files restored after using the grep command.
Models/Agriculture/farmhouse1.ac
Models/Agriculture/farmhouse2.ac
Models/Agriculture/farmhouse3.ac
Models/Aircraft/F-15-lowpoly.xml
Models/Aircraft/H-60.xml
Models/Aircraft/dauphin.ac
Models/Aircraft/strobe.xml
Models/Aircraft/testpilot.xml
Models/Aircraft/towropes.xml
Models/Airport/Jetway/Airlines/AWE.png
Models/Airport/Jetway/Airlines/DAL.png
Models/Airport/Jetway/Airlines/FGFS.png
Models/Airport/Jetway/Airlines/SWA.png
Models/Airport/Jetway/Airlines/UAL.png
Models/Airport/Jetway/AutoGate-ba.ac
Models/Airport/Jetway/AutoGate.xml
Models/Airport/Jetway/DockingGate-ba.ac
Models/Airport/Jetway/DockingGate.xml
Models/Airport/Jetway/generic.xml
Models/Airport/Jetway/jetway-737-ba.ac
Models/Airport/Jetway/jetway-737-ba.xml
Models/Airport/Jetway/jetway-747-ba.ac
Models/Airport/Jetway/jetway-747-ba.xml
Models/Airport/Jetway/jetway-a320-ba.ac
Models/Airport/Jetway/jetway-a320-ba.xml
Models/Airport/Jetway/jetway-ba.ac
Models/Airport/Jetway/jetway-ba.xml
Models/Airport/Jetway/jetway-movable-2.ac
Models/Airport/Jetway/jetway-movable-2.xml
Models/Airport/Jetway/jetway-movable-3.ac
Models/Airport/Jetway/jetway-movable-3.xml
Models/Airport/Jetway/jetway-movable.ac
Models/Airport/Jetway/jetway-movable.xml
Models/Airport/Jetway/jetway.xml
Models/Airport/Pushback/Douglas.xml
Models/Airport/Pushback/Forklift.xml
Models/Airport/Pushback/Goldhofert-warning-light.xml
Models/Airport/Pushback/Goldhofert.xml
Models/Airport/Pushback/Military.xml
Models/Airport/Vehicle/hoskosh-ti-1500.ac
Models/Airport/ils.xml
Models/Airport/supacat_winch.ac
Models/Airport/supacat_winch.xml
Models/Airport/windsock.xml
Models/Industrial/Industrial100x70.xml
Models/Industrial/Industrial100x90.xml
Models/Industrial/Industrial10x20.xml
Models/Industrial/Industrial110x185.xml
Models/Industrial/Industrial120x90.xml
Models/Industrial/Industrial130x95.xml
Models/Industrial/Industrial150x115.xml
Models/Industrial/Industrial35x55.xml
Models/Industrial/Industrial50x100.xml
Models/Industrial/Industrial50x75.xml
Models/Industrial/Industrial55x35.xml
Models/Industrial/Industrial60x50.xml
Models/Industrial/Industrial70x60.xml
Models/Industrial/Industrial70x75.xml
Models/Industrial/Industrial85x160.xml
Models/Military/humvee-pickup-odrab-low-poly.xml
Models/Power/coolingtower.xml
Models/Transport/110Bus.xml
Models/Transport/ICE-firstcar.xml
Models/Transport/ICE-firstcar2.xml
Models/Transport/ICE-middlecar.xml
Models/Transport/ICE-middlecar2.xml
Models/Transport/KSFO_AirTrain.xml
Models/Transport/class_66.xml
Models/Transport/coach-teak-brake-1.xml
Models/Transport/coach-teak-brake.xml
Models/Transport/coach-teak-first-class.xml
Models/Transport/diesel_T153.xml
Models/Transport/locomotive-A4.xml
Models/Transport/tender-A4.xml
Models/Transport/wagon-ore.xml
Self dependency restoration
Python script: Restore self dependencies.
This is for finding the dependencies on $FG_ROOT/Models/*
for all files restored in the above sections.
from os import F_OK, access, sep, system
from re import search
# The restored files.
files = [
["Models/Aircraft", "F-15-lowpoly.xml"],
["Models/Aircraft", "H-60.xml"],
["Models/Aircraft", "strobe.xml"],
["Models/Aircraft", "testpilot.xml"],
["Models/Aircraft", "towropes.xml"],
["Models/Airport/Jetway", "AutoGate.xml"],
["Models/Airport/Jetway", "DockingGate.xml"],
["Models/Airport/Jetway", "generic.xml"],
["Models/Airport/Jetway", "jetway-737-ba.xml"],
["Models/Airport/Jetway", "jetway-747-ba.xml"],
["Models/Airport/Jetway", "jetway-a320-ba.xml"],
["Models/Airport/Jetway", "jetway-ba.xml"],
["Models/Airport/Jetway", "jetway-movable-2.xml"],
["Models/Airport/Jetway", "jetway-movable-3.xml"],
["Models/Airport/Jetway", "jetway-movable.xml"],
["Models/Airport/Jetway", "jetway.xml"],
["Models/Airport/Pushback", "Douglas.xml"],
["Models/Airport/Pushback", "Forklift.xml"],
["Models/Airport/Pushback", "Goldhofert-warning-light.xml"],
["Models/Airport/Pushback", "Goldhofert.xml"],
["Models/Airport/Pushback", "Military.xml"],
["Models/Airport", "ils.xml"],
["Models/Airport", "supacat_winch.xml"],
["Models/Airport", "windsock.xml"],
["Models/Industrial", "Industrial100x70.xml"],
["Models/Industrial", "Industrial100x90.xml"],
["Models/Industrial", "Industrial10x20.xml"],
["Models/Industrial", "Industrial110x185.xml"],
["Models/Industrial", "Industrial120x90.xml"],
["Models/Industrial", "Industrial130x95.xml"],
["Models/Industrial", "Industrial150x115.xml"],
["Models/Industrial", "Industrial35x55.xml"],
["Models/Industrial", "Industrial50x100.xml"],
["Models/Industrial", "Industrial50x75.xml"],
["Models/Industrial", "Industrial55x35.xml"],
["Models/Industrial", "Industrial60x50.xml"],
["Models/Industrial", "Industrial70x60.xml"],
["Models/Industrial", "Industrial70x75.xml"],
["Models/Industrial", "Industrial85x160.xml"],
["Models/Military", "humvee-pickup-odrab-low-poly.xml"],
["Models/Power", "coolingtower.xml"],
["Models/Transport", "110Bus.xml"],
["Models/Transport", "ICE-firstcar.xml"],
["Models/Transport", "ICE-firstcar2.xml"],
["Models/Transport", "ICE-middlecar.xml"],
["Models/Transport", "ICE-middlecar2.xml"],
["Models/Transport", "KSFO_AirTrain.xml"],
["Models/Transport", "class_66.xml"],
["Models/Transport", "coach-teak-brake-1.xml"],
["Models/Transport", "coach-teak-brake.xml"],
["Models/Transport", "coach-teak-first-class.xml"],
["Models/Transport", "diesel_T153.xml"],
["Models/Transport", "locomotive-A4.xml"],
["Models/Transport", "tender-A4.xml"],
["Models/Transport", "wagon-ore.xml"]
]
# Loop over each file path.
for path, file in files:
# The full path.
full = path + sep + file
print(full)
# Open the file.
file = open(full)
lines = file.readlines()
file.close()
# Find any paths to check.
for line in lines:
# Strip the line.
line = line.strip()
for tag in ['path', 'model']:
if search(tag, line):
# Extract the file.
tag1 = "<%s>"%tag
tag2 = "</%s>"%tag
try:
dep_file = line.split(tag1)[1]
dep_file = dep_file.split(tag2)[0]
except:
continue
if not len(dep_file):
continue
# Does the file exist?
missing = True
if access(dep_file, F_OK):
missing = False
# Try the full path.
if access(path + sep + dep_file, F_OK):
missing = False
# Try to restore the missing file.
if missing:
print(" Missing: %s (tag <%s>)" % (dep_file, tag))
system("git checkout f739a7 %s" % dep_file)
else:
print(" Found: %s (tag <%s>)" % (dep_file, tag))
Texture restoration
Python script: Restore missing texture dependencies.
This is for finding the texture dependencies on $FG_ROOT/Models/*
for all files restored in the above sections.
from os import F_OK, access, sep, system
from re import search
# The restored files.
files = [
["Models/Aircraft", "F-15-lowpoly.ac"],
["Models/Aircraft", "H-60.ac"],
["Models/Aircraft", "strobe.ac"],
["Models/Aircraft", "testpilot.ac"],
["Models/Aircraft", "towropes.ac"],
["Models/Airport/Jetway", "generic.ac"],
["Models/Airport/Pushback", "Douglas.ac"],
["Models/Airport/Pushback", "Forklift.ac"],
["Models/Airport/Pushback", "Goldhofert-warning-light.ac"],
["Models/Airport/Pushback", "Goldhofert.ac"],
["Models/Airport/Pushback", "Military.ac"],
["Models/Airport", "ils.ac"],
["Models/Airport", "windsock.ac"],
["Models/Industrial", "Industrial100x70.ac"],
["Models/Industrial", "Industrial100x90.ac"],
["Models/Industrial", "Industrial10x20.ac"],
["Models/Industrial", "Industrial110x185.ac"],
["Models/Industrial", "Industrial120x90.ac"],
["Models/Industrial", "Industrial130x95.ac"],
["Models/Industrial", "Industrial150x115.ac"],
["Models/Industrial", "Industrial35x55.ac"],
["Models/Industrial", "Industrial50x100.ac"],
["Models/Industrial", "Industrial50x75.ac"],
["Models/Industrial", "Industrial55x35.ac"],
["Models/Industrial", "Industrial60x50.ac"],
["Models/Industrial", "Industrial70x60.ac"],
["Models/Industrial", "Industrial70x75.ac"],
["Models/Industrial", "Industrial85x160.ac"],
["Models/Military", "humvee-pickup-odrab-low-poly.ac"],
["Models/Power", "coolingtower.ac"],
["Models/Transport", "110Bus.ac"],
["Models/Transport", "Class_66.ac"],
["Models/Transport", "ICE3firstcar.ac"],
["Models/Transport", "ICE3middlecar.ac"],
["Models/Transport", "ICE3middlecar2.ac"],
["Models/Transport", "KSFO_AirTrain.ac"],
["Models/Transport", "diesel_T153.ac"],
["Models/Transport", "lner-teak-brake-coach.ac"],
["Models/Transport", "lner-teak-first-class-coach.ac"],
["Models/Transport", "locomotive-A4.ac"],
["Models/Transport", "tender-A4.ac"],
["Models/Transport", "wagon-ore.ac"],
["Models/Agriculture", "farmhouse1.ac"],
["Models/Agriculture", "farmhouse2.ac"],
["Models/Agriculture", "farmhouse3.ac"],
["Models/Aircraft", "dauphin.ac"],
["Models/Airport/Jetway", "AutoGate-ba.ac"],
["Models/Airport/Jetway", "DockingGate-ba.ac"],
["Models/Airport/Jetway", "jetway-737-ba.ac"],
["Models/Airport/Jetway", "jetway-747-ba.ac"],
["Models/Airport/Jetway", "jetway-a320-ba.ac"],
["Models/Airport/Jetway", "jetway-ba.ac"],
["Models/Airport/Jetway", "jetway-movable-2.ac"],
["Models/Airport/Jetway", "jetway-movable-3.ac"],
["Models/Airport/Jetway", "jetway-movable.ac"],
["Models/Airport/Vehicle", "hoskosh-ti-1500.ac"],
["Models/Airport", "supacat_winch.ac"]
]
# Loop over each file path.
for path, file in files:
# The full path.
full = path + sep + file
print(full)
# Open the file.
file = open(full)
lines = file.readlines()
file.close()
# Find any paths to check.
for line in lines:
if search('texture', line):
# Extract the file.
dep_file = line.split("\"")[1]
if not len(dep_file):
continue
# Does the file exist?
missing = True
if access(dep_file, F_OK):
missing = False
# Try the full path.
if access(path + sep + dep_file, F_OK):
missing = False
# Try to restore the missing file.
if missing:
print(" Missing: %s" % dep_file)
system("git checkout f739a7 %s" % dep_file)
system("git checkout f739a7 %s/%s" % (path, dep_file))
else:
print(" Found: %s" % dep_file)