blob: 34108e35788a3d7734168f0820d1f3c286f19e86 (
plain)
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
#!/bin/sh
set -e
TESTDIR="$(readlink -f "$(dirname "$0")")"
. "$TESTDIR/framework"
setupenvironment
configarchitecture 'amd64'
buildsimplenativepackage 'pkg1' 'amd64' '1' 'stable'
buildsimplenativepackage 'pkg2' 'amd64' '1' 'stable'
setupaptarchive
cathistory() {
sed rootdir/var/log/apt/history.log -re 's/^(Commandline|Start-Date|End-Date):.*/\1: dummy/'
}
testsuccess aptget install pkg1
testequal "
Start-Date: dummy
Commandline: dummy
Install: pkg1:amd64 (1)
End-Date: dummy" cathistory
testsuccess aptget install pkg2 --comment="A test comment"
testequal "
Start-Date: dummy
Commandline: dummy
Install: pkg1:amd64 (1)
End-Date: dummy
Start-Date: dummy
Commandline: dummy
Comment: A test comment
Install: pkg2:amd64 (1)
End-Date: dummy" cathistory
normalizedinfo() {
apt history-info 0 | sed -E \
-e 's/^( *-?Start time *: ).*/\1dummy/' \
-e 's/^( *-?End time *: ).*/\1dummy/' \
-e 's|^( *-?Command line *: ).*/(.*)|\1\2|'
}
testsuccessequal "Transaction ID: 0
Start time: dummy
End time: dummy
Requested by:
Command line: apt-get install pkg1
Packages changed:
Install pkg1:amd64 (1)
" normalizedinfo
# replace aribtrary command line and date with "dummy".
normalizedlist() {
apt history-list | sed -E 's/^([0-9]+)[[:space:]]+'\
'.*'\
'[0-9]{4}-[0-9]{2}-[0-9]{2}[[:space:]]+'\
'[0-9]{2}:[0-9]{2}:[0-9]{2}/'\
'\1 dummy dummy /'
}
testsuccessequal "ID Command line Date and Time Action Changes
0 dummy dummy Install 1
1 dummy dummy Install 1 " normalizedlist
################################################################################
# Read previous history for manipulation
################################################################################
# Test history
# 0 - Install pkg1
# 1 - Install pkg2
# 2 - Remove pkg1 (undo ID 0)
# 3 - Install pkg1 (undo ID 2)
# 4 - Remove pkg1 (redo ID 2)
# 5 - Install pkg1 (rollback to ID 1)
# 6 - Remove pkg1 (rollback to ID 2)
testdpkginstalled pkg1
# undo the first package install
apt history-undo 0 -y >> /dev/null
testdpkgnotinstalled pkg1
# ...which generates a new id that we also undo
apt history-undo 2 -y >>/dev/null
testdpkginstalled pkg1
# redo the removal
apt history-redo 2 -y >> /dev/null
testdpkgnotinstalled pkg1
# rollback to ID 1 and it should be installed
apt history-rollback 1 -y >> /dev/null
testdpkginstalled pkg1
# rollback to ID 2 and it should be removed
apt history-rollback 2 -y >> /dev/null
testdpkgnotinstalled pkg1
# rollback to ID 0 and it should be installed
apt history-rollback 0 -y >> /dev/null
testdpkginstalled pkg1
# rollback to ID 4 and it should be removed
apt history-rollback 4 -y >> /dev/null
testdpkgnotinstalled pkg1
################################################################################
# Reset history log
################################################################################
msgmsg "Actionless group"
cat > rootdir/var/log/apt/history.log << EOF
Start-Date: dummy
Commandline: install nothing
End-Date: dummy
EOF
testsuccessequal "ID Command line Date and Time Action Changes
0 install nothing dummy 0 " normalizedlist
testsuccessequal "Transaction ID: 0
Start time: dummy
End time: dummy
Requested by:
Command line: install nothing
Packages changed:" normalizedinfo
testfailureequal "E: Incorrect usage, no ID was given." apt history-redo
testfailureequal "E: Incorrect usage, no ID was given." apt history-undo
testfailureequal "E: Incorrect usage, no ID was given." apt history-rollback
|