user19698007
user19698007

Reputation:

How can I sign rpm packages with a loop in an expect script

I do not know if this question was already made somewhere, please be patient with me. I'm compiling asterisk in a CI Job (Gitlab) and I want to sign all rpm packages with my own GPG key. For that I have this expect script:

#!/usr/bin/expect -f

foreach files [glob *] {
  set password [lindex $argv 0]
  set files [lrange $argv 1 1]
  spawn rpm --define "_gpg_name <[email protected]>" --addsign $files
  expect "Enter pass phrase:"
  send -- "$password\r"
  expect eof
  exp_continue
}

I want to execute this as a loop in the CI Job:

 - |+
      for item in $(ls -l | tr -s " " | cut -d " " -f 9)
      do
        expect -d ${CI_PROJECT_DIR}/sign.exp ${GPG_PASSWD} $item
      done

Both variables are defined in Gitlab. Every time I run the job, I get the following error:

spawn rpm --define _gpg_name <[email protected]> --addsign asterisk-voicemail-plain-debuginfo-18.12.1-1.el8.x86_64.rpm
parent: waiting for sync byte
parent: telling child to go ahead
parent: now unsynchronized from child
spawn: returns {122292}

expect: does "" (spawn_id exp4) match glob pattern "Enter pass phrase:"? no
asterisk-voicemail-plain-debuginfo-18.12.1-1.el8.x86_64.rpm:

expect: does "asterisk-voicemail-plain-debuginfo-18.12.1-1.el8.x86_64.rpm:\r\n" (spawn_id exp4) match glob pattern "Enter pass phrase:"? no
expect: read eof
expect: set expect_out(spawn_id) "exp4"
expect: set expect_out(buffer) "asterisk-voicemail-plain-debuginfo-18.12.1-1.el8.x86_64.rpm:\r\n"
send: sending "xxxxxxxxxxxxx\r" to { exp4 send: spawn id exp4 not open
    while executing
"send -- "$password\r""
    ("foreach" body line 6)
    invoked from within
"foreach files [glob *] {
  set password [lindex $argv 0]
  set files [lrange $argv 1 1]
  spawn rpm --define "_gpg_name <[email protected]>" --add..."
    (file "../sign.exp" line 3)

I'd appreciate any suggestion here. Ok, I got errors but when I check the rpm package, I can see that the package is signed.

Thank you in advance for your help.

Upvotes: 0

Views: 304

Answers (0)

Related Questions