forked from calccrypto/tar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
64 lines (48 loc) · 1.21 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
CC?=gcc
CFLAGS=-Wall -std=c11
LFLAGS=
TARGET=libtar.a
AR=ar
all: $(TARGET)
tar.o: tar.h tar.c
$(CC) $(CFLAGS) -c tar.c
$(TARGET): tar.o
$(AR) -r $(TARGET) tar.o
exec: $(TARGET) main.c
$(CC) $(CFLAGS) main.c -o exec -ltar -L.
test: $(TARGET) exec
# create fake files
@-touch file
@-mkdir folder
@-mkfifo pipe
@-ln -s file sym
@-mknod block b 1 2
@-mknod char c 3 4
# archive the files with tar
tar -cf test.tar file folder pipe sym block char char block sym pipe folder file
# remove data
rm -r file folder pipe sym block char
# test extraction
./exec x test.tar
# archive the files
./exec c test.tar file folder pipe sym block char char block sym pipe folder file
# remove entries from archive
./exec r test.tar folder/ block
# diff real tar and this tar
tar -vtf test.tar > real
./exec lv test.tar > out
diff -u real out
@rm real out
# put them back
./exec a test.tar block folder/
# diff real tar and this tar
tar -vtf test.tar > real
./exec lv test.tar > out
diff -u real out
@rm real out
# extract the files with tar
tar -xf test.tar
# clean up
rm -r test.tar char block sym pipe folder file
clean:
rm -rf tar.o $(TARGET) ./exec test.tar char block sym pipe folder file real out