Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bash: using expect to automate GPG signing

I am writing a bash script that automates the signing of RPM packages in a YUM repository. To accomplish this task, I use expect.

Here is my source code so far:

/usr/bin/expect <<EOD
spawn bash -c "rpm --resign ${NEW_REPO}/packages/*.rpm"
expect "Enter pass phrase:"
send "${GPG_PASS}\r"
expect eof
EOD

NEW_REPO is the path to the YUM repo, and GPG_PASS is the password for the GPG key.

For the most part, this works quite well and succeeds in signing packages.

The Problem: this code block only signs between 28-30 RPM packages even though the directory contains 42 packages. Manually signing the batch of RPM packages from the command line works perfectly, but the expect block in my script simply stops before it reaches all of the packages. Is this some wierd quirk of expect, or am I doing something completely wrong? Workarounds/suggestions are welcome.

Thanks

like image 531
scottysseus Avatar asked Mar 16 '23 10:03

scottysseus


1 Answers

It's probably just timing out. Try adding:

set timeout 600

Or if you want to wait forever:

set timeout -1

As the first line of your expect script.

like image 78
Sean Bright Avatar answered Mar 24 '23 15:03

Sean Bright