/usr/share/cmake/Modules/ManageUpload.cmake is in cmake-fedora 2.5.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 | # - Manage upload source archive to hosting site
# cmake-fedora can upload source archive to hosting site by
# scp, sftp or any other command.
#
# Included Modules:
# - ManageMessage
# - ManageVariable
#
# This module defines following functions:
# MANAGE_UPLOAD_TARGET(<targetName>
# COMMAND <program> ...
# [COMMENT <comment>]
# [ADD_CUSTOM_TARGET_ARGS <arg> ...]
# )
# - Make an upload target using arbitrary command.
# If COMMAND program exists the target <targetName> will be created;
# if not, a M_OFF message is shown and target will not be created.
# * Parameters:
# + targetName: target for use this command.
# + COMMAND program ... : Upload command and arguments
# + COMMENT comment (Optional) Comment when target is being built.
# Default: "<targetName>: Upload with <program> ..."
# + ADD_CUSTOM_TARGET_ARGS <arg> ...: (Optional) Other arguments to be
# passed to ADD_CUSTOM_TARGET.
# * Targets:
# + <targetName>
#
# MANAGE_UPLOAD_SCP(<targetName>
# HOST_URL <url>
# [USER <user>] [UPLOAD_FILES <file> ...] [DEPENDS <file> ...]
# [REMOTE_DIR <dir>] [OPTIONS <options>]
# [COMMENT <comment>]
# [ADD_CUSTOM_TARGET_ARGS <arg> ...]
# )
# - Make an upload target using scp.
# This functions check whether scp exists, see MANAGE_UPLOAD_TARGET
# for detailed behavior.
# * Parameters:
# + targetName: target for use this command.
# + HOST_URL url: scp server.
# + USER user: (Optional) scp user.
# Default: Environment variable $USER.
# + UPLOAD_FILES file ... : (Optional) Files to be uploaded.
# This will also tell cmake the build to those files,
# thus, <targetName> depends on those files.
# Default: ${SOURCE_ARCHIVE_FILE}
# + DEPENDS file ...: (Optional) Files that <targetName> should depends on,
# but no need to upload.
# + REMOTE_DIR dir: (Optional) Directory on the server.
# + OPTIONS options: (Optional) scp options.
# + COMMENT comment (Optional) Comment when target is being built.
# Default: "<targetName>: Upload with scp [<options>] user@url:dir/file1 ..."
# + ADD_CUSTOM_TARGET_ARGS <arg> ...: (Optional) Other arguments to be
# passed to ADD_CUSTOM_TARGET.
# * Targets:
# + <targetName>
#
# MANAGE_UPLOAD_SFTP(<targetName>
# HOST_URL <url>
# [BATCH <batchFile>]
# [USER <user>] [UPLOAD_FILES <file> ...] [DEPENDS <file> ...]
# [REMOTE_DIR <dir>] [OPTIONS <options>]
# [COMMENT <comment>]
# [ADD_CUSTOM_TARGET_ARGS <arg> ...]
# )
# - Make an upload target using sftp.
# This functions check whether sftp exists, see MANAGE_UPLOAD_TARGET
# for detailed behavior.
# * Parameters:
# + targetName: target for use this command.
# + HOST_URL url: sftp server.
# + BATCH batchFile: (Optional) File of sftp batch command.
# If not specified, a batch file will be generated at
# ${CMAKE_CURRENT_BINARY_DIR}/<targetName>-sftp-batch
# + USER user: (Optional) sftp user.
# Default: Environment variable $USER.
# + UPLOAD_FILES file ... : (Optional) Files to be uploaded.
# This will also tell cmake the build to those files,
# thus, <targetName> depends on those files.
# Default: ${SOURCE_ARCHIVE_FILE}
# + DEPENDS file ...: (Optional) Files that <targetName> should depends on,
# but no need to upload.
# + REMOTE_DIR dir: (Optional) Directory on the server.
# + OPTIONS options: (Optional) sftp options.
# + COMMENT comment (Optional) Comment when target is being built.
# Default: "<targetName>: Upload with sftp [<options>] user@url/dir/file1 ..."
# + ADD_CUSTOM_TARGET_ARGS <arg> ...: (Optional) Other arguments to be
# passed to ADD_CUSTOM_TARGET.
# * Targets:
# + <targetName>
#
#
# MANAGE_UPLOAD_FEDORAHOSTED(<targetName>
# [USER <user>] [UPLOAD_FILES <file> ...] [DEPENDS <file> ...]
# [OPTIONS <options>]
# [COMMENT <comment>]
# [ADD_CUSTOM_TARGET_ARGS <arg> ...]
# )
# - Make an upload target to fedora hosted.
# This functions check whether scp exists, see MANAGE_UPLOAD_TARGET
# for detailed behavior.
# * Parameters:
# + targetName: target for use this command.
# + USER user: (Optional) scp user.
# Default: Environment variable $USER.
# + UPLOAD_FILES file ... : (Optional) Files to be uploaded.
# This will also tell cmake the build to those files,
# thus, <targetName> depends on those files.
# Default: ${SOURCE_ARCHIVE_FILE}
# + DEPENDS file ...: (Optional) Files that <targetName> should depends on,
# but no need to upload.
# + OPTIONS options: (Optional) scp options.
# + COMMENT comment (Optional) Comment when target is being built.
# Default: "<targetName>: Upload with scp [<options>] user@url:dir/file1 ..."
# + ADD_CUSTOM_TARGET_ARGS <arg> ...: (Optional) Other arguments to be
# passed to ADD_CUSTOM_TARGET.
# * Targets:
# + <targetName>
#
# MANAGE_UPLOAD_SOURCEFORGE(<targetName>
# [BATCH <batchFile>]
# [USER <user>] [UPLOAD_FILES <file> ...] [DEPENDS <file> ...]
# [OPTIONS <options>]
# [COMMENT <comment>]
# [ADD_CUSTOM_TARGET_ARGS <arg> ...]
# )
# - Make an upload target using sftp.
# This functions check whether sftp exists, see MANAGE_UPLOAD_TARGET
# for detailed behavior.
# * Parameters:
# + targetName: target for use this command.
# + BATCH batchFile: (Optional) File of sftp batch command.
# If not specified, a batch file will be generated at
# ${CMAKE_CURRENT_BINARY_DIR}/<targetName>-sftp-batch
# + USER user: (Optional) sftp user.
# Default: Environment variable $USER.
# + UPLOAD_FILES file ... : (Optional) Files to be uploaded.
# This will also tell cmake the build to those files,
# thus, <targetName> depends on those files.
# Default: ${SOURCE_ARCHIVE_FILE}
# + DEPENDS file ...: (Optional) Files that <targetName> should depends on,
# but no need to upload.
# + OPTIONS options: (Optional) sftp options.
# + COMMENT comment (Optional) Comment when target is being built.
# Default: "<targetName>: Upload with sftp [<options>] user@url/dir/file1 ..."
# + ADD_CUSTOM_TARGET_ARGS <arg> ...: (Optional) Other arguments to be
# passed to ADD_CUSTOM_TARGET.
# * Targets:
# + <targetName>
#
# MANAGE_UPLOAD_FEDORAHOSTED(targetName
# [USER user] [UPLOAD_FILES files] [OPTIONS options] [DEPENDS files]
# [COMMENT comments])
# - Make an upload target for uploading to FedoraHosted.
# Parameters:
# + targetName: target name in make.
# + USER user: scp user. Note that if USER is used but user is not defined.
# It produces M_OFF warning.
# + UPLOAD_FILES: Files to be uploaded. This will be in DEPENDS list.
# + OPTIONS options: scp options.
# + DEPENDS files: other files that should be in DEPENDS list.
# + COMMENT comments: Comment to be shown when building the target.
#
# MANAGE_UPLOAD_SOURCEFORGE(targetName [BATCH batchFile]
# [USER user] [UPLOAD_FILES files] [OPTIONS options] [DEPENDS files]
# [COMMENT comments])
# [UPLOAD_FILES files] [REMOTE_DIR remoteDir]
# [UPLOAD_OPTIONS options] [DEPENDS files])
# - Make an upload target for uploading to SourceForge
# Parameters:
# + targetName: target name in make.
# + BATCH batchFile to be used in sftp. (sftp -b )
# + USER user: sftp user. Note that if USER is used but user is not defined.
# It produces M_OFF warning.
# + UPLOAD_FILES: Files to be uploaded. This will be in DEPENDS list.
# + OPTIONS options: sftp options.
# + DEPENDS files: other files that should be in DEPENDS list.
# + COMMENT comments: Comment to be shown when building the target.
#
#
IF(DEFINED _MANAGE_UPLOAD_CMAKE_)
RETURN()
ENDIF()
SET(_MANAGE_UPLOAD_CMAKE_ "DEFINED")
INCLUDE(ManageMessage)
INCLUDE(ManageString)
INCLUDE(ManageVariable)
FUNCTION(MANAGE_UPLOAD_TARGET targetName)
SET(_validOptions "COMMAND" "COMMENT" "ADD_CUSTOM_TARGET_ARGS")
VARIABLE_PARSE_ARGN(_o _validOptions ${ARGN})
LIST(GET _o_COMMAND 0 _cmd)
FIND_PROGRAM_ERROR_HANDLING(${targetName}_UPLOAD_EXECUTABLE
ERROR_MSG " Upload target ${targetName} disabled."
ERROR_VAR _upload_target_missing_dependency
VERBOSE_LEVEL ${M_OFF}
"${_cmd}"
)
IF("${_o_COMMENT}" STREQUAL "")
SET(_o "${targetName}: Upload with ${_o_COMMAND}")
ENDIF()
IF(NOT _upload_target_missing_dependency)
ADD_CUSTOM_TARGET(${targetName}
COMMAND ${_o_COMMAND}
COMMENT "${_o_COMMENT}"
${_o_ADD_CUSTOM_TARGET_ARGS}
)
ENDIF()
ENDFUNCTION(MANAGE_UPLOAD_TARGET targetName)
## Internal
FUNCTION(MANAGE_UPLOAD_MAKE_URL var user url)
IF(NOT "${user}" STREQUAL "")
SET(_str "${user}@${url}")
ELSE()
SET(_str "${url}")
ENDIF()
SET(${var} "${_str}" PARENT_SCOPE)
ENDFUNCTION(MANAGE_UPLOAD_MAKE_URL)
FUNCTION(MANAGE_UPLOAD_SCP targetName)
SET(_validOptions "HOST_URL" "USER"
"UPLOAD_FILES" "DEPENDS" "REMOTE_DIR" "OPTIONS" "COMMENT"
"ADD_CUSTOM_TARGET_ARGS"
)
VARIABLE_PARSE_ARGN(_o _validOptions ${ARGN})
IF("${_o_HOST_URL}" STREQUAL "")
M_MSG(${M_ERROR} "HOST_URL is required.")
ENDIF()
IF("${_o_UPLOAD_FILES}" STREQUAL "")
SET(_o_UPLOAD_FILES "${SOURCE_ARCHIVE_FILE}")
ENDIF()
MANAGE_UPLOAD_MAKE_URL(_uploadUrl "${_o_USER}" "${_o_HOST_URL}")
IF(NOT "${_o_REMOTE_DIR}" STREQUAL "")
STRING_APPEND(_uploadUrl ":${_o_REMOTE_DIR}")
ENDIF()
IF("${_o_COMMENT}" STREQUAL "")
SET(_o "${targetName}: Upload with scp ${_o_OPTIONS} ${_o_UPLOAD_FILES} ${_uploadUrl}")
ENDIF()
MANAGE_UPLOAD_TARGET(${targetName}
COMMAND scp ${_o_OPTIONS} ${_o_UPLOAD_FILES} ${_uploadUrl}
DEPENDS ${_o_UPLOAD_FILES} ${_o_DEPENDS}
COMMENT "${_o_COMMENTS}"
ADD_CUSTOM_TARGET_ARGS VERBATIM ${_o_ADD_CUSTOM_TARGET_ARGS}
)
ENDFUNCTION(MANAGE_UPLOAD_SCP fileAlias)
FUNCTION(MANAGE_UPLOAD_SFTP targetName)
SET(_validOptions "HOST_URL" "USER"
"BATCH"
"UPLOAD_FILES" "DEPENDS" "REMOTE_DIR" "OPTIONS" "COMMENT"
"ADD_CUSTOM_TARGET_ARGS"
)
VARIABLE_PARSE_ARGN(_o _validOptions ${ARGN})
IF("${_o_HOST_URL}" STREQUAL "")
M_MSG(${M_ERROR} "HOST_URL is required.")
ENDIF()
IF("${_o_UPLOAD_FILES}" STREQUAL "")
SET(_o_UPLOAD_FILES "${SOURCE_ARCHIVE_FILE}")
ENDIF()
MANAGE_UPLOAD_MAKE_URL(_uploadUrl "${_o_USER}" "${_o_HOST_URL}")
## Generate batch
IF("${_o_BATCH}" STREQUAL "")
SET(_o_BATCH "${CMAKE_CURRENT_BINARY_DIR}/${targetName}-sftp-batch")
FILE(WRITE "${_o_BATCH}" "pwd\n")
FOREACH(_f ${_o_UPLOAD_FILES})
FILE(APPEND "${_o_BATCH}" "put -p ${_f} ${_o_REMOTE_DIR}\n")
ENDFOREACH()
FILE(APPEND "${_o_BATCH}" "bye\n")
ENDIF()
IF("${_o_COMMENT}" STREQUAL "")
SET(_o "${targetName}: Upload with scp ${_o_OPTIONS} ${_o_UPLOAD_FILES} ${_uploadUrl}")
ENDIF()
MANAGE_UPLOAD_TARGET(${targetName}
COMMAND sftp -b ${_o_BATCH} ${_o_OPTIONS} ${_uploadUrl}
DEPENDS ${_o_UPLOAD_FILES} ${_o_DEPENDS}
COMMENT "${_o_COMMENTS}"
ADD_CUSTOM_TARGET_ARGS VERBATIM ${_o_ADD_CUSTOM_TARGET_ARGS}
)
ENDFUNCTION(MANAGE_UPLOAD_SFTP targetName)
FUNCTION(MANAGE_UPLOAD_FEDORAHOSTED targetName)
MANAGE_UPLOAD_SCP(${targetName}
HOST_URL "fedorahosted.org" REMOTE_DIR "${PROJECT_NAME}" ${ARGN}
)
ENDFUNCTION(MANAGE_UPLOAD_FEDORAHOSTED)
FUNCTION(MANAGE_UPLOAD_SOURCEFORGE targetName)
MANAGE_UPLOAD_SFTP(${targetName}
HOST_URL "frs.sourceforge.net"
REMOTE_DIR "/home/frs/project/${PROJECT_NAME}" ${ARGN}
)
ENDFUNCTION(MANAGE_UPLOAD_SOURCEFORGE)
|