source: trunk/base/Mk/macports.upgrade.mk @ 50395

Last change on this file since 50395 was 48209, checked in by blb@…, 11 years ago

base/Mk/macports.upgrade.mk - make sure to always respect DESTDIR

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 9.3 KB
Line 
1# $Id: macports.upgrade.mk 48209 2009-03-17 00:32:47Z blb@macports.org $
2
3UPGRADECHECK    = $(DESTDIR)${localstatedir}/macports/.mprename
4
5
6upgrade::
7        @echo ""; echo "Upgrading your existing MacPorts installation to the new namespace if necessary:"; echo ""
8
9# We can safely delete the ${TCL_PACKAGE_DIR}/darwinports1.0 dir as files in it are always overwritten and will now be installed onto
10# ${TCL_PACKAGE_DIR}/macports1.0 with new names:
11        [ ! -d $(DESTDIR)${TCL_PACKAGE_DIR}/darwinports1.0 ] || rm -rf $(DESTDIR)${TCL_PACKAGE_DIR}/darwinports1.0
12
13# MacPorts base files in ${datadir} are also safely removed as new ones are always installed, and onto a their new location in this case too:
14        [ ! -d $(DESTDIR)${datadir}/darwinports ] || rm -rf $(DESTDIR)${datadir}/darwinports
15
16# Old version file can be safely deleted, as it was already used to start this upgrade and a new one will be installed into the new location:
17        [ ! -f $(DESTDIR)${sysconfdir}/ports/dp_version ] || rm -vf $(DESTDIR)${sysconfdir}/ports/dp_version
18
19# Old ports.conf(5) man page is removed:
20        [ ! -f $(DESTDIR)${prefix}/share/man/man5/ports.conf.5 ] || rm -vf $(DESTDIR)${prefix}/share/man/man5/ports.conf.5
21
22# Conf files directory is renamed:
23        [ ! -d $(DESTDIR)${sysconfdir}/ports ] || mv -v $(DESTDIR)${sysconfdir}/ports $(DESTDIR)${sysconfdir}/macports
24
25# Important directories inside ${localstatedir}/db/dports are moved to their new location, creating it first:
26        [ -d $(DESTDIR)${localstatedir}/macports ] || mkdir -vp $(DESTDIR)${localstatedir}/macports
27        for dir in distfiles packages receipts software; do \
28                [ ! -d $(DESTDIR)${localstatedir}/db/dports/$${dir} ] || mv -v $(DESTDIR)${localstatedir}/db/dports/$${dir} $(DESTDIR)${localstatedir}/macports ; \
29        done
30
31# Move the default ports tree to the new layout:
32        [ ! -d $(DESTDIR)${localstatedir}/db/dports/sources/rsync.rsync.darwinports.org_dpupdate_dports ] || { mkdir -vp \
33                $(DESTDIR)${localstatedir}/macports/sources/rsync.macports.org/release && mv -v \
34                $(DESTDIR)${localstatedir}/db/dports/sources/rsync.rsync.darwinports.org_dpupdate_dports $(DESTDIR)${localstatedir}/macports/sources/rsync.macports.org/release/ports ; \
35        }
36
37# Open up receipts and upgrade any paths in them containing old conventions to the new namespace:
38        for receipt in $(DESTDIR)${localstatedir}/macports/receipts/*/*/receipt.bz2 ; do [ ! \( -f $${receipt} -a ! -f $${receipt}.mpsaved \) ] || { \
39                cp -v $${receipt} $${receipt}.mpsaved && { \
40                        $(BZIP2) -q -dc $${receipt} | sed 's/db\/dports/macports/g' | $(BZIP2) -q -zf > $${receipt}.new ; \
41                } && mv -v $${receipt}.new $${receipt} ; \
42        }; done
43
44# Check for existance of the main configuration file and perform a couple of replacements on it, backing it up first:
45## 1) new default path up to our configuration files (referenced through other variables);
46## 2) new default value for the portdbpath variable;
47## 3) new MacPorts rsync server;
48## 4) new default value for the base tree;
49## 5) new default value for trunk's base sources for users who have it (some do);
50## 6) stray quotes are removed from the value of the rsync_options key in old conf files;
51## 7) useless --delete option is removed from the default rsync flags (--delete is implied by --delete-after);
52## 8) references to the old ports.conf(5) man page are updated to the new macports.conf(5) page;
53        [ ! \( -f $(DESTDIR)${sysconfdir}/macports/ports.conf -a ! -f ${UPGRADECHECK} \) ] || { \
54                mv -v $(DESTDIR)${sysconfdir}/macports/ports.conf $(DESTDIR)${sysconfdir}/macports/macports.conf.mpsaved; \
55                sed 's/etc\/ports/etc\/macports/g' $(DESTDIR)${sysconfdir}/macports/macports.conf.mpsaved > $(DESTDIR)${sysconfdir}/macports/macports.conf.tmp && \
56                        mv -v $(DESTDIR)${sysconfdir}/macports/macports.conf.tmp $(DESTDIR)${sysconfdir}/macports/macports.conf; \
57                sed 's/db\/dports/macports/g' $(DESTDIR)${sysconfdir}/macports/macports.conf > $(DESTDIR)${sysconfdir}/macports/macports.conf.tmp && \
58                        mv -v $(DESTDIR)${sysconfdir}/macports/macports.conf.tmp $(DESTDIR)${sysconfdir}/macports/macports.conf; \
59                sed 's/darwinports/macports/g' $(DESTDIR)${sysconfdir}/macports/macports.conf > $(DESTDIR)${sysconfdir}/macports/macports.conf.tmp && \
60                        mv -v $(DESTDIR)${sysconfdir}/macports/macports.conf.tmp $(DESTDIR)${sysconfdir}/macports/macports.conf; \
61                sed 's/dpupdate1\/base/release\/base/g' $(DESTDIR)${sysconfdir}/macports/macports.conf > $(DESTDIR)${sysconfdir}/macports/macports.conf.tmp && \
62                        mv -v $(DESTDIR)${sysconfdir}/macports/macports.conf.tmp $(DESTDIR)${sysconfdir}/macports/macports.conf; \
63                sed 's/dpupdate\/base\/\{0,1\}/trunk\/base\//g' $(DESTDIR)${sysconfdir}/macports/macports.conf > $(DESTDIR)${sysconfdir}/macports/macports.conf.tmp && \
64                        mv -v $(DESTDIR)${sysconfdir}/macports/macports.conf.tmp $(DESTDIR)${sysconfdir}/macports/macports.conf; \
65                sed '/^rsync_options/s/"\(.*\)"/\1/' $(DESTDIR)${sysconfdir}/macports/macports.conf > $(DESTDIR)${sysconfdir}/macports/macports.conf.tmp && \
66                        mv -v $(DESTDIR)${sysconfdir}/macports/macports.conf.tmp $(DESTDIR)${sysconfdir}/macports/macports.conf; \
67                sed 's/ --delete / /' $(DESTDIR)${sysconfdir}/macports/macports.conf > $(DESTDIR)${sysconfdir}/macports/macports.conf.tmp && \
68                        mv -v $(DESTDIR)${sysconfdir}/macports/macports.conf.tmp $(DESTDIR)${sysconfdir}/macports/macports.conf; \
69                sed 's/ ports.conf(5)/ macports.conf(5)/g' $(DESTDIR)${sysconfdir}/macports/macports.conf > $(DESTDIR)${sysconfdir}/macports/macports.conf.tmp && \
70                        mv -v $(DESTDIR)${sysconfdir}/macports/macports.conf.tmp $(DESTDIR)${sysconfdir}/macports/macports.conf; \
71        }
72
73# Check for existance of the main sources file and perform a couple of replacements on it, backing it up first:
74## 1) new MacPorts rsync server;
75## 2) new default value for the ports tree.
76        [ ! \( -f $(DESTDIR)${sysconfdir}/macports/sources.conf -a ! -f ${UPGRADECHECK} \) ] || { \
77                cp -v $(DESTDIR)${sysconfdir}/macports/sources.conf $(DESTDIR)${sysconfdir}/macports/sources.conf.mpsaved; \
78                sed 's/darwinports/macports/g' $(DESTDIR)${sysconfdir}/macports/sources.conf > $(DESTDIR)${sysconfdir}/macports/sources.conf.tmp && \
79                        mv -v $(DESTDIR)${sysconfdir}/macports/sources.conf.tmp $(DESTDIR)${sysconfdir}/macports/sources.conf; \
80                sed 's/dpupdate\/dports/release\/ports\//g' $(DESTDIR)${sysconfdir}/macports/sources.conf > $(DESTDIR)${sysconfdir}/macports/sources.conf.tmp && \
81                        mv -v $(DESTDIR)${sysconfdir}/macports/sources.conf.tmp $(DESTDIR)${sysconfdir}/macports/sources.conf; \
82        }
83
84# Check for existance of a personal configuration file and perform a couple of replacements on it, backing it up first:
85## 1) new default path up to our configuration files (referenced through other variables);
86## 2) new default value for the portdbpath variable;
87## 3) new MacPorts rsync server;
88## 4) new default value for the base tree;
89## 5) new default value for trunk's base sources for users who have it (some do);
90## 6) stray quotes are removed from the value of the rsync_options key in old conf files;
91## 7) useless --delete option is removed from the default rsync flags (--delete is implied by --delete-after);
92## 8) references to the old ports.conf(5) man page are updated to the new macports.conf(5) page;
93        [ ! \( -f "$(DESTDIR)$${HOME}/.macports/ports.conf" -a ! -f ${UPGRADECHECK} \) ] || { \
94                mv -v "$(DESTDIR)$${HOME}/.macports/ports.conf" "$(DESTDIR)$${HOME}/.macports/macports.conf.mpsaved"; \
95                sed 's/etc\/ports/etc\/macports/g' "$(DESTDIR)$${HOME}/.macports/macports.conf.mpsaved" > "$(DESTDIR)$${HOME}/.macports/macports.conf.tmp" && \
96                        mv -v "$(DESTDIR)$${HOME}/.macports/macports.conf.tmp" "$(DESTDIR)$${HOME}/.macports/macports.conf"; \
97                sed 's/db\/dports/macports/g' "$(DESTDIR)$${HOME}/.macports/macports.conf" > "$(DESTDIR)$${HOME}/.macports/macports.conf.tmp" && \
98                        mv -v "$(DESTDIR)$${HOME}/.macports/macports.conf.tmp" "$(DESTDIR)$${HOME}/.macports/macports.conf"; \
99                sed 's/darwinports/macports/g' "$(DESTDIR)$${HOME}/.macports/macports.conf" > "$(DESTDIR)$${HOME}/.macports/macports.conf.tmp" && \
100                        mv -v "$(DESTDIR)$${HOME}/.macports/macports.conf.tmp" "$(DESTDIR)$${HOME}/.macports/macports.conf"; \
101                sed 's/dpupdate1\/base/release\/base/g' "$(DESTDIR)$${HOME}/.macports/macports.conf" > "$(DESTDIR)$${HOME}/.macports/macports.conf.tmp" && \
102                        mv -v "$(DESTDIR)$${HOME}/.macports/macports.conf.tmp" "$(DESTDIR)$${HOME}/.macports/macports.conf"; \
103                sed 's/dpupdate\/base\/\{0,1\}/trunk\/base\//g' "$(DESTDIR)$${HOME}/.macports/macports.conf" > "$(DESTDIR)$${HOME}/.macports/macports.conf.tmp" && \
104                        mv -v "$(DESTDIR)$${HOME}/.macports/macports.conf.tmp" "$(DESTDIR)$${HOME}/.macports/macports.conf"; \
105                sed '/^rsync_options/s/"\(.*\)"/\1/' "$(DESTDIR)$${HOME}/.macports/macports.conf" > "$(DESTDIR)$${HOME}/.macports/macports.conf.tmp" && \
106                        mv -v "$(DESTDIR)$${HOME}/.macports/macports.conf.tmp" "$(DESTDIR)$${HOME}/.macports/macports.conf"; \
107                sed 's/ --delete / /' "$(DESTDIR)$${HOME}/.macports/macports.conf" > "$(DESTDIR)$${HOME}/.macports/macports.conf.tmp" && \
108                        mv -v "$(DESTDIR)$${HOME}/.macports/macports.conf.tmp" "$(DESTDIR)$${HOME}/.macports/macports.conf"; \
109                sed 's/ ports.conf(5)/ macports.conf(5)/g' "$(DESTDIR)$${HOME}/.macports/macports.conf" > "$(DESTDIR)$${HOME}/.macports/macports.conf.tmp" && \
110                        mv -v "$(DESTDIR)$${HOME}/.macports/macports.conf.tmp" "$(DESTDIR)$${HOME}/.macports/macports.conf"; \
111        }
112
113# Upgrade success announcement (meaning we're done ;):
114        @[ -f ${UPGRADECHECK} ] || { echo ""; echo "MacPorts installation successfully upgraded from the old DarwinPorts namespace!"; echo ""; \
115                echo "MacPorts rename update done!" > ${UPGRADECHECK} ; }
Note: See TracBrowser for help on using the repository browser.