Просмотр исходного кода

implement mirrorMercurial()

master
belliash 7 лет назад
Родитель
Сommit
f87b57fc97
2 измененных файлов: 47 добавлений и 0 удалений
  1. 25
    0
      libraries/filesystem
  2. 22
    0
      libraries/repositories

+ 25
- 0
libraries/filesystem Просмотреть файл

@@ -63,6 +63,31 @@ function download() {
63 63
 	return ${RESULT}
64 64
 }
65 65
 
66
+#-------------------------------------------------------------------------------
67
+# Generates a contents file
68
+# Parameters: %contentsfile% %archive%
69
+#-------------------------------------------------------------------------------
70
+function generateContents() {
71
+	local OUTPUT="${1}"
72
+	local ARCHIVE="${2}"
73
+	[ ! -f ${ARCHIVE} ] && return 1
74
+	case ${ARCHIVE} in
75
+		*.iso)
76
+			isoinfo -l -i ${ARCHIVE} > ${OUTPUT} || return 1
77
+			;;
78
+		*.tar)
79
+			tar -tvf ${ARCHIVE} > ${OUTPUT} || return 1
80
+			;;
81
+		*.tar.gz|*.tar.xz|*.tar.z)
82
+			tar -tvzf ${ARCHIVE} > ${OUTPUT} || return 1
83
+			;;
84
+		*.tar.bz2)
85
+			tar -tvjf ${ARCHIVE} > ${OUTPUT} || return 1
86
+			;;
87
+	esac
88
+	return 0
89
+}
90
+
66 91
 #-------------------------------------------------------------------------------
67 92
 # Generates a hash file
68 93
 # Parameters: %digestfile% %filelist%

+ 22
- 0
libraries/repositories Просмотреть файл

@@ -21,6 +21,25 @@ function mirrorGit() {
21 21
 	return 0
22 22
 }
23 23
 
24
+#-------------------------------------------------------------------------------
25
+# Creates a local mirror of specified HG repository
26
+# Parameters: %dest_directory% %address% [%username%]
27
+#-------------------------------------------------------------------------------
28
+function mirrorMercurial() {
29
+	local DIRECTORY="${1}"
30
+	local ADDRESS="${2}"
31
+	local USER="${3:-root}"
32
+	if [ -d ${DIRECTORY} ]; then
33
+		cd ${DIRECTORY}
34
+		run "su ${USER} -s \"/bin/sh\" -c \"hg pull --update -e \
35
+			${BINDIR}/ssh_wrapper.sh\"" || return 1
36
+	else
37
+		run "su ${USER} -s \"/bin/sh\" -c \"hg clone ${ADDRESS} ${DIRECTORY} \
38
+			-e ${BINDIR}/ssh_wrapper.sh\"" || return 1
39
+	fi
40
+	return 0
41
+}
42
+
24 43
 #-------------------------------------------------------------------------------
25 44
 # Creates a local mirror of specified repository regardless its protocol
26 45
 # Parameters: %dest_directory% %protocol% %address% [%username%]
@@ -30,6 +49,9 @@ function mirrorRepository() {
30 49
 		[Gg][Ii][Tt])
31 50
 			mirrorGit "${1}" "${3}" "${4}" && return 0
32 51
 			;;
52
+		[Hh][Gg])
53
+			mirrorMercurial "${1}" "${3}" "${4}" && return 0
54
+			;;
33 55
 		[Rr][Ss][Yy][Nn][Cc])
34 56
 			mirrorRsync "${1}" "${3}" "${4}" && return 0
35 57
 			;;

Загрузка…
Отмена
Сохранить