diff --git a/.SRCINFO b/.SRCINFO index daaf8c1614de..f4176d704851 100644 --- a/.SRCINFO +++ b/.SRCINFO @@ -1,8 +1,8 @@ pkgbase = azcopy pkgdesc = A command-line utility designed for copying data to/from Microsoft Azure pkgver = 10.22.0 - pkgrel = 1 - url = https://docs.microsoft.com/en-us/azure/storage/common/storage-use-azcopy + pkgrel = 2 + url = https://github.com/Azure/azure-storage-azcopy arch = x86_64 arch = i686 arch = arm @@ -11,9 +11,12 @@ pkgbase = azcopy arch = aarch64 license = MIT makedepends = go - makedepends = git - replaces = azcopy-10 + depends = glibc source = azcopy-10.22.0.tar.gz::https://github.com/Azure/azure-storage-azcopy/archive/v10.22.0.tar.gz + source = remove-version-check.patch + source = fix-lifecyclemgr-nil-error.patch sha512sums = e066a949098ba03770691cf7686e28c1adfdb8dca36f09933a0c5c3cde9dbd24e7e41ac4bc95c0bb35f3e01d2c68de75628aebae173f0e8d676be683965fcebf + sha512sums = d436770cf67213fd7118992d6c04a06e5604482b24213441296f2e18fe4653301652958019f7efeb460e54e3b673feb4cf5b1228d893ee39a81f55c9c0799e94 + sha512sums = 524a0f75c3a736623fdf344f8b1d406557ed34c3582958f1a3c3ca222931b3edc0f727acf04d73f877951163e62e1ca3441bf579afef491bdde037901273ff90 pkgname = azcopy diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000000..3ade5966566a --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +* +!.gitignore +!PKGBUILD +!.SRCINFO +!Makefile +!remove-version-check.patch +!fix-lifecyclemgr-nil-error.patch diff --git a/PKGBUILD b/PKGBUILD index d674ffd54398..826ec823d036 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -1,3 +1,4 @@ +# Maintainer: Carl Smedstad # Maintainer: Xuanrui Qi # Maintainer: Fabio 'Lolix' Loli # Maintainer: Jens Heremans @@ -5,27 +6,79 @@ pkgname=azcopy pkgver=10.22.0 -pkgrel=1 +pkgrel=2 pkgdesc="A command-line utility designed for copying data to/from Microsoft Azure" arch=('x86_64' 'i686' 'arm' 'armv6h' 'armv7h' 'aarch64') -url="https://docs.microsoft.com/en-us/azure/storage/common/storage-use-azcopy" +url="https://github.com/Azure/azure-storage-azcopy" license=('MIT') -makedepends=('go' 'git') -replaces=('azcopy-10') -source=("${pkgname}-${pkgver}.tar.gz::https://github.com/Azure/azure-storage-azcopy/archive/v${pkgver}.tar.gz") -sha512sums=('e066a949098ba03770691cf7686e28c1adfdb8dca36f09933a0c5c3cde9dbd24e7e41ac4bc95c0bb35f3e01d2c68de75628aebae173f0e8d676be683965fcebf') +depends=('glibc') +makedepends=('go') +source=( + "${pkgname}-${pkgver}.tar.gz::$url/archive/v${pkgver}.tar.gz" + "remove-version-check.patch" + "fix-lifecyclemgr-nil-error.patch" +) +sha512sums=( + 'e066a949098ba03770691cf7686e28c1adfdb8dca36f09933a0c5c3cde9dbd24e7e41ac4bc95c0bb35f3e01d2c68de75628aebae173f0e8d676be683965fcebf' + 'd436770cf67213fd7118992d6c04a06e5604482b24213441296f2e18fe4653301652958019f7efeb460e54e3b673feb4cf5b1228d893ee39a81f55c9c0799e94' + '524a0f75c3a736623fdf344f8b1d406557ed34c3582958f1a3c3ca222931b3edc0f727acf04d73f877951163e62e1ca3441bf579afef491bdde037901273ff90' +) prepare() { - mkdir -p "${srcdir}/src/github.com/Azure" - mv "${srcdir}/azure-storage-azcopy-${pkgver}" "${srcdir}/src/github.com/Azure/azure-storage-azcopy" + cd "${srcdir}/azure-storage-azcopy-${pkgver}" + + # Due to the version check, each invocation takes ~8 seconds. See: + # https://github.com/Azure/azure-storage-azcopy/issues/2482 + patch --forward --strip=1 --input="$srcdir/remove-version-check.patch" + + # Fix intermittent nil pointer dereference in common/lifecyleMgr.go:375. + patch --forward --strip=1 --input="$srcdir/fix-lifecyclemgr-nil-error.patch" + + # Avoid downloading Go dependencies in build() by doing it here instead + go mod download -x } build() { - cd "${srcdir}/src/github.com/Azure/azure-storage-azcopy" - go build -buildmode=pie + cd "${srcdir}/azure-storage-azcopy-${pkgver}" + + export CGO_CPPFLAGS="$CPPFLAGS" + export CGO_CFLAGS="$CFLAGS" + export CGO_CXXFLAGS="$CXXFLAGS" + export CGO_LDFLAGS="$LDFLAGS" + export GOFLAGS="-buildmode=pie -trimpath -ldflags=-linkmode=external -mod=readonly -modcacherw" + + go build -v -o azcopy + + # Completions + ./azcopy completion bash > azcopy.bash + ./azcopy completion fish > azcopy.fish + ./azcopy completion zsh > azcopy.zsh +} + +check() { + cd "${srcdir}/azure-storage-azcopy-${pkgver}" + + # Skip failing tests - not sure why they fail. + _unit_tests=$( + go list ./... \ + | grep -v 'github.com/Azure/azure-storage-azcopy/v10/cmd' \ + | grep -v 'github.com/Azure/azure-storage-azcopy/v10/common' \ + | grep -v 'github.com/Azure/azure-storage-azcopy/v10/e2etest' \ + | grep -v 'github.com/Azure/azure-storage-azcopy/v10/ste' \ + | sort + ) + # shellcheck disable=SC2086 + go test $_unit_tests } package() { - install -Dm755 "${srcdir}/src/github.com/Azure/azure-storage-azcopy/azure-storage-azcopy" "${pkgdir}/usr/bin/azcopy" - install -Dm644 "${srcdir}/src/github.com/Azure/azure-storage-azcopy/LICENSE" "${pkgdir}/usr/share/licenses/$pkgname/LICENSE" + cd "${srcdir}/azure-storage-azcopy-${pkgver}" + + install -Dm755 azcopy "${pkgdir}/usr/bin/azcopy" + + install -Dm644 azcopy.bash "${pkgdir}/usr/share/bash-completion/completions/azcopy" + install -Dm644 azcopy.fish "${pkgdir}/usr/share/fish/vendor_completions.d/azcopy.fish" + install -Dm644 azcopy.zsh "${pkgdir}/usr/share/zsh/site-functions/_azcopy" + + install -Dm644 LICENSE "${pkgdir}/usr/share/licenses/$pkgname/LICENSE" } diff --git a/fix-lifecyclemgr-nil-error.patch b/fix-lifecyclemgr-nil-error.patch new file mode 100644 index 000000000000..4d432c080479 --- /dev/null +++ b/fix-lifecyclemgr-nil-error.patch @@ -0,0 +1,15 @@ +diff --git a/common/lifecyleMgr.go b/common/lifecyleMgr.go +index 57ba87d7..ed0a5f9e 100644 +--- a/common/lifecyleMgr.go ++++ b/common/lifecyleMgr.go +@@ -372,7 +372,9 @@ func (lcm *lifecycleMgr) Exit(o OutputBuilder, applicationExitCode ExitCode) { + exitCode: applicationExitCode, + } + +- AzcopyCurrentJobLogger.CloseLog() ++ if AzcopyCurrentJobLogger != nil { ++ AzcopyCurrentJobLogger.CloseLog() ++ } + if applicationExitCode != EExitCode.NoExit() { + // stall forever until the success message is printed and program exits + lcm.SurrenderControl() diff --git a/remove-version-check.patch b/remove-version-check.patch new file mode 100644 index 000000000000..bdab0764a7e8 --- /dev/null +++ b/remove-version-check.patch @@ -0,0 +1,54 @@ +diff --git a/cmd/root.go b/cmd/root.go +index 621c25e7..f3f8fa0d 100644 +--- a/cmd/root.go ++++ b/cmd/root.go +@@ -54,7 +54,6 @@ var azcopyAwaitContinue bool + var azcopyAwaitAllowOpenFiles bool + var azcopyScanningLogger common.ILoggerResetable + var azcopyCurrentJobID common.JobID +-var azcopySkipVersionCheck bool + var retryStatusCodes string + + type jobLoggerInfo struct { +@@ -161,15 +160,6 @@ var rootCmd = &cobra.Command{ + common.IncludeAfterFlagName, IncludeAfterDateFilter{}.FormatAsUTC(adjustedTime)) + jobsAdmin.JobsAdmin.LogToJobLog(startTimeMessage, common.LogInfo) + +- if !azcopySkipVersionCheck { +- // spawn a routine to fetch and compare the local application's version against the latest version available +- // if there's a newer version that can be used, then write the suggestion to stderr +- // however if this takes too long the message won't get printed +- // Note: this function is necessary for non-help, non-login commands, since they don't reach the corresponding +- // beginDetectNewVersion call in Execute (below) +- beginDetectNewVersion() +- } +- + if debugSkipFiles != "" { + for _, v := range strings.Split(debugSkipFiles, ";") { + if strings.HasPrefix(v, "/") { +@@ -201,16 +191,6 @@ func Execute(logPathFolder, jobPlanFolder string, maxFileAndSocketHandles int, j + if err := rootCmd.Execute(); err != nil { + glcm.Error(err.Error()) + } else { +- if !azcopySkipVersionCheck { +- // our commands all control their own life explicitly with the lifecycle manager +- // only commands that don't explicitly exit actually reach this point (e.g. help commands and login commands) +- select { +- case <-beginDetectNewVersion(): +- // noop +- case <-time.After(time.Second * 8): +- // don't wait too long +- } +- } + glcm.Exit(nil, common.EExitCode.Success()) + } + } +@@ -227,8 +207,6 @@ func init() { + rootCmd.PersistentFlags().StringVar(&cmdLineExtraSuffixesAAD, trustedSuffixesNameAAD, "", "Specifies additional domain suffixes where Azure Active Directory login tokens may be sent. The default is '"+ + trustedSuffixesAAD+"'. Any listed here are added to the default. For security, you should only put Microsoft Azure domains here. Separate multiple entries with semi-colons.") + +- rootCmd.PersistentFlags().BoolVar(&azcopySkipVersionCheck, "skip-version-check", false, "Do not perform the version check at startup. Intended for automation scenarios & airgapped use.") +- + // Note: this is due to Windows not supporting signals properly + rootCmd.PersistentFlags().BoolVar(&cancelFromStdin, "cancel-from-stdin", false, "Used by partner teams to send in `cancel` through stdin to stop a job.") +