github.com/containers/libpod@v1.9.4-0.20220419124438-4284fd425507/contrib/cirrus/setup_environment.sh (about) 1 #!/bin/bash 2 3 set -e 4 5 source $(dirname $0)/lib.sh 6 7 req_env_var USER HOME GOSRC SCRIPT_BASE SETUP_MARKER_FILEPATH 8 9 # Ensure this script only executes successfully once and always logs ending timestamp 10 if [[ -e "$SETUP_MARKER_FILEPATH" ]]; then 11 show_env_vars 12 exit 0 13 fi 14 15 exithandler() { 16 RET=$? 17 echo "." 18 echo "$(basename $0) exit status: $RET" 19 [[ "$RET" -eq "0" ]] && date +%s >> "$SETUP_MARKER_FILEPATH" 20 show_env_vars 21 [[ "$RET" -eq "0" ]] || warn "Non-zero exit caused by error ABOVE env. var. display." 22 } 23 trap exithandler EXIT 24 25 # Verify basic dependencies 26 for depbin in go rsync unzip sha256sum curl make python3 git 27 do 28 if ! type -P "$depbin" &> /dev/null 29 then 30 echo "***** WARNING: $depbin binary not found in $PATH *****" 31 fi 32 done 33 34 # Sometimes environment setup needs to vary between distros 35 # Note: This should only be used for environment variables, and temporary workarounds. 36 # Anything externally dependent, should be made fixed-in-time by adding to 37 # contrib/cirrus/packer/*_setup.sh to be incorporated into VM cache-images 38 # (see docs). 39 cd "${GOSRC}/" 40 case "${OS_RELEASE_ID}" in 41 ubuntu) 42 ;; 43 fedora) 44 # All SELinux distros need this for systemd-in-a-container 45 setsebool container_manage_cgroup true 46 if [[ "$ADD_SECOND_PARTITION" == "true" ]]; then 47 bash "$SCRIPT_BASE/add_second_partition.sh" 48 fi 49 50 warn "Switching io scheduler to 'deadline' to avoid RHBZ 1767539" 51 warn "aka https://bugzilla.kernel.org/show_bug.cgi?id=205447" 52 echo "mq-deadline" > /sys/block/sda/queue/scheduler 53 cat /sys/block/sda/queue/scheduler 54 55 if [[ "$ADD_SECOND_PARTITION" == "true" ]]; then 56 bash "$SCRIPT_BASE/add_second_partition.sh" 57 fi 58 59 warn "Forcing systemd cgroup manager" 60 X=$(echo "export CGROUP_MANAGER=systemd" | \ 61 tee -a /etc/environment) && eval "$X" && echo "$X" 62 ;; 63 centos) # Current VM is an image-builder-image no local podman/testing 64 echo "No further setup required for VM image building" 65 exit 0 66 ;; 67 *) bad_os_id_ver ;; 68 esac 69 70 # Reload to incorporate any changes from above 71 source "$SCRIPT_BASE/lib.sh" 72 73 case "$CG_FS_TYPE" in 74 tmpfs) 75 warn "Forcing testing with runc instead of crun" 76 X=$(echo "export OCI_RUNTIME=/usr/bin/runc" | \ 77 tee -a /etc/environment) && eval "$X" && echo "$X" 78 ;; 79 cgroup2fs) 80 # This is necessary since we've built/installed from source, which uses runc as the default. 81 warn "Forcing testing with crun instead of runc" 82 X=$(echo "export OCI_RUNTIME=/usr/bin/crun" | \ 83 tee -a /etc/environment) && eval "$X" && echo "$X" 84 85 if [[ "$MOD_LIBPOD_CONF" == "true" ]]; then 86 warn "Updating runtime setting in repo. copy of libpod.conf" 87 sed -i -r -e 's/^runtime = "runc"/runtime = "crun"/' $GOSRC/libpod.conf 88 git diff $GOSRC/libpod.conf 89 fi 90 91 if [[ "$OS_RELEASE_ID" == "fedora" ]]; then 92 warn "Upgrading to the latest crun" 93 # Normally not something to do for stable testing 94 # but crun is new, and late-breaking fixes may be required 95 # on short notice 96 dnf update -y crun 97 fi 98 ;; 99 *) 100 die 110 "Unsure how to handle cgroup filesystem type '$CG_FS_TYPE'" 101 ;; 102 esac 103 104 # Must execute before possible setup_rootless() 105 make install.tools 106 107 case "$SPECIALMODE" in 108 none) 109 [[ -n "$CROSS_PLATFORM" ]] || \ 110 remove_packaged_podman_files 111 ;; 112 endpoint) 113 remove_packaged_podman_files 114 ;; 115 bindings) 116 remove_packaged_podman_files 117 ;; 118 rootless) 119 # Only do this once, even if ROOTLESS_USER (somehow) changes 120 if ! grep -q 'ROOTLESS_USER' /etc/environment 121 then 122 X=$(echo "export ROOTLESS_USER='${ROOTLESS_USER:-some${RANDOM}dude}'" | \ 123 tee -a /etc/environment) && eval "$X" && echo "$X" 124 X=$(echo "export SPECIALMODE='${SPECIALMODE}'" | \ 125 tee -a /etc/environment) && eval "$X" && echo "$X" 126 X=$(echo "export TEST_REMOTE_CLIENT='${TEST_REMOTE_CLIENT}'" | \ 127 tee -a /etc/environment) && eval "$X" && echo "$X" 128 setup_rootless 129 fi 130 remove_packaged_podman_files 131 ;; 132 in_podman) # Assumed to be Fedora 133 $SCRIPT_BASE/setup_container_environment.sh 134 ;; 135 *) 136 die 111 "Unsupported \$SPECIALMODE: $SPECIALMODE" 137 esac 138 139 install_test_configs