-
Notifications
You must be signed in to change notification settings - Fork 0
/
docs.txt
237 lines (192 loc) · 10.5 KB
/
docs.txt
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
"Ad hoc package manager"
adhoc-packagem.pl
A Perl tool that "installs" files from a directory and then helps removing them all.
USAGE (see OPTIONS below, too)
inst [-p|-dummy] <source_dir> [-r <root_path>] [-file <output>[.insfiles]]
[-nco] [-sc] [-strip]
del [-p] <input>.insfiles [-r <root_path>]
-h
--help
PREFACE
Currently it's not very smart, but it does the job.
When an .insfiles file in source directory is requested, an empty .insfiles
is created also in destination directory. (The "real" file under name specified
with -file option is created and valid, so it is not a big problem.)
It can be reproduced with this command:
'./adhoc-packagem.pl inst tst -file tst/x -r dest'.
Another notable case is when destination is a directory inside source (for
example when using: `inst .. -r d'). In this case this tool could attempt to
copy d/ into d/ infinitely (it's when cp(1) warns:
cp: cannot copy a directory, `..', into itself, `d/').
(This will be fixed at some point.) Otherwise this tool works very well.
See also SPECIAL FILES and OTHER INFO for more details.
PURPOSE
It can be used when you want to copy directory with some app to /usr/local
(or even /usr or /; the destination path "/" is the default) and then remove
it easily.
OPTIONS
Command line arguments must occur after source directory (inst) or .insfiles (del).
Options -p and -dummy are the exception: they can occur just after "inst" or "del"
(examples of permitted order: inst -p x; inst x -p; inst -dummy x). Duplicated
-p or -dummy are not allowed here: in "inst -p -p x", "-p" would be treated as
a "source_dir" argument.
* inst
inst [-p|-dummy] <source_dir> [-r <root_path>] [-file <output>[.insfiles]]
[-nco] [-sc] [-strip]
Copy files from source_dir to root_path, or / if root_path is not specified.
Use -file output to specify output .insfiles (extension will be appended if
necessary). Default .insfiles is: cleaned_source_dir.insfile, where
cleaned_source_dir is source_dir with all dots stripped from the beginning and
the end of the last part of the path. Also, if the last part begins with a dot,
the text "FILES." is prepended to the file name. Examples follow.
/tmp/src -> /tmp/src.insfiles
/tmp/.src -> /tmp/FILES.src.insfiles
Argument source_dir must be a directory; root_path can be a directory or
a symbolic link pointing to a directory.
* del
del [-p] <input>.insfiles [-allow-del-from-root] [-r <root_path>]
Reads input.insfiles and removes files and non-empty directories in reversed order.
If you specify -r root_path, it will be appended to all items. This could
be useful if you work with chroots. Use -p to see what resulting paths would look
like.
Note: additional -file input2.insfiles is permitted and will override input.insfiles.
When root directory for the operation is / (determined from ROOTDIR saved in an
.insfiles file) and it is not overridden with -r, the process is aborted
unless -allow-del-from-root is specified. See description of -allow-del-from-root
for the rationale.
* -h (or --help)
Prints some blah - informations and usage. If you are reading this file you
don't need this.
* -p
Run in pretend mode. See PRETEND MODE.
* -dummy
When in dummy mode, nothing is copied to destination directory. Only an .insfiles
file is created, without checking for any conflicts that might occur without
this option.
This can be useful to recreate an .insfiles after it has been lost using only
original source directory. Note that such .insfiles file will be different from
the original one if for example previous "inst" was run with option "-sc" and
file collisions were detected and thus not recorded in the .insfiles content,
but these files will be recorded now with -dummy option used.
* -nco
Only allowed with "inst".
"No change ownership" - don't alter ownership of files and directories that
has been copied.
This option is useful when you (as root) "install" files that belong to another
user and want the files in destination path to be owned by root.
Another case when this option is useful is when you have no permission to
change ownership and want to avoid "can't change owner/group" warnings.
MORE INFO section contains more informations about changing file modes.
This has no effect (besides of printing a message) with -p and -dummy.
* -r
Specify alternative root path (or destination). If used multiple times, the last
one will be used. See description for "inst" and "del".
* -sc
Only allowed with "inst".
"Skip on conflict" - allows to continue copying if an item in destination
directory already exist. The only exception is when source is a directory (not
a symbolic link pointing to a directory) and destination is a file. In such
a case copying will abort, as usual. The reason: if we have file structure
in source directory like this: abc/def (abc is a directory) and in destination:
abc (abc is a file), copying the file abc/def will fail anyway, because there
is no abc directory to copy to.
A file that has been skipped is not recorded in an .insfiles file and will not
be removed when "del" command is used.
* -file
Specify alternative name (path) to an .insfiles file. Most useful with "inst",
but can be used with "del", too. If used multiple times, the last one will be used.
* -strip
If this option is used, root directory saved in an .insfiles is set to "/".
In other words, the remaining part is "stripped". This only affects contents
of the file with list; files are installed as normal. This option can be useful
when you install to a chroot. To remove files from the same location as before,
the '-r' argument can be used with "del".
For example:
./adhoc-packagem.pl inst src -r /opt/dst -file haha.insfiles -strip
# src.insfiles wouldn't contain the full path to "dst"; to remove files:
./adhoc-packagem.pl del haha.insfiles -r /opt/dst.
-allow-del-from-root
Only allowed with "del".
When root directory for the operation is / (determined from ROOTDIR saved in an
.insfiles file) and it is not overridden with -r, the process is aborted.
This option has been introduced as a safety guard helpful when -strip was used
with "inst".
Consider such example:
./adhoc-packagem inst /mnt/chroot -r /mnt/chroot2 -strip
because -strip was used, the .insfiles file contains entries without preceeding
/mnt/chroot (see description of the -strip option above).
Then the same person wants to delete /mnt/chroot2. The correct invocation is:
./adhoc-packagem del data.insfiles -r /mnt/chroot2
but it is not difficult to forget about -r and execute this:
./adhoc-packagem del data.insfiles
which will delete data from /.
It may be changed in the future to require this option only if -strip was used,
like shown above, because it is mostly helpful only in this case.
SPECIAL FILES
A note about non-regular files on "inst".
Symbolic links: a new symbolic link is made in the destination directory, and new
symlink's "content" (where it points to) is exactly the same as of the original one.
Note it doesn't mean the new symbolic link will always point to the same
item in a filesystem - it means only that, for example, "../xyz" will be "../xyz".
Another special files are ignored and a warning is issued.
There's no attempt to change owner, group or permissions for a symbolic link.
OTHER INFO
* inst
It tries to operate safely. If a file already exists it won't be overwritten
(in such a case the process will abort unless "-sc" is used - all changes can be
undone with "del" command).
However, if a directory (or a symbolic link that points to a directory) already
exists, it will be used. Such a directory (or symbolic link) won't be removed
with "del" option.
If a source item is a directory and a file with the same name exists in destination
directory, the process is aborted.
If a source item is not a directory and a directory (or a symbolic link pointing
to a directory) with the same name exists in destination directory, the process
is aborted unless "-sc" option is used.
It tries to change mode (writable, executable etc.) of created item to match the
original one's mode (note: not for symbolic links; not for directories that already
exist). On success, tries to set the same UID and GID, too (same note as above),
unless the -nco ("no change ownership") option is specified.
If any of these two operations fail, a warning is issued, but the process
is not aborted.
Access or modification time of created item is set as-is (usually it will be
"now").
If a file cannot be copied or a symbolic link cannot be made, a message is
printed on screen and the process is aborted.
If none of these options are provided: -p, -sc, -dummy, then if nothing has been
copied due to an error (usually permission error), .insfiles file is deleted.
* del
Currently it does not check if file was modified in any way after installing with
this tool, and removes it when using "del" option anyway.
When removing directories it uses the rmdir function, that will refuse to
delete non-empty directory. It is good and intended! (A non-empty directory
occurs if something was added to it after "installing" with this tool.)
If an item was already removed, a warning is issued.
PRETEND MODE
Pretend mode (-p) is a simple way to check of what would be done.
* with "inst":
- generates an .insfiles,
- checks if there are any conflicts ("If a file already exists it won't be
overwritten" etc. above),
- does not check for permissions or another problems that can occur during copying;
* with "del":
- reads an .insfiles (with normal check whether it's OK),
- writes what file (or maybe directory - see below) would be removed,
- if such a file/directory does not exist anymore, tells user about it,
- a non-empty directory would not be removed, but in this mode user won't be
notified about this fact.
PORTABILITY AND NOTES FOR NON-UNIX OPERATING SYSTEMS
It has been tested and proved itself to work on a GNU/Linux system and MS Windows.
Systems using some kind of exotic path notation are not supported.
An .insfiles file stores paths using path separators native to the operating
system (slashes on Linux and backslashes on Windows). It means that an .insfiles
file generated on Linux should work on Windows, but the opposite is not true.
"Volume" is not stored, so for example "C:\directory\subdir" is stored as
"\directory\subdir". It means that you may need to change working drive first
with "del". (Option -r with drive letter should work, but it's not tested so not
recommended.) With "inst" you must change drive to the one where you want
files to be placed, because with "inst" drive letter specified with -r is ignored.
The tool can be found currently here: https://github.com/Enlik/adhoc-packagem.
by Enlik
January/April/December 2011, January/December 2012
End of file.