Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FFS Gluon Firmware Selector
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
firmware
FFS Gluon Firmware Selector
Commits
9cb827b3
Commit
9cb827b3
authored
8 years ago
by
Moritz Warning
Browse files
Options
Downloads
Patches
Plain Diff
refactor code and make the listing of unmatches images optional
parent
be1a8766
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
app.js
+61
-58
61 additions, 58 deletions
app.js
config_template.js
+2
-0
2 additions, 0 deletions
config_template.js
with
63 additions
and
58 deletions
app.js
+
61
−
58
View file @
9cb827b3
...
@@ -183,13 +183,13 @@ var firmwarewizard = function() {
...
@@ -183,13 +183,13 @@ var firmwarewizard = function() {
}
}
// exclude file names containing a string
// exclude file names containing a string
function
i
sValid
FileName
(
name
)
{
function
i
gnore
FileName
(
name
)
{
for
(
var
i
in
IGNORED_ELEMENTS
)
{
for
(
var
i
in
IGNORED_ELEMENTS
)
{
if
(
name
.
indexOf
(
IGNORED_ELEMENTS
[
i
])
!=
-
1
)
{
if
(
name
.
indexOf
(
IGNORED_ELEMENTS
[
i
])
!=
-
1
)
{
return
fals
e
;
return
tru
e
;
}
}
}
}
return
tru
e
;
return
fals
e
;
}
}
// simplified version string sort
// simplified version string sort
...
@@ -215,6 +215,12 @@ var firmwarewizard = function() {
...
@@ -215,6 +215,12 @@ var firmwarewizard = function() {
return
m
?
m
[
1
]
:
''
;
return
m
?
m
[
1
]
:
''
;
}
}
function
findRevision
(
name
)
{
// reversion identifier like a1, v2
var
m
=
/-
([
a-z
][
0-9
]
+
(
.
[
0-9
]
+
)?)[
.-
]
/
.
exec
(
name
);
return
m
?
m
[
1
]
:
'
alle
'
;
}
function
findRegion
(
name
)
{
function
findRegion
(
name
)
{
var
m
=
/-
(
eu|cn|de|jp|us
)[
.-
]
/
.
exec
(
name
);
var
m
=
/-
(
eu|cn|de|jp|us
)[
.-
]
/
.
exec
(
name
);
return
m
?
m
[
1
]
:
''
;
return
m
?
m
[
1
]
:
''
;
...
@@ -228,6 +234,41 @@ var firmwarewizard = function() {
...
@@ -228,6 +234,41 @@ var firmwarewizard = function() {
}
}
}
}
function
parseFilePath
(
device
,
match
,
path
,
href
,
branch
)
{
if
(
device
.
model
==
'
--ignore--
'
||
device
.
revision
==
'
--ignore--
'
)
{
return
;
}
var
location
=
path
+
href
;
var
type
=
findType
(
href
);
var
version
=
findVersion
(
href
);
var
region
=
findRegion
(
href
);
var
revision
=
device
.
revision
;
if
(
revision
.
length
==
0
)
{
revision
=
findRevision
(
href
.
replace
(
match
,
''
));
}
if
(
region
.
length
)
{
revision
+=
'
-
'
+
region
;
}
// collect branch versions
app
.
currentVersions
[
branch
]
=
version
;
if
(
!
(
device
.
vendor
in
images
))
{
images
[
device
.
vendor
]
=
{};
}
addArray
(
images
[
device
.
vendor
],
device
.
model
,
{
'
revision
'
:
revision
,
'
branch
'
:
branch
,
'
type
'
:
type
,
'
version
'
:
version
,
'
location
'
:
location
});
}
function
createOption
(
value
,
title
,
selectedOption
)
{
function
createOption
(
value
,
title
,
selectedOption
)
{
var
o
=
document
.
createElement
(
'
option
'
);
var
o
=
document
.
createElement
(
'
option
'
);
o
.
value
=
value
;
o
.
value
=
value
;
...
@@ -480,70 +521,32 @@ var firmwarewizard = function() {
...
@@ -480,70 +521,32 @@ var firmwarewizard = function() {
return
0
;
return
0
;
});
});
for
(
var
indexPath
in
config
.
directories
)
{
// match all links
var
basePath
=
indexPath
.
substring
(
0
,
indexPath
.
lastIndexOf
(
'
/
'
)
+
1
);
var
reLink
=
new
RegExp
(
'
href="([^"]*)"
'
,
'
g
'
);
var
branch
=
config
.
directories
[
indexPath
];
// match image files
var
reMatch
=
new
RegExp
(
'
(
'
+
matches
.
join
(
'
|
'
)
+
'
)[.-]
'
);
for
(
var
indexPath
in
config
.
directories
)
{
// retrieve the contents of the directory
// retrieve the contents of the directory
loadSite
(
indexPath
,
function
(
data
,
indexPath
)
{
loadSite
(
indexPath
,
function
(
data
,
indexPath
)
{
// create regex for extracting image paths
var
basePath
=
indexPath
.
substring
(
0
,
indexPath
.
lastIndexOf
(
'
/
'
)
+
1
);
var
reIndex
=
new
RegExp
(
'
="([^"]*[-.][^"]*)"
'
,
'
g
'
);
var
branch
=
config
.
directories
[
indexPath
];
reLink
.
lastIndex
=
0
;
// find the correct reversion (e.g. a1, v2)
var
reRevision
=
'
[a-z][0-9]+(.[0-9]+)?
'
;
var
reMatches
=
new
RegExp
(
'
(
'
+
matches
.
join
(
'
|
'
)
+
'
)-?(rev-)?(
'
+
reRevision
+
'
)?(-sysupgrade)?.(img.gz|bin|tar|img|elf|vdi|vmdk)$
'
);
var
m
;
var
m
;
do
{
do
{
m
=
reIndex
.
exec
(
data
);
m
=
reLink
.
exec
(
data
);
if
(
m
)
{
if
(
m
)
{
var
href
=
m
[
1
];
var
href
=
m
[
1
];
var
match
=
reMatches
.
exec
(
href
);
var
match
=
reMatch
.
exec
(
href
);
if
(
isValidFileName
(
href
))
{
if
(
match
)
{
if
(
match
)
{
var
devices
=
vendormodels_reverse
[
match
[
1
]];
var
devices
=
vendormodels_reverse
[
match
[
1
]];
for
(
var
i
in
devices
)
{
for
(
var
i
in
devices
)
{
if
(
devices
[
i
].
model
==
'
--ignore--
'
||
devices
[
i
].
revision
==
'
--ignore--
'
)
{
parseFilePath
(
devices
[
i
],
match
,
basePath
,
href
,
branch
);
continue
;
}
var
location
=
basePath
+
href
;
var
type
=
findType
(
href
);
var
version
=
findVersion
(
href
);
var
revision
=
devices
[
i
].
revision
;
if
(
revision
.
length
==
0
)
{
revision
=
match
[
3
]
||
'
alle
'
;
href
.
replace
(
revision
,
''
);
}
var
region
=
findRegion
(
href
);
if
(
region
.
length
)
{
revision
+=
'
-
'
+
region
;
}
// collect branch versions
app
.
currentVersions
[
branch
]
=
version
;
if
(
!
(
devices
[
i
].
vendor
in
images
))
{
images
[
devices
[
i
].
vendor
]
=
{};
}
addArray
(
images
[
devices
[
i
].
vendor
],
devices
[
i
].
model
,
{
'
revision
'
:
revision
,
'
branch
'
:
branch
,
'
type
'
:
type
,
'
version
'
:
version
,
'
location
'
:
location
});
}
}
else
{
console
.
log
(
"
No rule for firmware image
"
,
href
);
}
}
}
else
if
(
config
.
listMissingImages
&&
!
ignoreFileName
(
href
))
{
console
.
log
(
"
No rule for firmware image:
"
,
href
);
}
}
}
}
}
while
(
m
);
}
while
(
m
);
...
...
This diff is collapsed.
Click to expand it.
config_template.js
+
2
−
0
View file @
9cb827b3
...
@@ -14,6 +14,8 @@
...
@@ -14,6 +14,8 @@
*/
*/
var
config
=
{
var
config
=
{
// list images on console that match no model
listMissingImages
:
false
,
// see devices.js for different vendor model maps
// see devices.js for different vendor model maps
vendormodels
:
vendormodels
,
vendormodels
:
vendormodels
,
// relative image paths and branch
// relative image paths and branch
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment