extfs: rpm: add test for a custom package.

We use a 'spec' contributed by Jiri Tyr.

We keep the previous test (by renaming rpm.* to rpm.glib.*), though, in case
somebody wants to work on data from "the real world".

Signed-off-by: Mooffie <mooffie@gmail.com>
This commit is contained in:
Mooffie 2017-01-05 14:09:00 +02:00
parent 4b8785ead6
commit b10f34e898
10 changed files with 399 additions and 9 deletions

View File

@ -39,9 +39,12 @@ data_files_to_distribute = \
data/lslR.3.spaces-iso-noslash.output \
data/lslR.README \
data/rpm.README \
data/rpm.env_vars \
data/rpm.input \
data/rpm.output \
data/rpm.custom.env_vars \
data/rpm.custom.input \
data/rpm.custom.output \
data/rpm.glib.env_vars \
data/rpm.glib.input \
data/rpm.glib.output \
data/rpm.rewrite.sh \
data/u7z.README \
data/u7z.complex.env_vars \

View File

@ -1,13 +1,23 @@
The *.input files for the rpm helper are what we call "tags files".
They're generated by rpm2tags.
The *.input files for the tests are what we call "tags files". They are
generated by rpm2tags.
The rpm package chosen was glib2-2.46.2-4.el7.i686.rpm (downloadable from
rpmfind.net), as it has scriptlets that demonstrate the INFO/SCRIPTS dir.
The tests:
- rpm.glib.input:
Generated from glib2-2.46.2-4.el7.i686.rpm (downloadable from
rpmfind.net).
- rpm.custom.input:
Generated from our own custom package (see test.spec in this
distribution). The advantage of this custom package is that it lets us
test the helper with almost all the tags it's supposed to support.
--
The way this test works is a bit unconventional:
The way we test this helper is a bit unconventional:
We aren't overriding one or two variables in the helper but, instead,
inject a code snippet into it (see 'rpm.rewrite.sh'). This lets us

View File

@ -0,0 +1,261 @@
# -*- mode: perl -*-
# vim: filetype=perl
#
# This "tags file" was created by running the following command:
#
# $ perl rpm2tags.pl ~/rpmbuild/RPMS/noarch/test-2.3-4.noarch.rpm
#
# This file is used in our tests instead of the corresponding RPM file.
# This lets us run the tests on systems where 'rpm' is not installed.
$tags = {
'PROVIDEVERSION' => '1:2.3-4',
'PATCHESNAME' => '(none)',
'REQUIREFLAGS' => '288',
'NAME' => 'test',
'FILEDEPENDSN' => '0',
'POSTTRANS' => 'echo "Post-transaction script"',
'SUGGESTNEVRS' => '(none)',
'CONFLICTFLAGS' => '0',
'VERIFYSCRIPT' => 'echo "Verify script"',
'_INFO' => 'Name : test
Epoch : 1
Version : 2.3
Release : 4
Architecture: noarch
Install Date: (not installed)
Group : Development/System
Size : 5
License : MIT
Signature : (none)
Source RPM : test-2.3-4.src.rpm
Build Date : Thu Jan 5 13:46:18 2017
Build Host : mooffie-desktop
Relocations : (not relocatable)
Packager : Test Packager
Vendor : Test Vendor
URL : http://example.com
Summary : Testing
Description :
Multi-line description field
with "double", \'single quotes\', and $weird | \\characters i\\n = i\\\\t, empty line...
...and a tab: [ ].
',
'DBINSTANCE' => '0',
'FILECOLORS' => '0',
'POSTUNFLAGS' => '(none)',
'POLICYTYPESINDEXES' => '(none)',
'PACKAGER' => 'Test Packager',
'SIGSIZE' => '2408',
'PREINPROG' => '/bin/sh',
'CLASSDICT' => 'ASCII text',
'FILEINODES' => '1',
'EXCLUSIVEARCH' => '(none)',
'ICON' => '(none)',
'OBSOLETEFLAGS' => '0',
'CHANGELOGNAME' => 'Jiri Tyr <jiri.tyr at gmail.com> 1:2.3-4',
'V' => '2.3',
'VERIFYSCRIPTFLAGS' => '(none)',
'SUPPLEMENTFLAGS' => '(none)',
'FILECLASS' => 'ASCII text',
'COOKIE' => '(none)',
'OLDENHANCESNAME' => '(none)',
'FILEDEPENDSX' => '0',
'ORDERNAME' => '(none)',
'TRIGGERSCRIPTS' => '(none)',
'OLDFILENAMES' => '(none)',
'PAYLOADFORMAT' => 'cpio',
'CHANGELOGTIME' => '1483099200',
'DIRINDEXES' => '0',
'OLDENHANCESVERSION' => '(none)',
'OLDENHANCES' => '(none)',
'SIZE' => '5',
'SUMMARY' => 'Testing',
'POLICYFLAGS' => '(none)',
'SOURCERPM' => 'test-2.3-4.src.rpm',
'OBSOLETEVERSION' => '',
'FILEUSERNAME' => 'root',
'EPOCH' => '1',
'ORIGDIRNAMES' => '(none)',
'LICENSE' => 'MIT',
'OLDSUGGESTS' => '(none)',
'PATCHESVERSION' => '(none)',
'FILEMD5S' => 'd8e8fca2dc0f896fd7cb4cb0031ba249',
'POLICIES' => '(none)',
'DSAHEADER' => '(none)',
'LONGSIGSIZE' => '2408',
'ENHANCENEVRS' => '(none)',
'ENHANCEFLAGS' => '(none)',
'PROVIDENEVRS' => 'test = 1:2.3-4',
'OLDSUGGESTSFLAGS' => '(none)',
'NVRA' => 'test-2.3-4.noarch',
'TRIGGERINDEX' => '(none)',
'HEADERI18NTABLE' => 'C',
'PATCHESFLAGS' => '(none)',
'BUILDARCHS' => '(none)',
'ENHANCEVERSION' => '(none)',
'REQUIREFLAGS:depflags' => '',
'RECOMMENDS' => '(none)',
'VERSION' => '2.3',
'FILELINKTOS' => '',
'CONFLICTNEVRS' => 'notest',
'OBSOLETENEVRS' => 'testing',
'E' => '1',
'CHANGELOGTEXT' => '- Initial build.',
'PRETRANSFLAGS' => '(none)',
'REQUIRENAME' => '/bin/sh',
'HEADERREGIONS' => '(none)',
'NOPATCH' => '(none)',
'FILEREQUIRE' => '',
'BUILDTIME' => '1483616778',
'FILEFLAGS' => '0',
'OLDSUGGESTSVERSION' => '(none)',
'PROVIDEFLAGS' => '8',
'O' => 'testing',
'SHA1HEADER' => '94826dbc4976a5c54a494a0591553b972edcf235',
'ARCHIVESIZE' => '264',
'FILENAMES' => '/var/tmp/test.txt',
'FILERDEVS' => '0',
'INSTALLCOLOR' => '(none)',
'REQUIRENEVRS' => '/bin/sh',
'FILEDIGESTS' => 'd8e8fca2dc0f896fd7cb4cb0031ba249',
'EXCLUSIVEOS' => '(none)',
'CHANGELOGTIME:date' => 'Fri Dec 30 14:00:00 2016',
'PREFIXES' => '(none)',
'POLICYNAMES' => '(none)',
'FILEVERIFYFLAGS' => '4294967295',
'TRIGGERNAME' => '(none)',
'PROVIDES' => 'test',
'RELEASE' => '4',
'SOURCEPACKAGE' => '(none)',
'FSCONTEXTS' => '(none)',
'GROUP' => 'Development/System',
'HDRID' => '94826dbc4976a5c54a494a0591553b972edcf235',
'SOURCEPKGID' => '(none)',
'SUGGESTVERSION' => '(none)',
'SIGGPG' => '(none)',
'FILELANGS' => '',
'ORDERFLAGS' => '(none)',
'GIF' => '(none)',
'OBSOLETES' => 'testing',
'REQUIREVERSION' => '',
'PAYLOADFLAGS' => '9',
'TRIGGERTYPE' => '(none)',
'REMOVETID' => '(none)',
'OBSOLETEFLAGS:depflags' => '',
'FILEMTIMES' => '1483616778',
'POSTUN' => 'echo "Post-uninstallation script"',
'PROVIDEFLAGS:depflags' => '=',
'POSTINPROG' => '/bin/sh',
'OLDSUGGESTSNAME' => '(none)',
'BUGURL' => '(none)',
'INSTALLTIME' => '(none)',
'PREINFLAGS' => '(none)',
'LONGARCHIVESIZE' => '264',
'ENHANCES' => '(none)',
'VENDOR' => 'Test Vendor',
'URL' => 'http://example.com',
'RSAHEADER' => '(none)',
'VCS' => '(none)',
'POSTTRANSPROG' => '/bin/sh',
'TRIGGERVERSION' => '(none)',
'ORIGBASENAMES' => '(none)',
'TRIGGERFLAGS' => '(none)',
'RECOMMENDFLAGS' => '(none)',
'ARCH' => 'noarch',
'SUGGESTFLAGS' => '(none)',
'OS' => 'linux',
'PREUNPROG' => '/bin/sh',
'P' => 'test',
'SUPPLEMENTNAME' => '(none)',
'CONFLICTFLAGS:depflags' => '',
'DEPENDSDICT' => '(none)',
'PREUNFLAGS' => '(none)',
'PLATFORM' => 'noarch-debian-linux',
'DIRNAMES' => '/var/tmp/',
'POSTTRANSFLAGS' => '(none)',
'NVR' => 'test-2.3-4',
'SIGPGP' => '(none)',
'INSTFILENAMES' => '(none)',
'CONFLICTS' => 'notest',
'NEVRA' => 'test-1:2.3-4.noarch',
'RECONTEXTS' => '(none)',
'NEVR' => 'test-1:2.3-4',
'REQUIRES' => '/bin/sh',
'PATCH' => '(none)',
'SOURCE' => '(none)',
'LONGSIZE' => '5',
'FILECAPS' => '(none)',
'DISTURL' => '(none)',
'RECOMMENDVERSION' => '(none)',
'FILEMODES' => '33188',
'BUILDHOST' => 'mooffie-desktop',
'PUBKEYS' => '(none)',
'PREUN' => 'echo "Pre-uninstallation script"',
'FILEPROVIDE' => '',
'OPTFLAGS' => '-O2 -g -march=i386 -mtune=i686',
'ORIGFILENAMES' => '(none)',
'CONFLICTNAME' => 'notest',
'TRIGGERSCRIPTFLAGS' => '(none)',
'TRIGGERCONDS' => '(none)',
'HEADERIMAGE' => '(none)',
'SUPPLEMENTVERSION' => '(none)',
'BASENAMES' => 'test.txt',
'SUPPLEMENTS' => '(none)',
'SUGGESTS' => '(none)',
'PREIN' => 'echo "Pre-installation script"',
'OLDENHANCESFLAGS' => '(none)',
'DESCRIPTION' => 'Multi-line description field
with "double", \'single quotes\', and $weird | \\characters i\\n = i\\\\t, empty line...
...and a tab: [ ].',
'FILESTATES' => '(none)',
'CONFLICTVERSION' => '',
'PROVIDENAME' => 'test',
'HEADERCOLOR' => '0',
'FILECONTEXTS' => '(none)',
'EPOCHNUM' => '1',
'LONGFILESIZES' => '5',
'DISTRIBUTION' => 'Test Distro',
'SUGGESTNAME' => '(none)',
'RPMVERSION' => '4.12.0.1',
'POLICYTYPES' => '(none)',
'HEADERSIGNATURES' => '(none)',
'VERBOSE' => '(none)',
'R' => '4',
'PKGID' => 'e8150d00f05b3becbc59c4a31becfab6',
'NOSOURCE' => '(none)',
'EXCLUDEARCH' => '(none)',
'FILEDIGESTALGO' => '(none)',
'N' => 'test',
'RECOMMENDNAME' => '(none)',
'FILESIZES' => '5',
'FILEDEVICES' => '1',
'EXCLUDEOS' => '(none)',
'C' => 'notest',
'PRETRANSPROG' => '/bin/sh',
'PRETRANS' => 'echo "Pre-transaction script"',
'ORIGDIRINDEXES' => '(none)',
'FILENLINKS' => '1',
'TRIGGERSCRIPTPROG' => '(none)',
'VERIFYSCRIPTPROG' => '/bin/sh',
'OBSOLETENAME' => 'testing',
'RECOMMENDNEVRS' => '(none)',
'POSTINFLAGS' => '(none)',
'BUILDTIME:date' => 'Thu Jan 5 13:46:18 2017',
'SIGMD5' => 'e8150d00f05b3becbc59c4a31becfab6',
'SUPPLEMENTNEVRS' => '(none)',
'FILEGROUPNAME' => 'root',
'POSTUNPROG' => '/bin/sh',
'INSTPREFIXES' => '(none)',
'ORDERVERSION' => '(none)',
'XPM' => '(none)',
'INSTALLTID' => '(none)',
'POSTIN' => 'echo "Post-installation script"',
'DISTTAG' => '(none)',
'PAYLOADCOMPRESSOR' => 'gzip',
'ENHANCENAME' => '(none)',
'EVR' => '1:2.3-4'
}
;

View File

@ -0,0 +1,28 @@
-r--r--r-- 1 0 0 539 2017-01-05 00:00:00 HEADER
-r-xr-xr-x 1 0 0 39 2017-01-05 00:00:00 INSTALL
-r-xr-xr-x 1 0 0 39 2017-01-05 00:00:00 UPGRADE
dr-xr-xr-x 3 0 0 0 2017-01-05 00:00:00 INFO
-r--r--r-- 1 0 0 0 2017-01-05 00:00:00 INFO/NAME-EPOCH:VERSION-RELEASE
-r--r--r-- 1 0 0 0 2017-01-05 00:00:00 INFO/GROUP
-r--r--r-- 1 0 0 0 2017-01-05 00:00:00 INFO/BUILDHOST
-r--r--r-- 1 0 0 0 2017-01-05 00:00:00 INFO/SOURCERPM
-r--r--r-- 1 0 0 0 2017-01-05 00:00:00 INFO/BUILDTIME
-r--r--r-- 1 0 0 0 2017-01-05 00:00:00 INFO/RPMVERSION
-r--r--r-- 1 0 0 0 2017-01-05 00:00:00 INFO/OS
-r--r--r-- 1 0 0 0 2017-01-05 00:00:00 INFO/SIZE
-r--r--r-- 1 0 0 0 2017-01-05 00:00:00 INFO/DISTRIBUTION
-r--r--r-- 1 0 0 0 2017-01-05 00:00:00 INFO/VENDOR
-r--r--r-- 1 0 0 0 2017-01-05 00:00:00 INFO/DESCRIPTION
-r--r--r-- 1 0 0 0 2017-01-05 00:00:00 INFO/SCRIPTS/PREIN
-r--r--r-- 1 0 0 0 2017-01-05 00:00:00 INFO/SCRIPTS/POSTIN
-r--r--r-- 1 0 0 0 2017-01-05 00:00:00 INFO/SCRIPTS/PREUN
-r--r--r-- 1 0 0 0 2017-01-05 00:00:00 INFO/SCRIPTS/POSTUN
-r--r--r-- 1 0 0 0 2017-01-05 00:00:00 INFO/SCRIPTS/VERIFYSCRIPT
-r--r--r-- 1 0 0 0 2017-01-05 00:00:00 INFO/SCRIPTS/ALL
-r--r--r-- 1 0 0 0 2017-01-05 00:00:00 INFO/SCRIPTS/PREINPROG
-r--r--r-- 1 0 0 0 2017-01-05 00:00:00 INFO/SCRIPTS/POSTINPROG
-r--r--r-- 1 0 0 0 2017-01-05 00:00:00 INFO/SCRIPTS/PREUNPROG
-r--r--r-- 1 0 0 0 2017-01-05 00:00:00 INFO/SCRIPTS/POSTUNPROG
-r--r--r-- 1 0 0 0 2017-01-05 00:00:00 INFO/SCRIPTS/VERIFYSCRIPTPROG
-r--r--r-- 1 0 0 0 2017-01-05 00:00:00 INFO/CHANGELOG
-r--r--r-- 1 0 0 0 2017-01-05 00:00:00 CONTENTS.cpio

View File

@ -0,0 +1,3 @@
MC_TEST_RPM_REWRITE="$MC_TEST_EXTFS_DATA_DIR/rpm.rewrite.sh"
MCFASTRPM= # disable "fast mode".

View File

@ -1,2 +1,2 @@
EXTRA_DIST = rpm2tags.pl
EXTRA_DIST = rpm2tags.pl test.spec

View File

@ -0,0 +1,85 @@
#
# This spec file is used to build the test*.rpm package we use in one of
# our tests.
#
# The advantage of using our own custom package, instead of downloading a
# random one from the net, is that we get the chance here to define all the
# tags our rpm helper is supposed to support.
#
# Build this package with:
#
# $ rpmbuild -bb test.spec
#
# Then create the input for the test with:
#
# $ perl /path/to/rpm2tags.pl ~/rpmbuild/RPMS/noarch/test*.rpm > rpm.custom.input
#
Name: test
Summary: Testing
Epoch: 1
Version: 2.3
Release: 4%{?dist}
URL: http://example.com
Group: Development/System
License: MIT
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
BuildArch: noarch
Conflicts: notest
Obsoletes: testing
Distribution: Test Distro
Packager: Test Packager
Vendor: Test Vendor
%description
Multi-line description field
with "double", 'single quotes', and $weird | \characters i\n = i\\t, empty line...
...and a tab: [ ].
%install
[ "%{buildroot}" != / ] && %{__rm} -rf "%{buildroot}"
%{__mkdir_p} %{buildroot}%{_tmppath}
echo %{name} > %{buildroot}%{_tmppath}/%{name}.txt
%pretrans
echo "Pre-transaction script"
%pre
echo "Pre-installation script"
%post
echo "Post-installation script"
%preun
echo "Pre-uninstallation script"
%postun
echo "Post-uninstallation script"
%posttrans
echo "Post-transaction script"
%verifyscript
echo "Verify script"
%clean
[ "%{buildroot}" != / ] && %{__rm} -rf "%{buildroot}"
%files
%defattr(-,root,root,-)
%{_tmppath}/%{name}.txt
%changelog
* Fri Dec 30 2016 Jiri Tyr <jiri.tyr at gmail.com> 1:2.3-4
- Initial build.