Let's talk about CPIO.
CPIO is an old archiving utility,
comparable to TAR.
It's not used a lot anymore,
but the format is common and for that reason
you need to know a bit about it anyway.
CPIO works on an output list of files
that need to be generated by another utility,
like FIND or LS.
In general, TAR is considered easier to use
because it can take input files as arguments,
while with CPIO you need to provide
input files with another command.
Let's have a look at some usage examples.
So I'm going to show you LS.
That's a common command, right?
An LS followed by a pipe CPIO minus OV
and that will create the backup on screen.
Well, an on-screen backup,
that's not very convenient
and that is why I'm redirecting it
to my archive dot CPIO.
That is how you would normally use it.
So an alternative is FIND dot minus DEPTH minus PRINT.
That will find a couple of files
and these files is what you can pipe to CPIO minus O.
So again, CPIO minus O
and you redirect the output to my archive 2 dot CPIO.
Now, this FIND example shows something
that is quite interesting.
So for instance, you can use FIND slash minus name
star dot TXT to look for all TXT files
or whichever file you want to create.
And then you use CPIO minus O
minus minus format is star.
This format is star is creating tar compatible format
and then TXT files dot tar
and that will create a tar file for you.
Now, also convenient is the option to extract your CPIO.
CPIO minus IDMV.
That's a lot of options,
but these options are what you typically use
to extract your archive.
And if you do that without typos,
it might be working better.
Now, here I'm getting some error message
user not create newer or same age version exists.
Yeah, that is correct
because it has absolute file names
and it tries to write the absolute file name
and that is something that you should be careful about.
Doesn't overwrite it fortunately,
so nothing has gone wrong.
Now, CPIO is funny,
particularly on a Red Hat system
because Red Hat is using RPMs
and an RPM archive is really a CPO archive
with some metadata.
So do we have any RPMs?
Let's do a find on star RPM so that we can see.
And oh my goodness, there's a lot of them.
So I am going to do what?
Well, I am going to copy var cache.
Package kit 10 metadata upstream.
That's my upstream repositories
and I'm picking one of them,
the builder RPM.
I'm copying it to here
and then I'm going to use RPM to CPIO
on my builder dot whatever.
And yeah, it's refusing to write it to a terminal.
So let's call it builder dot CPIO.
And now I have my CPIO file
and there I can use CPIO minus IDMV
on builder dot CPIO.
Oh, I'm doing it the wrong way.
I need my input redirection, of course.
And as you can see,
this has created a subdirectory structure
in my current directory.
You see that?
The user directory is right here.
And in this user directory,
I have all files that are coming
from the RPM package.
So if ever you need to fetch something
directly from an RPM package,
this can be a convenient way to do so.