1# rpmvercmp.at: rpm config link behavior tests 2 3AT_BANNER([RPM config symlink behavior]) 4 5AT_SETUP([config symlinks]) 6AT_KEYWORDS([install]) 7RPMDB_INIT 8 9for v in "1.0" "2.0"; do 10 runroot rpmbuild --quiet -bb \ 11 --define "ver $v" \ 12 --define "filedata foo" \ 13 --define "filetype link" \ 14 /data/SPECS/configtest.spec 15done 16 17# Install over existing config file 18AT_CHECK([ 19RPMDB_INIT 20cf="${RPMTEST}"/etc/my.conf 21rm -rf "${cf}"* 22 23ln -s "otherstuff" "${cf}" 24runroot rpm -U /build/RPMS/noarch/configtest-1.0-1.noarch.rpm 25readlink "${cf}" 26runroot rpm -e configtest 27readlink "${cf}.rpmorig" 28], 29[0], 30[foo 31otherstuff 32], 33[warning: /etc/my.conf saved as /etc/my.conf.rpmorig] 34) 35 36# Install over existing identical config link, no backup needed 37AT_CHECK([ 38RPMDB_INIT 39cf="${RPMTEST}"/etc/my.conf 40rm -rf "${cf}"* 41 42ln -s "foo" "${cf}" 43readlink "${cf}" 44runroot rpm -U /build/RPMS/noarch/configtest-1.0-1.noarch.rpm 45readlink "${cf}" 46runroot rpm -e configtest 47test ! -L "${cf}" 48], 49[0], 50[foo 51foo 52], 53[]) 54 55# Erase unmodified config link, no backup here 56AT_CHECK([ 57RPMDB_INIT 58cf="${RPMTEST}"/etc/my.conf 59rm -rf "${cf}"* 60 61runroot rpm -U /build/RPMS/noarch/configtest-1.0-1.noarch.rpm 62readlink "${cf}" 63runroot rpm -e configtest 64test ! -L "${cf}" 65], 66[0], 67[foo 68], 69[]) 70 71# Erase modified config link 72AT_CHECK([ 73RPMDB_INIT 74cf="${RPMTEST}"/etc/my.conf 75rm -rf "${cf}"* 76 77runroot rpm -U /build/RPMS/noarch/configtest-1.0-1.noarch.rpm 78readlink "${cf}" 79ln -sf "otherstuff" "${cf}" 80runroot rpm -e configtest 81readlink "${cf}.rpmsave" 82], 83[0], 84[foo 85otherstuff 86], 87[warning: /etc/my.conf saved as /etc/my.conf.rpmsave] 88) 89 90# Upgrade package with config link, no backup here 91AT_CHECK([ 92RPMDB_INIT 93cf="${RPMTEST}"/etc/my.conf 94rm -rf "${cf}"* 95 96runroot rpm -U /build/RPMS/noarch/configtest-1.0-1.noarch.rpm 97readlink "${cf}" 98runroot rpm -U /build/RPMS/noarch/configtest-2.0-1.noarch.rpm 99readlink "${cf}" 100], 101[0], 102[foo 103foo 104], 105[]) 106 107# 108# Upgrade package with config link, no backup here 109AT_CHECK([ 110RPMDB_INIT 111cf="${RPMTEST}"/etc/my.conf 112rm -rf "${cf}"* 113 114runroot rpm -U /build/RPMS/noarch/configtest-1.0-1.noarch.rpm 115runroot rpm -Uvv --fsmdebug /build/RPMS/noarch/configtest-2.0-1.noarch.rpm > output.txt 2>&1 116grep -c "touch" output.txt 117], 118[0], 119[1 120], 121[]) 122 123# Upgrade package with modified config link, unchanged in pkg. No backup. 124AT_CHECK([ 125RPMDB_INIT 126cf="${RPMTEST}"/etc/my.conf 127rm -rf "${cf}"* 128 129runroot rpm -U /build/RPMS/noarch/configtest-1.0-1.noarch.rpm 130readlink "${cf}" 131ln -sf "otherstuff" "${cf}" 132readlink "${cf}" 133runroot rpm -U /build/RPMS/noarch/configtest-2.0-1.noarch.rpm 134readlink "${cf}" 135], 136[0], 137[foo 138otherstuff 139otherstuff 140], 141[]) 142AT_CLEANUP 143 144# ------------------------------ 145AT_SETUP([changing config symlinks]) 146AT_KEYWORDS([install]) 147RPMDB_INIT 148for v in "1.0" "2.0"; do 149 runroot rpmbuild --quiet -bb \ 150 --define "ver $v" \ 151 --define "filedata foo-$v" \ 152 --define "filetype link" \ 153 /data/SPECS/configtest.spec 154done 155 156# Upgrade package with unmodified config link, changed in pkg 157AT_CHECK([ 158RPMDB_INIT 159cf="${RPMTEST}"/etc/my.conf 160rm -rf "${cf}"* 161 162runroot rpm -U /build/RPMS/noarch/configtest-1.0-1.noarch.rpm 163readlink "${cf}" 164runroot rpm -U /build/RPMS/noarch/configtest-2.0-1.noarch.rpm 165readlink "${cf}" 166], 167[0], 168[foo-1.0 169foo-2.0 170], 171[]) 172 173# Upgrade package with locally modified config link, changed in pkg 174AT_CHECK([ 175RPMDB_INIT 176cf="${RPMTEST}"/etc/my.conf 177rm -rf "${cf}"* 178 179runroot rpm -U /build/RPMS/noarch/configtest-1.0-1.noarch.rpm 180readlink "${cf}" 181ln -sf "otherstuff" "${cf}" 182readlink "${cf}" 183runroot rpm -U /build/RPMS/noarch/configtest-2.0-1.noarch.rpm 184readlink "${cf}" 185readlink "${cf}.rpmsave" 186], 187[0], 188[foo-1.0 189otherstuff 190foo-2.0 191otherstuff 192], 193[warning: /etc/my.conf saved as /etc/my.conf.rpmsave] 194) 195 196# Modified config link matches the content from new package. 197AT_CHECK([ 198RPMDB_INIT 199cf="${RPMTEST}"/etc/my.conf 200rm -rf "${cf}"* 201 202runroot rpm -U /build/RPMS/noarch/configtest-1.0-1.noarch.rpm 203readlink "${cf}" 204ln -sf "foo-2.0" "${cf}" 205readlink "${cf}" 206runroot rpm -U /build/RPMS/noarch/configtest-2.0-1.noarch.rpm 207readlink "${cf}" 208], 209[0], 210[foo-1.0 211foo-2.0 212foo-2.0 213], 214[]) 215AT_CLEANUP 216 217# config(noreplace) variants of the same cases. 218# 219# ------------------------------ 220AT_SETUP([upgrade unchanged config(noreplace) links]) 221AT_KEYWORDS([install]) 222RPMDB_INIT 223for v in "1.0" "2.0"; do 224 runroot rpmbuild --quiet -bb \ 225 --define "ver $v" \ 226 --define "filedata foo" \ 227 --define "filetype link" \ 228 --define "noreplace 1" \ 229 /data/SPECS/configtest.spec 230done 231 232# Upgrade package with config file, no backup here 233AT_CHECK([ 234RPMDB_INIT 235cf="${RPMTEST}"/etc/my.conf 236rm -rf "${cf}"* 237 238runroot rpm -U /build/RPMS/noarch/configtest-1.0-1.noarch.rpm 239readlink "${cf}" 240runroot rpm -U /build/RPMS/noarch/configtest-2.0-1.noarch.rpm 241readlink "${cf}" 242], 243[0], 244[foo 245foo 246], 247[]) 248 249# Upgrade package with locally modified config file, unchanged in pkg 250AT_CHECK([ 251RPMDB_INIT 252cf="${RPMTEST}"/etc/my.conf 253rm -rf "${cf}"* 254 255runroot rpm -U /build/RPMS/noarch/configtest-1.0-1.noarch.rpm 256readlink "${cf}" 257ln -sf "otherstuff" "${cf}" 258readlink "${cf}" 259runroot rpm -U /build/RPMS/noarch/configtest-2.0-1.noarch.rpm 260readlink "${cf}" 261], 262[0], 263[foo 264otherstuff 265otherstuff 266], 267[]) 268AT_CLEANUP 269 270# ------------------------------ 271AT_SETUP([upgrade changing config(noreplace) links]) 272AT_KEYWORDS([install]) 273RPMDB_INIT 274 275for v in "1.0" "2.0"; do 276 runroot rpmbuild --quiet -bb \ 277 --define "ver $v" \ 278 --define "filedata foo-$v" \ 279 --define "filetype link" \ 280 --define "noreplace 1" \ 281 /data/SPECS/configtest.spec 282done 283 284AT_CHECK([ 285RPMDB_INIT 286cf="${RPMTEST}"/etc/my.conf 287rm -rf "${cf}"* 288 289# Upgrade package with unmodified config file, changed in pkg 290runroot rpm -U /build/RPMS/noarch/configtest-1.0-1.noarch.rpm 291readlink "${cf}" 292runroot rpm -U /build/RPMS/noarch/configtest-2.0-1.noarch.rpm 293readlink "${cf}" 294], 295[0], 296[foo-1.0 297foo-2.0 298], 299[]) 300 301# Upgrade package with locally modified config file, changed in pkg 302AT_CHECK([ 303RPMDB_INIT 304cf="${RPMTEST}"/etc/my.conf 305rm -rf "${cf}"* 306 307runroot rpm -U /build/RPMS/noarch/configtest-1.0-1.noarch.rpm 308readlink "${cf}" 309ln -sf "otherstuff" "${cf}" 310readlink "${cf}" 311runroot rpm -U /build/RPMS/noarch/configtest-2.0-1.noarch.rpm 312readlink "${cf}" 313readlink "${cf}.rpmnew" 314], 315[0], 316[foo-1.0 317otherstuff 318otherstuff 319foo-2.0 320], 321[warning: /etc/my.conf created as /etc/my.conf.rpmnew] 322) 323 324# Modified config link matches the content from new package. 325AT_CHECK([ 326RPMDB_INIT 327cf="${RPMTEST}"/etc/my.conf 328rm -rf "${cf}"* 329 330runroot rpm -U /build/RPMS/noarch/configtest-1.0-1.noarch.rpm 331readlink "${cf}" 332ln -sf "foo-2.0" "${cf}" 333readlink "${cf}" 334runroot rpm -U /build/RPMS/noarch/configtest-2.0-1.noarch.rpm 335readlink "${cf}" 336test ! -L "${cf}.rpmnew" 337], 338[0], 339[foo-1.0 340foo-2.0 341foo-2.0 342], 343[]) 344AT_CLEANUP 345 346# Shared config link variants of the same cases 347# ------------------------------ 348AT_SETUP([upgrade unchanged shared config links]) 349AT_KEYWORDS([install]) 350RPMDB_INIT 351 352for s in "A" "B"; do 353 for v in "1.0" "2.0"; do 354 runroot rpmbuild --quiet -bb \ 355 --define "sub $s" \ 356 --define "ver $v" \ 357 --define "filedata foo" \ 358 --define "filetype link" \ 359 /data/SPECS/configtest.spec 360 done 361done 362 363# Upgrade package with config file, no backup here 364AT_CHECK([ 365RPMDB_INIT 366cf="${RPMTEST}"/etc/my.conf 367rm -rf "${cf}"* 368 369runroot rpm -U \ 370 /build/RPMS/noarch/configtest-A-1.0-1.noarch.rpm \ 371 /build/RPMS/noarch/configtest-B-1.0-1.noarch.rpm 372readlink "${cf}" 373runroot rpm -U \ 374 /build/RPMS/noarch/configtest-A-2.0-1.noarch.rpm \ 375 /build/RPMS/noarch/configtest-B-2.0-1.noarch.rpm 376readlink "${cf}" 377], 378[0], 379[foo 380foo 381], 382[]) 383 384# Upgrade package with locally modified config file, unchanged in pkg 385AT_CHECK([ 386RPMDB_INIT 387cf="${RPMTEST}"/etc/my.conf 388rm -rf "${cf}"* 389 390runroot rpm -U \ 391 /build/RPMS/noarch/configtest-A-1.0-1.noarch.rpm \ 392 /build/RPMS/noarch/configtest-B-1.0-1.noarch.rpm 393readlink "${cf}" 394ln -sf "otherstuff" "${cf}" 395readlink "${cf}" 396runroot rpm -U \ 397 /build/RPMS/noarch/configtest-A-2.0-1.noarch.rpm \ 398 /build/RPMS/noarch/configtest-B-2.0-1.noarch.rpm 399readlink "${cf}" 400], 401[0], 402[foo 403otherstuff 404otherstuff 405], 406[]) 407AT_CLEANUP 408 409# ------------------------------ 410AT_SETUP([upgrade changing shared config links]) 411AT_KEYWORDS([install]) 412RPMDB_INIT 413 414for s in "A" "B"; do 415 for v in "1.0" "2.0"; do 416 runroot rpmbuild --quiet -bb \ 417 --define "sub $s" \ 418 --define "ver $v" \ 419 --define "filedata foo-$v" \ 420 --define "filetype link" \ 421 /data/SPECS/configtest.spec 422 done 423done 424 425# Upgrade package with unmodified config file, changed in pkg 426AT_CHECK([ 427RPMDB_INIT 428cf="${RPMTEST}"/etc/my.conf 429rm -rf "${cf}"* 430 431runroot rpm -U \ 432 /build/RPMS/noarch/configtest-A-1.0-1.noarch.rpm \ 433 /build/RPMS/noarch/configtest-B-1.0-1.noarch.rpm 434readlink "${cf}" 435runroot rpm -U \ 436 /build/RPMS/noarch/configtest-A-2.0-1.noarch.rpm \ 437 /build/RPMS/noarch/configtest-B-2.0-1.noarch.rpm 438readlink "${cf}" 439], 440[0], 441[foo-1.0 442foo-2.0 443], 444[]) 445 446# Upgrade package with locally modified config file, changed in pkg 447AT_CHECK([ 448RPMDB_INIT 449cf="${RPMTEST}"/etc/my.conf 450rm -rf "${cf}"* 451 452runroot rpm -U \ 453 /build/RPMS/noarch/configtest-A-1.0-1.noarch.rpm \ 454 /build/RPMS/noarch/configtest-B-1.0-1.noarch.rpm 455readlink "${cf}" 456ln -sf "otherstuff" "${cf}" 457readlink "${cf}" 458runroot rpm -U \ 459 /build/RPMS/noarch/configtest-A-2.0-1.noarch.rpm \ 460 /build/RPMS/noarch/configtest-B-2.0-1.noarch.rpm 461readlink "${cf}" 462readlink "${cf}.rpmsave" 463], 464[0], 465[foo-1.0 466otherstuff 467foo-2.0 468otherstuff 469], 470[warning: /etc/my.conf saved as /etc/my.conf.rpmsave] 471) 472 473# Modified config link matches the content from new package. 474AT_CHECK([ 475RPMDB_INIT 476cf="${RPMTEST}"/etc/my.conf 477rm -rf "${cf}"* 478 479runroot rpm -U \ 480 /build/RPMS/noarch/configtest-A-1.0-1.noarch.rpm \ 481 /build/RPMS/noarch/configtest-B-1.0-1.noarch.rpm 482readlink "${cf}" 483ln -sf "foo-2.0" "${cf}" 484readlink "${cf}" 485runroot rpm -U \ 486 /build/RPMS/noarch/configtest-A-2.0-1.noarch.rpm \ 487 /build/RPMS/noarch/configtest-B-2.0-1.noarch.rpm 488readlink "${cf}" 489], 490[0], 491[foo-1.0 492foo-2.0 493foo-2.0 494], 495[]) 496AT_CLEANUP 497 498# Shared config(noreplace) variants of the more interesting cases 499# ------------------------------ 500AT_SETUP([upgrade changing shared config(noreplace) links]) 501AT_KEYWORDS([install]) 502RPMDB_INIT 503 504for s in "A" "B"; do 505 for v in "1.0" "2.0"; do 506 runroot rpmbuild --quiet -bb \ 507 --define "sub $s" \ 508 --define "ver $v" \ 509 --define "filedata foo-$v" \ 510 --define "filetype link" \ 511 --define "noreplace 1" \ 512 /data/SPECS/configtest.spec 513 done 514done 515 516# Upgrade package with locally modified config file, changed in pkg. 517AT_CHECK([ 518RPMDB_INIT 519cf="${RPMTEST}"/etc/my.conf 520rm -rf "${cf}"* 521 522runroot rpm -U \ 523 /build/RPMS/noarch/configtest-A-1.0-1.noarch.rpm \ 524 /build/RPMS/noarch/configtest-B-1.0-1.noarch.rpm 525readlink "${cf}" 526ln -sf "otherstuff" "${cf}" 527readlink "${cf}" 528runroot rpm -U \ 529 /build/RPMS/noarch/configtest-A-2.0-1.noarch.rpm \ 530 /build/RPMS/noarch/configtest-B-2.0-1.noarch.rpm 531readlink "${cf}" 532readlink "${cf}.rpmnew" 533], 534[0], 535[foo-1.0 536otherstuff 537otherstuff 538foo-2.0 539], 540[warning: /etc/my.conf created as /etc/my.conf.rpmnew] 541) 542 543# Modified config link matches the content from new package. 544AT_CHECK([ 545RPMDB_INIT 546cf="${RPMTEST}"/etc/my.conf 547rm -rf "${cf}"* 548 549runroot rpm -U \ 550 /build/RPMS/noarch/configtest-A-1.0-1.noarch.rpm \ 551 /build/RPMS/noarch/configtest-B-1.0-1.noarch.rpm 552readlink "${cf}" 553ln -sf "foo-2.0" "${cf}" 554readlink "${cf}" 555runroot rpm -U \ 556 /build/RPMS/noarch/configtest-A-2.0-1.noarch.rpm \ 557 /build/RPMS/noarch/configtest-B-2.0-1.noarch.rpm 558readlink "${cf}" 559test ! -L "${cf}.rpmnew" 560], 561[0], 562[foo-1.0 563foo-2.0 564foo-2.0 565], 566[]) 567AT_CLEANUP 568