diff --git a/libraries/filesystem b/libraries/filesystem index 850270b..9c7dfb5 100644 --- a/libraries/filesystem +++ b/libraries/filesystem @@ -63,6 +63,31 @@ function download() { return ${RESULT} } +#------------------------------------------------------------------------------- +# Generates a contents file +# Parameters: %contentsfile% %archive% +#------------------------------------------------------------------------------- +function generateContents() { + local OUTPUT="${1}" + local ARCHIVE="${2}" + [ ! -f ${ARCHIVE} ] && return 1 + case ${ARCHIVE} in + *.iso) + isoinfo -l -i ${ARCHIVE} > ${OUTPUT} || return 1 + ;; + *.tar) + tar -tvf ${ARCHIVE} > ${OUTPUT} || return 1 + ;; + *.tar.gz|*.tar.xz|*.tar.z) + tar -tvzf ${ARCHIVE} > ${OUTPUT} || return 1 + ;; + *.tar.bz2) + tar -tvjf ${ARCHIVE} > ${OUTPUT} || return 1 + ;; + esac + return 0 +} + #------------------------------------------------------------------------------- # Generates a hash file # Parameters: %digestfile% %filelist% diff --git a/libraries/repositories b/libraries/repositories index a3c96f2..ca01ffb 100644 --- a/libraries/repositories +++ b/libraries/repositories @@ -21,6 +21,25 @@ function mirrorGit() { return 0 } +#------------------------------------------------------------------------------- +# Creates a local mirror of specified HG repository +# Parameters: %dest_directory% %address% [%username%] +#------------------------------------------------------------------------------- +function mirrorMercurial() { + local DIRECTORY="${1}" + local ADDRESS="${2}" + local USER="${3:-root}" + if [ -d ${DIRECTORY} ]; then + cd ${DIRECTORY} + run "su ${USER} -s \"/bin/sh\" -c \"hg pull --update -e \ + ${BINDIR}/ssh_wrapper.sh\"" || return 1 + else + run "su ${USER} -s \"/bin/sh\" -c \"hg clone ${ADDRESS} ${DIRECTORY} \ + -e ${BINDIR}/ssh_wrapper.sh\"" || return 1 + fi + return 0 +} + #------------------------------------------------------------------------------- # Creates a local mirror of specified repository regardless its protocol # Parameters: %dest_directory% %protocol% %address% [%username%] @@ -30,6 +49,9 @@ function mirrorRepository() { [Gg][Ii][Tt]) mirrorGit "${1}" "${3}" "${4}" && return 0 ;; + [Hh][Gg]) + mirrorMercurial "${1}" "${3}" "${4}" && return 0 + ;; [Rr][Ss][Yy][Nn][Cc]) mirrorRsync "${1}" "${3}" "${4}" && return 0 ;;