1
00:00:00,000 --> 00:00:08,560
Let's talk about CPIO.

2
00:00:08,560 --> 00:00:11,520
CPIO is an old archiving utility,

3
00:00:11,520 --> 00:00:13,120
comparable to TAR.

4
00:00:13,120 --> 00:00:15,120
It's not used a lot anymore,

5
00:00:15,120 --> 00:00:17,360
but the format is common and for that reason

6
00:00:17,360 --> 00:00:19,760
you need to know a bit about it anyway.

7
00:00:19,760 --> 00:00:22,879
CPIO works on an output list of files

8
00:00:22,879 --> 00:00:25,520
that need to be generated by another utility,

9
00:00:25,520 --> 00:00:27,760
like FIND or LS.

10
00:00:28,320 --> 00:00:30,879
In general, TAR is considered easier to use

11
00:00:30,879 --> 00:00:33,680
because it can take input files as arguments,

12
00:00:33,680 --> 00:00:36,320
while with CPIO you need to provide

13
00:00:36,320 --> 00:00:38,560
input files with another command.

14
00:00:40,320 --> 00:00:42,480
Let's have a look at some usage examples.

15
00:00:44,480 --> 00:00:46,400
So I'm going to show you LS.

16
00:00:47,279 --> 00:00:48,880
That's a common command, right?

17
00:00:48,880 --> 00:00:53,200
An LS followed by a pipe CPIO minus OV

18
00:00:53,919 --> 00:00:56,959
and that will create the backup on screen.

19
00:00:56,959 --> 00:00:58,400
Well, an on-screen backup,

20
00:00:58,400 --> 00:01:00,240
that's not very convenient

21
00:01:00,240 --> 00:01:03,119
and that is why I'm redirecting it

22
00:01:03,119 --> 00:01:06,320
to my archive dot CPIO.

23
00:01:06,879 --> 00:01:08,559
That is how you would normally use it.

24
00:01:09,360 --> 00:01:16,400
So an alternative is FIND dot minus depth minus print.

25
00:01:16,400 --> 00:01:18,080
That will find a couple of files

26
00:01:18,720 --> 00:01:24,959
and these files is what you can pipe to CPIO minus O.

27
00:01:25,680 --> 00:01:27,839
So again, CPIO minus O

28
00:01:27,839 --> 00:01:32,559
and you redirect the output to my archive 2 dot CPIO.

29
00:01:34,160 --> 00:01:36,800
Now, this FIND example shows something

30
00:01:36,800 --> 00:01:38,080
that is quite interesting.

31
00:01:38,639 --> 00:01:42,000
So for instance, you can use FIND slash minus name

32
00:01:43,120 --> 00:01:47,919
star dot txt to look for all txt files

33
00:01:47,919 --> 00:01:49,919
or whichever file you want to create.

34
00:01:50,480 --> 00:01:53,360
And then you use CPIO minus O

35
00:01:54,239 --> 00:01:56,160
minus minus format is star.

36
00:01:56,720 --> 00:02:00,080
This format is star is creating tar compatible format

37
00:02:00,800 --> 00:02:04,559
and then txt files dot tar.

38
00:02:06,080 --> 00:02:08,960
And that will create a tar file for you.

39
00:02:09,520 --> 00:02:13,119
Now, also convenient is the option to extract your CPIO.

40
00:02:13,679 --> 00:02:16,720
CPIO minus IDMV.

41
00:02:16,720 --> 00:02:18,240
That's a lot of options,

42
00:02:18,240 --> 00:02:20,880
but these options are what you typically use

43
00:02:20,880 --> 00:02:23,279
to extract your archive.

44
00:02:24,000 --> 00:02:25,839
And if you do that without typos,

45
00:02:25,839 --> 00:02:27,520
it might be working better.

46
00:02:28,080 --> 00:02:31,600
Now, here I'm getting some error message user

47
00:02:31,600 --> 00:02:34,639
not create newer or same age version exists.

48
00:02:34,639 --> 00:02:36,080
Yeah, that is correct

49
00:02:36,080 --> 00:02:38,160
because it has absolute file names

50
00:02:38,160 --> 00:02:41,520
and it tries to write the absolute file name.

51
00:02:41,520 --> 00:02:45,039
And that is something that you should be careful about.

52
00:02:45,039 --> 00:02:47,199
Doesn't overwrite it fortunately,

53
00:02:47,199 --> 00:02:48,639
so nothing has gone wrong.

54
00:02:49,199 --> 00:02:51,440
Now, CPIO is funny,

55
00:02:52,080 --> 00:02:53,839
particularly on a Red Hat system

56
00:02:53,839 --> 00:02:56,639
because Red Hat is using RPMs

57
00:02:56,639 --> 00:03:00,320
and an RPM archive is really a CPO archive

58
00:03:00,320 --> 00:03:02,240
with some metadata.

59
00:03:02,240 --> 00:03:04,000
So do we have any RPMs?

60
00:03:04,800 --> 00:03:08,800
Let's do a find on star RPM so that we can see.

61
00:03:08,800 --> 00:03:11,119
And oh my goodness, there's a lot of them.

62
00:03:11,759 --> 00:03:15,440
So I am going to do what?

63
00:03:15,440 --> 00:03:18,800
Well, I am going to copy var cache.

64
00:03:21,600 --> 00:03:25,759
Package kit 10 metadata upstream.

65
00:03:26,479 --> 00:03:28,479
That's my upstream repositories

66
00:03:28,479 --> 00:03:29,679
and I'm picking one of them,

67
00:03:29,679 --> 00:03:31,520
the builder RPM.

68
00:03:31,520 --> 00:03:32,880
I'm copying it to here

69
00:03:33,520 --> 00:03:37,360
and then I'm going to use RPM to CPIO

70
00:03:37,919 --> 00:03:41,119
on my builder dot whatever.

71
00:03:41,679 --> 00:03:45,039
And yeah, it's refusing to write it to a terminal.

72
00:03:45,039 --> 00:03:51,119
So let's call it builder dot CPIO.

73
00:03:52,399 --> 00:03:54,479
And now I have my CPIO file

74
00:03:54,479 --> 00:03:59,440
and there I can use CPIO minus IDMV

75
00:03:59,440 --> 00:04:04,000
on builder dot CPIO.

76
00:04:04,000 --> 00:04:05,600
Oh, I'm doing it the wrong way.

77
00:04:05,600 --> 00:04:08,479
I need my input redirection, of course.

78
00:04:08,479 --> 00:04:09,600
And as you can see,

79
00:04:09,600 --> 00:04:12,320
this has created a subdirectory structure

80
00:04:12,320 --> 00:04:13,759
in my current directory.

81
00:04:13,759 --> 00:04:16,799
You see that the user directory is right here.

82
00:04:16,799 --> 00:04:18,399
And in this user directory,

83
00:04:18,399 --> 00:04:21,440
I have all files that are coming from the RPM package.

84
00:04:21,440 --> 00:04:23,440
So if ever you need to fetch something

85
00:04:23,440 --> 00:04:25,519
directly from an RPM package,

86
00:04:25,519 --> 00:04:28,320
this can be a convenient way to do so.

