File: backup

package info (click to toggle)
acr 2.2.4-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 712 kB
  • sloc: sh: 4,738; makefile: 41
file content (64 lines) | stat: -rw-r--r-- 1,872 bytes parent folder | download | duplicates (5)
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
backups in ACR
==============

Imagine this scenario:

You already typed ./configure and you have some files filtered by SUBST_FILES
command into the configure.acr.

Then you modify one of the filtered files, instead of the .orig.

As you can see. Your final code will be overwritten by your Makefile and
configure will remove your original code by the .orig one.

This kind of problems can make you loss parts of code.

ACR 0.3 integrates a new feature in SUBST code that makes a diff between
foo and foo.backup. If they differ ./configure will fail showing an error
message.

To solve this just "diff -u foo.backup foo" and patch foo.orig using the
diff output by hand. This kind of stuff can't be fixed automatically, because
it's a programmer's problem.

Make sure to modify your Makefiles to use this new feature removing/checking
the .backup existence.

This feature could change in the future. But needs more feedback against
end users. Please, mail me about this feature explaining your ideas, fixes,
changes or proposals.

You can use this GNU-make function to check and cleanup properly your .orig
and .backup files. instead of using -rm ${FILE} you must use:

$(call unsubst,${FILE})

and the following function:

--------------------->8-----------------------
define unsubst
   @if [ -f "${1}.backup" ]; then\
      if [ -f "${1}" ]; then\
         if [ -n "`diff -u ${1} ${1}.backup`" ]; then\
            echo "It looks like '${1}' has changed. Check .backup peer."; \
            exit 1; \
         else\
            rm -f ${1}.backup;\
            mv ${1}.orig ${1};\
         fi\
      fi\
   fi
endef
-----------------------8<---------------------

A sample Makefile will look like:

---------------Makefile----------------
define unsubst
	(...)
endef

clean:
	$(call unsubst,CONFIG)
	$(call unsubst,src/config.h)
---------------------------------------