Skip to content

Commit 2e71786

Browse files
authored
Merge pull request #627 from robbat2/gentoo
Improve Python3 & Finding Moreutils Parallel
2 parents d95134c + 483298b commit 2e71786

File tree

4 files changed

+45
-20
lines changed

4 files changed

+45
-20
lines changed

share/github-backup-utils/ghe-backup-config

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,20 @@ ghe_parallel_check() {
7272
fi
7373

7474
# Some machines may have both moreutils parallel and GNU parallel installed.
75+
# Check some variants to find it
7576
GHE_PARALLEL_COMMAND="parallel"
76-
if [ -x "/usr/bin/parallel.moreutils" ]; then
77-
GHE_PARALLEL_COMMAND="/usr/bin/parallel.moreutils"
78-
fi
77+
local x
78+
for x in \
79+
/usr/bin/parallel.moreutils \
80+
/usr/bin/parallel_moreutils \
81+
/usr/bin/moreutils.parallel \
82+
/usr/bin/moreutils_parallel \
83+
; do
84+
if [ -x "${x}" ]; then
85+
GHE_PARALLEL_COMMAND="${x}"
86+
break
87+
fi
88+
done
7989

8090
# Check that the GHE_PARALLEL_COMMAND is pointing to moreutils parallel
8191
if ! $GHE_PARALLEL_COMMAND -h | grep -q "parallel \[OPTIONS\] command -- arguments"; then

test/bin/python

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,12 @@ cat >/dev/null
1717

1818
# verify the python compiles at least. if this fails then the python code passed
1919
# to -c failed basic syntax checks.
20+
# Compiler package ws removed in Py3
21+
# see https://www.python.org/dev/peps/pep-3108/#id53
22+
# The closest replacement is the ast package
23+
# https://docs.python.org/3/library/ast.html
2024
echo "$2" |
21-
/usr/bin/python2.7 -c "import sys; __import__('compiler').parse(sys.stdin.read())"
25+
/usr/bin/python3 -c "import sys; __import__('ast').parse(sys.stdin.read())"
2226

2327
# pretend we found zero processes.
2428
echo 0

test/test-ghe-restore.sh

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,7 @@ begin_test "ghe-restore cluster"
391391
(
392392
set -e
393393
rm -rf "$GHE_REMOTE_ROOT_DIR"
394+
setup_moreutils_parallel
394395
setup_remote_metadata
395396
setup_remote_cluster
396397
echo "cluster" > "$GHE_DATA_DIR/current/strategy"
@@ -402,21 +403,14 @@ begin_test "ghe-restore cluster"
402403
GHE_RESTORE_HOST=127.0.0.1
403404
export GHE_RESTORE_HOST
404405

405-
# CI servers may have moreutils parallel and GNU parallel installed. We need moreutils parallel.
406-
if [ -x "/usr/bin/parallel.moreutils" ]; then
407-
ln -sf /usr/bin/parallel.moreutils "$ROOTDIR/test/bin/parallel"
408-
fi
409-
410406
# run ghe-restore and write output to file for asserting against
411407
if ! ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then
412408
cat "$TRASHDIR/restore-out"
413409
: ghe-restore should have exited successfully
414410
false
415411
fi
416412

417-
if [ -h "$ROOTDIR/test/bin/parallel" ]; then
418-
unlink "$ROOTDIR/test/bin/parallel"
419-
fi
413+
cleanup_moreutils_parallel
420414

421415
# for debugging
422416
cat "$TRASHDIR/restore-out"
@@ -461,6 +455,7 @@ begin_test "ghe-restore missing directories or files from source snapshot displa
461455
# Tests the scenario where something exists in the database, but not on disk.
462456
set -e
463457
rm -rf "$GHE_REMOTE_ROOT_DIR"
458+
setup_moreutils_parallel
464459
setup_remote_metadata
465460
setup_remote_cluster
466461
echo "cluster" > "$GHE_DATA_DIR/current/strategy"
@@ -472,11 +467,6 @@ begin_test "ghe-restore missing directories or files from source snapshot displa
472467
GHE_RESTORE_HOST=127.0.0.1
473468
export GHE_RESTORE_HOST
474469

475-
# CI servers may have moreutils parallel and GNU parallel installed. We need moreutils parallel.
476-
if [ -x "/usr/bin/parallel.moreutils" ]; then
477-
ln -sf /usr/bin/parallel.moreutils "$ROOTDIR/test/bin/parallel"
478-
fi
479-
480470
# Tell dgit-cluster-restore-finalize and gist-cluster-restore-finalize to return warnings
481471
export GHE_DGIT_CLUSTER_RESTORE_FINALIZE_WARNING=1
482472
export GHE_GIST_CLUSTER_RESTORE_FINALIZE_WARNING=1
@@ -488,9 +478,7 @@ begin_test "ghe-restore missing directories or files from source snapshot displa
488478
false
489479
fi
490480

491-
if [ -h "$ROOTDIR/test/bin/parallel" ]; then
492-
unlink "$ROOTDIR/test/bin/parallel"
493-
fi
481+
cleanup_moreutils_parallel
494482

495483
# for debugging
496484
cat "$TRASHDIR/restore-out"

test/testlib.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,3 +431,26 @@ verify_all_restored_data() {
431431
# verify common data
432432
verify_common_data
433433
}
434+
435+
setup_moreutils_parallel() {
436+
# CI servers may have moreutils parallel and GNU parallel installed.
437+
# We need moreutils parallel
438+
local x
439+
for x in \
440+
/usr/bin/parallel.moreutils \
441+
/usr/bin/parallel_moreutils \
442+
/usr/bin/moreutils.parallel \
443+
/usr/bin/moreutils_parallel \
444+
; do
445+
if [ -x "${x}" ]; then
446+
ln -sf "${x}" "$ROOTDIR/test/bin/parallel"
447+
break
448+
fi
449+
done
450+
}
451+
452+
cleanup_moreutils_parallel() {
453+
if [ -h "$ROOTDIR/test/bin/parallel" ]; then
454+
unlink "$ROOTDIR/test/bin/parallel"
455+
fi
456+
}

0 commit comments

Comments
 (0)