| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 |
|
| 20 | |
| 21 | |
| 22 | |
| 23 |
|
| 24 | channels_file="channels-test-$$.scm"
|
| 25 | log_file="log-test-$$.log"
|
| 26 | trap "rm -f $channels_file $log_file" EXIT
|
| 27 |
|
| 28 | cat > "$channels_file" <<EOF
|
| 29 | (system "echo rm -rf /")
|
| 30 | %default-channels
|
| 31 | EOF
|
| 32 |
|
| 33 | |
| 34 | |
| 35 | guix time-machine -C "$channels_file" && false
|
| 36 |
|
| 37 | cat > "$channels_file" <<EOF
|
| 38 | (use-modules (system foreign))
|
| 39 | %default-channels
|
| 40 | EOF
|
| 41 |
|
| 42 | |
| 43 | guix time-machine -C "$channels_file" && false
|
| 44 |
|
| 45 | |
| 46 | |
| 47 | cat > "$channels_file" <<EOF
|
| 48 | (use-modules (guix tests http)
|
| 49 | (guix diagnostics)
|
| 50 | (guix scripts time-machine))
|
| 51 |
|
| 52 | (define channels
|
| 53 | '(list (channel
|
| 54 | (name 'guix)
|
| 55 | (url "https://example.org/evil/guix.git")
|
| 56 | (branch "devel")
|
| 57 | (commit "cabba9e900d2350aef42e65643de78500b2aad06")
|
| 58 | (introduction
|
| 59 | (make-channel-introduction
|
| 60 | "badcafef1d5c170db68aa4bbfb77024fdc468ed3"
|
| 61 | (openpgp-fingerprint
|
| 62 | "CABB A9EE 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5"))))))
|
| 63 |
|
| 64 | (with-http-server (list (list 200 (object->string channels)))
|
| 65 | (let ((error (open-output-string)))
|
| 66 | (catch 'quit
|
| 67 | (lambda ()
|
| 68 | (parameterize ((guix-warning-port error))
|
| 69 | (guix-time-machine "-C" (%local-url) "--" "describe")
|
| 70 | (primitive-exit 1)))
|
| 71 | (lambda _
|
| 72 | (exit (->bool (string-contains (get-output-string error)
|
| 73 | "'guix' is not trusted")))))))
|
| 74 | EOF
|
| 75 | guix repl -- "$channels_file"
|
| 76 |
|
| 77 | |
| 78 | |
| 79 | |
| 80 | cat > "$channels_file" <<EOF
|
| 81 | (use-modules (guix tests http)
|
| 82 | (guix diagnostics)
|
| 83 | (guix scripts time-machine))
|
| 84 |
|
| 85 | (define channels
|
| 86 | '(list))
|
| 87 |
|
| 88 | (with-http-server (list (list 200 (object->string channels)))
|
| 89 | (let* ((error (open-output-string))
|
| 90 | (port (mkstemp "guix-channels-XXXXXX"))
|
| 91 | (file (port-filename port)))
|
| 92 | (write (quasiquote
|
| 93 | (downloaded-channels
|
| 94 | ,(%local-url)
|
| 95 | #:append
|
| 96 | (list
|
| 97 | (channel
|
| 98 | (name 'guix) ;; this is an untrusted channel
|
| 99 | (url ,(%local-url)) ;; url doesn't matter
|
| 100 | (branch "devel")
|
| 101 | (commit "cabba9e900d2350aef42e65643de78500b2aad06")
|
| 102 | (introduction
|
| 103 | (make-channel-introduction
|
| 104 | "badcafef1d5c170db68aa4bbfb77024fdc468ed3"
|
| 105 | (openpgp-fingerprint
|
| 106 | "CABB A9EE 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5"))))))) port)
|
| 107 | (close-port port)
|
| 108 | (catch 'quit
|
| 109 | (lambda ()
|
| 110 | (parameterize ((guix-warning-port error))
|
| 111 | (guix-time-machine "--allow-untrusted-channels=no" "-C" file "--" "describe")
|
| 112 | (primitive-exit 1)))
|
| 113 | (lambda _
|
| 114 | (delete-file file)
|
| 115 | (exit (->bool (string-contains (get-output-string error)
|
| 116 | "'guix' is not trusted")))))))
|
| 117 | EOF
|
| 118 | guix repl -- "$channels_file"
|
| 119 |
|
| 120 | |
| 121 | cat > "$channels_file" <<EOF
|
| 122 | (downloaded-channels "https://example.org/channels.scm")
|
| 123 | EOF
|
| 124 |
|
| 125 | guix time-machine -C "$channels_file" --max-indirections=0 2> "$log_file" && false
|
| 126 | grep "too many channel indirections" "$log_file"
|
| 127 |
|
| 128 | |
| 129 | |
| 130 | |
| 131 | cat > "$channels_file" <<EOF
|
| 132 | (use-modules (guix tests http)
|
| 133 | (guix diagnostics)
|
| 134 | (guix scripts time-machine))
|
| 135 |
|
| 136 | (define channels
|
| 137 | '(list (channel ;this channel lacks an introduction
|
| 138 | (name 'guix)
|
| 139 | (url "https://example.org/evil/guix.git")
|
| 140 | (commit "cabba9e900d2350aef42e65643de78500b2aad06"))))
|
| 141 |
|
| 142 | (with-http-server (list (list 200 (object->string channels)))
|
| 143 | (let* ((error (open-output-string))
|
| 144 | (port (mkstemp "guix-channels-XXXXXX"))
|
| 145 | (file (port-filename port)))
|
| 146 | (write (quasiquote (downloaded-channels ,(%local-url))) port)
|
| 147 | (close-port port)
|
| 148 | (catch 'quit
|
| 149 | (lambda ()
|
| 150 | (parameterize ((guix-warning-port error))
|
| 151 | (guix-time-machine "-C" file "--" "describe")
|
| 152 | (primitive-exit 1)))
|
| 153 | (lambda _
|
| 154 | (delete-file file)
|
| 155 | (exit (->bool (string-contains (get-output-string error)
|
| 156 | "cannot be authenticated")))))))
|
| 157 | EOF
|
| 158 | guix repl -- "$channels_file"
|
| 159 |
|
| 160 | cat > "$channels_file" <<EOF
|
| 161 | %default-channels
|
| 162 | EOF
|
| 163 |
|
| 164 | |
| 165 | mkdir -p "$XDG_CACHE_HOME/dot-config/guix"
|
| 166 | cat > "$XDG_CACHE_HOME/dot-config/guix/trusted-channels.scm" <<EOF
|
| 167 | (list)
|
| 168 | EOF
|
| 169 |
|
| 170 | |
| 171 | |
| 172 | XDG_CONFIG_HOME="$XDG_CACHE_HOME/dot-config" \
|
| 173 | guix time-machine -C "$channels_file" --allow-untrusted-channels=no 2> "$log_file" && false
|
| 174 | grep "'guix' is not trusted" "$log_file"
|
| 175 |
|
| 176 | if guile -c '(getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV)' 2> /dev/null
|
| 177 | then
|
| 178 | |
| 179 | |
| 180 | XDG_CONFIG_HOME="$XDG_CACHE_HOME/dot-config" \
|
| 181 | guix time-machine \
|
| 182 | -C swh:1:cnt:003e1e0c1b9b358082201332c926ae54e9549002 \
|
| 183 | 2> "$log_file" \
|
| 184 | && false
|
| 185 | grep "'guix' is not trusted" "$log_file"
|
| 186 | fi
|
| 187 |
|
| 188 | if [ -d "$abs_top_srcdir/.git" ] \
|
| 189 | || guile -c '(getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV)' 2> /dev/null
|
| 190 | then
|
| 191 | guix time-machine --version
|
| 192 | else
|
| 193 | echo "This test requires networking or a local Git checkout; skipping." >&2
|
| 194 | exit 77
|
| 195 | fi
|
| 196 |
|
| 197 | if [ -d "$abs_top_srcdir/.git" ]
|
| 198 | then
|
| 199 | |
| 200 | |
| 201 | EXTRA_OPTIONS="--url=$abs_top_srcdir"
|
| 202 | else
|
| 203 | EXTRA_OPTIONS=""
|
| 204 | fi
|
| 205 |
|
| 206 | |
| 207 | |
| 208 | guix time-machine -q --commit=v0.15.0 $EXTRA_OPTIONS -- describe && false
|
| 209 |
|
| 210 | true
|