📄 app_gen.ins
字号:
if { $CHOICE == "no" } {
return "cancel"
}
#
# On update or fix installation, an option is given for renaming
# the previous executable directory to a date-tagged copy
#
if { $RENAME_E_VER } {
set EXISTING_E_PATH [file join $EDIR_LOCATION_PATH e$VER_NUM]
set BAK_PATH [tclu_get_bak_name $EXISTING_E_PATH]
set BAK_NAME [file tail $BAK_PATH]
if { [file exists $EXISTING_E_PATH] } {
set CHOICE [tku_popup_message question yesno \
"There seems to exist an executable \
\nsub-directory e$VER_NUM inside $EDIR_LOCATION_PATH \
\n$ACTION existing 'e$VER_NUM' to '$BAK_NAME' before \
\ncopying over it ?"]
if { $CHOICE == "yes" } {
switch -- $APP_GEN_G(INSTALL_TYPE) {
"update" {
if [ catch {file rename $EXISTING_E_PATH $BAK_PATH} ERROR] {
set CHOICE [tku_popup_message question yesno \
"$ERROR \
\nAre you sure you wish to continue ?"]
if { $CHOICE == "no" } {
return "error"
}
}
}
"fix" {
set CP $VPIG(CP)
set COMMAND "$CP -r $EXISTING_E_PATH $BAK_PATH"
set STATUS [tku_long_command $COMMAND \
"Copying existing directory e$VER_NUM..." \
$VPIG(WMESSAGE) \
abort]
if { $STATUS != "ok" } {
return "error"
}
}
default {
bgerror "Switch error app_gen.ins (2)"
}
}
} else {
set CHMOD $VPIG(CHMOD)
set CHMOD_COMMAND "$CHMOD -R 0777 $EXISTING_E_PATH"
set TITLE "Opening permissions for $EXISTING_E_PATH..."
set STATUS [tku_long_command \
$CHMOD_COMMAND $TITLE $VPIG(WMESSAGE) abort]
if {$STATUS != "ok"} {
return $STATUS
}
}
}
}
set TOOLS_PATH $VPIG(TOOLS_PATH)
#
# The generated command for opening the file is quite complex:
#
# It involves running the pipe_in program.
# pipe_in will pipe the data in the 'tgz' file to gunzip and then to
# tar. In the process, the file PROGRESS_PATH will receive data about the
# progress (in %) of the operation. This file is used by the
# tku.long_command_blink to display the current progress.
#
if { $APP_GEN_G(INSTALL_TYPE) == "full" } {
if [ catch {cd $DEST_PATH} RESPONSE ] {
tku_popup_message error ok $RESPONSE
return "error"
}
set PROGRESS_PATH [tclu_get_tmp_name tmp_vpi]
set COMMAND [format "%s %s %s | %s | %s %s" \
[file join $TOOLS_PATH pipe_in.exe] \
"$DATA_PATH" \
$PROGRESS_PATH \
[file join $TOOLS_PATH gunzip.exe] \
$VPIG(TAR) "xf - $TAR_DIRS "]
set TITLE "Installing environment ($APP_GEN_G(INSTALL_TYPE) installation)..."
set STATUS [tku_long_command $COMMAND $TITLE $VPIG(WMESSAGE) \
abort $PROGRESS_PATH]
catch { file delete $PROGRESS_PATH }
if { $STATUS != "ok" } {
return $STATUS
}
}
if { $DO_E_SEPARATELY } {
if [ catch {cd $EDIR_LOCATION_PATH} RESPONSE ] {
tku_popup_message error ok $RESPONSE
return "error"
}
set PROGRESS_PATH [tclu_get_tmp_name tmp_vpi]
set COMMAND [format "%s %s %s | %s | %s %s" \
[file join $TOOLS_PATH pipe_in.exe] \
"$DATA_PATH" \
$PROGRESS_PATH \
[file join $TOOLS_PATH gunzip.exe] \
$VPIG(TAR) "xf - e$VER_NUM "]
set TITLE "Installing executables ($APP_GEN_G(INSTALL_TYPE) installation)..."
set STATUS [tku_long_command $COMMAND $TITLE $VPIG(WMESSAGE) \
abort $PROGRESS_PATH]
catch { file delete $PROGRESS_PATH }
if { $STATUS != "ok" } {
if { $STATUS == "error" } {
tku_popup_message error ok \
"Installation error may be caused by: \
\n 1. Insufficient permissions to change the files \
\n 2. File is locked due to the application program running"
}
return $STATUS
}
}
set DEST_PATH $APP_GEN_G(DEST_PATH)
set CUR_VER_PATH [file join $DEST_PATH last_ver]
if [catch {open $CUR_VER_PATH {WRONLY CREAT TRUNC} 0777} FP] {
tku_popup_message error ok \
"The file $CUR_VER_PATH cannot be opened.\
\nIt may effect future installations consistency checks."
} else {
puts $FP $VPIG(NAME_VERSION)
close $FP
}
#
# If it is a Full ATGen installation some files should be renamed
#
if { $APP_GEN_G(INSTALL_TYPE) == "full" } {
set CHOICES [list Genesis ATGen]
set CHOICE [tku_popup_message question $CHOICES \
"Which product are you installing?"]
if { $CHOICE == "ATGen" } {
set DEST_PATH $APP_GEN_G(DEST_PATH)
set SYS_PATH [file join $DEST_PATH sys]
if [ catch {cd $SYS_PATH} RESPONSE ] {
tku_popup_message error ok $RESPONSE
return "error"
}
set ATG_FILE atg_install
if { ! [file exists $ATG_FILE] } {
tku_popup_message error ok \
"ATGen install file does not exist\n$ATG_FILE"
return "error"
}
if { [catch {open $ATG_FILE RDONLY} FP] } {
tku_popup_message error ok \
"Error to read ATGen install file\n$ATG_FILE"
return "error"
}
set ATG_INST_DATA [read $FP]
close $FP
set LINES [split $ATG_INST_DATA \n]
foreach LINE $LINES {
set LINE [string trim $LINE]
set COL1 [string range $LINE 0 0]
if { $COL1 == "#" } {
continue
}
set FIELDS [split $LINE " "]
if { [string length $FIELDS] == 0 } {
continue
}
set DEST_FILE ""
set FNAME ""
foreach FIELD $FIELDS {
set DEST_FILE [file join $DEST_FILE $FNAME]
set FNAME $FIELD
}
set FROM_FILE [file join $DEST_FILE _$FNAME]
set DEST_FILE [file join $DEST_FILE $FNAME]
if { [file exists $FROM_FILE] } {
if [file exists $DEST_FILE] {
if [catch {file delete $DEST_FILE} RESPONSE] {
tku_popup_message error ok $RESPONSE
return "error"
}
}
if [ catch {file rename $FROM_FILE $DEST_FILE} RESPONSE] {
tku_popup_message error ok $RESPONSE
return "error"
}
}
}
#........ Create the data directory..........#
set DATA_DIR_PATH [file join $APP_GEN_G(DEST_PATH) data]
if { ! [tclu_file_exists $DATA_DIR_PATH] } {
if [catch {file mkdir $DATA_DIR_PATH} RESPONSE] {
tku_popup_message error ok $RESPONSE
return "error"
}
}
}
}
return "ok"
}
#.................................................................
# Only called for fix versions
# verifies that the previously installed version is consistent with
# the one we try to install.
#
proc verify_previous_version {} {
global VPIG
global APP_GEN_G
set DEST_PATH $APP_GEN_G(DEST_PATH)
set CUR_VER_PATH [file join $DEST_PATH last_ver]
if [catch {open $CUR_VER_PATH RDONLY} FP] {
tku_popup_message error ok \
"The file $CUR_VER_PATH does not exist.\
\nIt is therefore impossible to verify that the\
\ninstallation is consistent with previous contents."
return 1
}
set CUR_NAME_VERSION [gets $FP]
close $FP
set VER_NUM [get_version_number $VPIG(NAME_VERSION)]
get_version_type $VPIG(NAME_VERSION) IS_FIX VTYPE \
FIX_ID PFIX_ID
set CUR_VER_NUM [get_version_number $CUR_NAME_VERSION]
get_version_type $CUR_NAME_VERSION CUR_IS_FIX CUR_VTYPE \
CUR_FIX_ID CUR_PFIX_ID
if { $VER_NUM != $CUR_VER_NUM } {
tku_popup_message error ok \
[format \
"Version number is inconsistent:\
\nNew version number : (%d)\
\nCurrent version number : (%d) " $VER_NUM $CUR_VER_NUM ]
return 1
}
set OK 0
set MESSAGE ""
switch -- $VTYPE {
"pre_rel_update" {
if { $CUR_VTYPE == "pre_rel"} {
set OK 1
} elseif { $CUR_VTYPE == "pre_rel_update"} {
if { [string compare $FIX_ID $CUR_FIX_ID] >= 0 } {
set OK 1
}
}
if { ! $OK } {
set MESSAGE "The current version must be a pre-release version \
\nof v$VER_NUM (e.g. v${VER_NUM}PR)"
}
}
"version_update" {
if { $CUR_VTYPE == "version"} {
set OK 1
} elseif { $CUR_VTYPE == "version_update"} {
if { [string compare $FIX_ID $CUR_FIX_ID] >= 0 } {
set OK 1
}
} elseif { $CUR_VTYPE == "private_update"} {
if { [string compare $FIX_ID $CUR_FIX_ID] > 0 } {
set OK 1
}
}
if { ! $OK } {
set MESSAGE "The current version must be a full or an\
\nearlier fix version of v$VER_NUM"
}
}
"private_update" {
if { $CUR_VTYPE == "version_update"} {
if { [string compare $FIX_ID $CUR_FIX_ID] >= 0 } {
set OK 1
}
} elseif { $CUR_VTYPE == "private_update"} {
if { [string compare $FIX_ID $CUR_FIX_ID] > 0 } {
set OK 1
}
if { [string compare $FIX_ID $CUR_FIX_ID] == 0 &&
[string compare $PFIX_ID $CUR_PFIX_ID] >= 0 } {
set OK 1
}
} elseif { $CUR_VTYPE == "version" } {
if { $VER_NUM == $CUR_VER_NUM } {
set OK 1
}
}
if { ! $OK } {
set MESSAGE "The current version (v$CUR_VER_NUM$CUR_FIX_ID) must be an\
\nearlier fix version of v$VER_NUM$FIX_ID."
}
}
default {
set OK 1
}
}
if { ! $OK } {
tku_popup_message error ok \
"Version name is inconsistent:\
\n$MESSAGE"
return 1
}
set EDIR_LOCATION_PATH [get_edir_location $APP_GEN_G(DEST_PATH)]
set EDIR_PATH [file join $EDIR_LOCATION_PATH e$VER_NUM]
if { ! [tclu_is_path_dir $EDIR_PATH] } {
tku_popup_message error ok \
"For a fix version, the directory below must exist:\
\n\n$EDIR_PATH"
return 1
}
return 0
}
################ Info Section - PERMS ###########################
set APP_GEN_G(PERMS_INFO) "
Actions performed during the 'Set file permissions' stage:
The following directories are set to rwxrwxrwx permissions
recursively:
share - recursive
fw - recursive
hosts - recursive
logs - recursive
tmp - recursive
sys/scripts - Non recursive
"
if { $VPIG(OS) == "nt" } {
regsub rwxrwxrwx $APP_GEN_G(PERMS_INFO) full APP_GEN_G(PERMS_INFO)
}
#####################################################################
proc app_gen_perms_cb {MODE} {
global VPIG
global APP_GEN_G
if { $MODE == "Standard" && $APP_GEN_G(INSTALL_TYPE) != "full" } {
return "undone"
}
set VER_DIRS [list \
share -R 1 \
fw -R 0 \
hosts -R 1 \
logs -R 1 \
tmp -R 1 \
sys/scripts "" 1 ]
set ROOT_MODE error
if { $MODE != "Standard" } {
set ROOT_MODE warning
}
if { ! [tku_is_root $ROOT_MODE] } {
return "error"
}
foreach {DIR RECURSE MANDATORY} $VER_DIRS {
set PATH [file join $APP_GEN_G(DEST_PATH) $DIR]
if { ! [file exists $PATH] } {
if { $MODE == "Custom" } { set MANDATORY 0 }
switch -- $MANDATORY {
1 {
tku_popup_message error ok \
"Directory does not exist\n$PATH"
return "error"
}
0 {
continue
}
default {
bgerror "Switch error app_gen.ins (3)"
}
}
}
set CHMOD $VPIG(CHMOD)
set CHMOD_COMMAND "$CHMOD $RECURSE 0777 $PATH"
set TITLE "Opening permissions for $DIR..."
set STATUS [tku_long_command \
$CHMOD_COMMAND $TITLE $VPIG(WMESSAGE) abort]
if {$STATUS != "ok"} {
return $STATUS
}
}
return "ok"
}
################ Info Section - STARTUP ###########################
if { $VPIG(OS) == "nt" } {
set APP_GEN_G(STARTUP_INFO) "
Actions performed during the 'Update startup files' stage:
- NuTCRACKER service is stopped, if running
- Unix scripting environment is unpacked into /bin & /usr
- Required dll's and exe's are copied to \$WINNT/system32
- NuTCRACKER is installed as an NT service
- The DSD dongle driver is installed (server only)
- System environment variables are set
- /tmp directory is created
- gnd service is installed (server only)
- Initial .cshrc file is copied to home directory
- Frontline taskbar shortcuts are created
"
} else {
set APP_GEN_G(STARTUP_INFO) "
Actions performed during the 'Update startup files' stage:
- The system startup file is updated with commands to automatically
start the Genesis daemon process (gnd).
- A user startup file is created which sets up some mandatory
environment variables and aliases. The file has to be 'sourced'
for each system user.
Note that in this file the environment variable PCMAP is set (except for NT).
This will cause the application to run in private colormap,
thus assuring that the color allocation will not conflict with
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -