Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Alchemy Viewer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Silent mode is enabled
All outbound communications are blocked.
Learn more
.
Show more breadcrumbs
Alchemy Viewer
Alchemy Viewer
Commits
35fc90e8
Commit
35fc90e8
authored
14 years ago
by
Mark Palange (Mani)
Browse files
Options
Downloads
Patches
Plain Diff
CHOP-179 Added --file option to linux-updater for local install
parent
1368a94f
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
indra/linux_updater/linux_updater.cpp
+82
-67
82 additions, 67 deletions
indra/linux_updater/linux_updater.cpp
with
82 additions
and
67 deletions
indra/linux_updater/linux_updater.cpp
+
82
−
67
View file @
35fc90e8
...
@@ -49,6 +49,7 @@ const guint ROTATE_IMAGE_TIMEOUT = 8000;
...
@@ -49,6 +49,7 @@ const guint ROTATE_IMAGE_TIMEOUT = 8000;
typedef
struct
_updater_app_state
{
typedef
struct
_updater_app_state
{
std
::
string
app_name
;
std
::
string
app_name
;
std
::
string
url
;
std
::
string
url
;
std
::
string
file
;
std
::
string
image_dir
;
std
::
string
image_dir
;
std
::
string
dest_dir
;
std
::
string
dest_dir
;
std
::
string
strings_dirs
;
std
::
string
strings_dirs
;
...
@@ -266,85 +267,95 @@ gpointer worker_thread_cb(gpointer data)
...
@@ -266,85 +267,95 @@ gpointer worker_thread_cb(gpointer data)
CURLcode
result
;
CURLcode
result
;
FILE
*
package_file
;
FILE
*
package_file
;
GError
*
error
=
NULL
;
GError
*
error
=
NULL
;
char
*
tmp_filename
=
NULL
;
int
fd
;
int
fd
;
//g_return_val_if_fail (data != NULL, NULL);
//g_return_val_if_fail (data != NULL, NULL);
app_state
=
(
UpdaterAppState
*
)
data
;
app_state
=
(
UpdaterAppState
*
)
data
;
try
{
try
{
// create temporary file to store the package.
fd
=
g_file_open_tmp
(
"secondlife-update-XXXXXX"
,
&
tmp_filename
,
&
error
);
if
(
error
!=
NULL
)
{
llerrs
<<
"Unable to create temporary file: "
<<
error
->
message
<<
llendl
;
g_error_free
(
error
);
if
(
!
app_state
->
url
.
empty
())
throw
0
;
}
package_file
=
fdopen
(
fd
,
"wb"
);
if
(
package_file
==
NULL
)
{
{
llerrs
<<
"Failed to create temporary file: "
char
*
tmp_local_filename
=
NULL
;
<<
tmp_filename
// create temporary file to store the package.
<<
llendl
;
fd
=
g_file_open_tmp
(
"secondlife-update-XXXXXX"
,
&
tmp_local_filename
,
&
error
);
if
(
error
!=
NULL
)
{
llerrs
<<
"Unable to create temporary file: "
<<
error
->
message
<<
llendl
;
gdk_threads_enter
();
g_error_free
(
error
);
display_error
(
app_state
->
window
,
throw
0
;
LLTrans
::
getString
(
"UpdaterFailDownloadTitle"
),
}
LLTrans
::
getString
(
"UpdaterFailUpdateDescriptive"
));
gdk_threads_leave
();
if
(
tmp_local_filename
!=
NULL
)
throw
0
;
{
}
app_state
->
file
=
tmp_local_filename
;
g_free
(
tmp_local_filename
);
}
// initialize curl and start downloading the package
package_file
=
fdopen
(
fd
,
"wb"
);
llinfos
<<
"Downloading package: "
<<
app_state
->
url
<<
llendl
;
if
(
package_file
==
NULL
)
{
llerrs
<<
"Failed to create temporary file: "
<<
app_state
->
file
.
c_str
()
<<
llendl
;
gdk_threads_enter
();
display_error
(
app_state
->
window
,
LLTrans
::
getString
(
"UpdaterFailDownloadTitle"
),
LLTrans
::
getString
(
"UpdaterFailUpdateDescriptive"
));
gdk_threads_leave
();
throw
0
;
}
curl
=
curl_easy_init
();
// initialize curl and start downloading the package
if
(
curl
==
NULL
)
llinfos
<<
"Downloading package: "
<<
app_state
->
url
<<
llendl
;
{
llerrs
<<
"Failed to initialize libcurl"
<<
llendl
;
gdk_threads_enter
();
curl
=
curl_easy_init
();
display_error
(
app_state
->
window
,
if
(
curl
==
NULL
)
LLTrans
::
getString
(
"UpdaterFailDownloadTitle"
),
{
LLTrans
::
getString
(
"UpdaterFailUpdateDescriptive"
));
llerrs
<<
"Failed to initialize libcurl"
<<
llendl
;
gdk_threads_leave
();
throw
0
;
gdk_threads_enter
();
}
display_error
(
app_state
->
window
,
LLTrans
::
getString
(
"UpdaterFailDownloadTitle"
),
LLTrans
::
getString
(
"UpdaterFailUpdateDescriptive"
));
gdk_threads_leave
();
throw
0
;
}
curl_easy_setopt
(
curl
,
CURLOPT_URL
,
app_state
->
url
.
c_str
());
curl_easy_setopt
(
curl
,
CURLOPT_URL
,
app_state
->
url
.
c_str
());
curl_easy_setopt
(
curl
,
CURLOPT_NOSIGNAL
,
TRUE
);
curl_easy_setopt
(
curl
,
CURLOPT_NOSIGNAL
,
TRUE
);
curl_easy_setopt
(
curl
,
CURLOPT_FOLLOWLOCATION
,
TRUE
);
curl_easy_setopt
(
curl
,
CURLOPT_FOLLOWLOCATION
,
TRUE
);
curl_easy_setopt
(
curl
,
CURLOPT_WRITEDATA
,
package_file
);
curl_easy_setopt
(
curl
,
CURLOPT_WRITEDATA
,
package_file
);
curl_easy_setopt
(
curl
,
CURLOPT_NOPROGRESS
,
FALSE
);
curl_easy_setopt
(
curl
,
CURLOPT_NOPROGRESS
,
FALSE
);
curl_easy_setopt
(
curl
,
CURLOPT_PROGRESSFUNCTION
,
curl_easy_setopt
(
curl
,
CURLOPT_PROGRESSFUNCTION
,
&
download_progress_cb
);
&
download_progress_cb
);
curl_easy_setopt
(
curl
,
CURLOPT_PROGRESSDATA
,
app_state
);
curl_easy_setopt
(
curl
,
CURLOPT_PROGRESSDATA
,
app_state
);
result
=
curl_easy_perform
(
curl
);
result
=
curl_easy_perform
(
curl
);
fclose
(
package_file
);
fclose
(
package_file
);
curl_easy_cleanup
(
curl
);
curl_easy_cleanup
(
curl
);
if
(
result
)
if
(
result
)
{
{
llerrs
<<
"Failed to download update: "
llerrs
<<
"Failed to download update: "
<<
app_state
->
url
<<
app_state
->
url
<<
llendl
;
<<
llendl
;
gdk_threads_enter
();
gdk_threads_enter
();
display_error
(
app_state
->
window
,
display_error
(
app_state
->
window
,
LLTrans
::
getString
(
"UpdaterFailDownloadTitle"
),
LLTrans
::
getString
(
"UpdaterFailDownloadTitle"
),
LLTrans
::
getString
(
"UpdaterFailUpdateDescriptive"
));
LLTrans
::
getString
(
"UpdaterFailUpdateDescriptive"
));
gdk_threads_leave
();
gdk_threads_leave
();
throw
0
;
throw
0
;
}
}
}
// now pulse the progres bar back and forth while the package is
// now pulse the progres bar back and forth while the package is
// being unpacked
// being unpacked
gdk_threads_enter
();
gdk_threads_enter
();
...
@@ -357,7 +368,7 @@ gpointer worker_thread_cb(gpointer data)
...
@@ -357,7 +368,7 @@ gpointer worker_thread_cb(gpointer data)
// *TODO: if the destination is not writable, terminate this
// *TODO: if the destination is not writable, terminate this
// thread and show file chooser?
// thread and show file chooser?
if
(
!
install_package
(
tmp_filename
,
app_state
->
dest_dir
))
if
(
!
install_package
(
app_state
->
file
.
c_str
()
,
app_state
->
dest_dir
))
{
{
llwarns
<<
"Failed to install package to destination: "
llwarns
<<
"Failed to install package to destination: "
<<
app_state
->
dest_dir
<<
app_state
->
dest_dir
...
@@ -393,11 +404,11 @@ gpointer worker_thread_cb(gpointer data)
...
@@ -393,11 +404,11 @@ gpointer worker_thread_cb(gpointer data)
}
}
// FIXME: delete package file also if delete-event is raised on window
// FIXME: delete package file also if delete-event is raised on window
if
(
tmp_filename
!=
NULL
)
if
(
!
app_state
->
url
.
empty
()
&&
!
app_state
->
file
.
empty
()
)
{
{
if
(
gDirUtilp
->
fileExists
(
tmp_filenam
e
))
if
(
gDirUtilp
->
fileExists
(
app_state
->
fil
e
))
{
{
LLFile
::
remove
(
tmp_filenam
e
);
LLFile
::
remove
(
app_state
->
fil
e
);
}
}
}
}
...
@@ -712,7 +723,7 @@ BOOL spawn_viewer(UpdaterAppState *app_state)
...
@@ -712,7 +723,7 @@ BOOL spawn_viewer(UpdaterAppState *app_state)
void
show_usage_and_exit
()
void
show_usage_and_exit
()
{
{
std
::
cout
<<
"Usage: linux-updater --url URL --name NAME --dest PATH --stringsdir PATH1,PATH2 --stringsfile FILE"
std
::
cout
<<
"Usage: linux-updater
<
--url URL
| --file FILE>
--name NAME --dest PATH --stringsdir PATH1,PATH2 --stringsfile FILE"
<<
"[--image-dir PATH]"
<<
"[--image-dir PATH]"
<<
std
::
endl
;
<<
std
::
endl
;
exit
(
1
);
exit
(
1
);
...
@@ -728,6 +739,10 @@ void parse_args_and_init(int argc, char **argv, UpdaterAppState *app_state)
...
@@ -728,6 +739,10 @@ void parse_args_and_init(int argc, char **argv, UpdaterAppState *app_state)
{
{
app_state
->
url
=
argv
[
i
];
app_state
->
url
=
argv
[
i
];
}
}
else
if
((
!
strcmp
(
argv
[
i
],
"--file"
))
&&
(
++
i
<
argc
))
{
app_state
->
file
=
argv
[
i
];
}
else
if
((
!
strcmp
(
argv
[
i
],
"--name"
))
&&
(
++
i
<
argc
))
else
if
((
!
strcmp
(
argv
[
i
],
"--name"
))
&&
(
++
i
<
argc
))
{
{
app_state
->
app_name
=
argv
[
i
];
app_state
->
app_name
=
argv
[
i
];
...
@@ -756,7 +771,7 @@ void parse_args_and_init(int argc, char **argv, UpdaterAppState *app_state)
...
@@ -756,7 +771,7 @@ void parse_args_and_init(int argc, char **argv, UpdaterAppState *app_state)
}
}
if
(
app_state
->
app_name
.
empty
()
if
(
app_state
->
app_name
.
empty
()
||
app_state
->
url
.
empty
()
||
(
app_state
->
url
.
empty
()
&&
app_state
->
file
.
empty
())
||
app_state
->
dest_dir
.
empty
())
||
app_state
->
dest_dir
.
empty
())
{
{
show_usage_and_exit
();
show_usage_and_exit
();
...
...
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