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

Last change on this file since 40142 was 40142, checked in by jmr@…, 12 years ago

Run a script in 'make install' and .dmg postflight which removes any duplicate entries from the dep_map (#8763)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 8.4 KB
Line 
1# $Id: macports.upgrade.mk 40142 2008-09-22 10:43:46Z jmr@macports.org $
2
3UPGRADECHECK    = ${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 ${TCL_PACKAGE_DIR}/darwinports1.0 ] || rm -rf ${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 ${datadir}/darwinports ] || rm -rf ${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 ${sysconfdir}/ports/dp_version ] || rm -vf ${sysconfdir}/ports/dp_version
18
19# Old ports.conf(5) man page is removed:
20        [ ! -f ${prefix}/share/man/man5/ports.conf.5 ] || rm -vf ${prefix}/share/man/man5/ports.conf.5
21
22# Conf files directory is renamed:
23        [ ! -d ${sysconfdir}/ports ] || mv -v ${sysconfdir}/ports ${sysconfdir}/macports
24
25# Important directories inside ${localstatedir}/db/dports are moved to their new location, creating it first:
26        [ -d ${localstatedir}/macports ] || mkdir -vp ${localstatedir}/macports
27        for dir in distfiles packages receipts software; do \
28                [ ! -d ${localstatedir}/db/dports/$${dir} ] || mv -v ${localstatedir}/db/dports/$${dir} ${localstatedir}/macports ; \
29        done
30
31# Move the default ports tree to the new layout:
32        [ ! -d ${localstatedir}/db/dports/sources/rsync.rsync.darwinports.org_dpupdate_dports ] || { mkdir -vp \
33                ${localstatedir}/macports/sources/rsync.macports.org/release && mv -v \
34                ${localstatedir}/db/dports/sources/rsync.rsync.darwinports.org_dpupdate_dports ${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 ${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 ${sysconfdir}/macports/ports.conf -a ! -f ${UPGRADECHECK} \) ] || { \
54                mv -v ${sysconfdir}/macports/ports.conf ${sysconfdir}/macports/macports.conf.mpsaved; \
55                sed 's/etc\/ports/etc\/macports/g' ${sysconfdir}/macports/macports.conf.mpsaved > ${sysconfdir}/macports/macports.conf.tmp && \
56                        mv -v ${sysconfdir}/macports/macports.conf.tmp ${sysconfdir}/macports/macports.conf; \
57                sed 's/db\/dports/macports/g' ${sysconfdir}/macports/macports.conf > ${sysconfdir}/macports/macports.conf.tmp && \
58                        mv -v ${sysconfdir}/macports/macports.conf.tmp ${sysconfdir}/macports/macports.conf; \
59                sed 's/darwinports/macports/g' ${sysconfdir}/macports/macports.conf > ${sysconfdir}/macports/macports.conf.tmp && \
60                        mv -v ${sysconfdir}/macports/macports.conf.tmp ${sysconfdir}/macports/macports.conf; \
61                sed 's/dpupdate1\/base/release\/base/g' ${sysconfdir}/macports/macports.conf > ${sysconfdir}/macports/macports.conf.tmp && \
62                        mv -v ${sysconfdir}/macports/macports.conf.tmp ${sysconfdir}/macports/macports.conf; \
63                sed 's/dpupdate\/base\/\{0,1\}/trunk\/base\//g' ${sysconfdir}/macports/macports.conf > ${sysconfdir}/macports/macports.conf.tmp && \
64                        mv -v ${sysconfdir}/macports/macports.conf.tmp ${sysconfdir}/macports/macports.conf; \
65                sed '/^rsync_options/s/"\(.*\)"/\1/' ${sysconfdir}/macports/macports.conf > ${sysconfdir}/macports/macports.conf.tmp && \
66                        mv -v ${sysconfdir}/macports/macports.conf.tmp ${sysconfdir}/macports/macports.conf; \
67                sed 's/ --delete / /' ${sysconfdir}/macports/macports.conf > ${sysconfdir}/macports/macports.conf.tmp && \
68                        mv -v ${sysconfdir}/macports/macports.conf.tmp ${sysconfdir}/macports/macports.conf; \
69                sed 's/ ports.conf(5)/ macports.conf(5)/g' ${sysconfdir}/macports/macports.conf > ${sysconfdir}/macports/macports.conf.tmp && \
70                        mv -v ${sysconfdir}/macports/macports.conf.tmp ${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 ${sysconfdir}/macports/sources.conf -a ! -f ${UPGRADECHECK} \) ] || { \
77                cp -v ${sysconfdir}/macports/sources.conf ${sysconfdir}/macports/sources.conf.mpsaved; \
78                sed 's/darwinports/macports/g' ${sysconfdir}/macports/sources.conf > ${sysconfdir}/macports/sources.conf.tmp && \
79                        mv -v ${sysconfdir}/macports/sources.conf.tmp ${sysconfdir}/macports/sources.conf; \
80                sed 's/dpupdate\/dports/release\/ports\//g' ${sysconfdir}/macports/sources.conf > ${sysconfdir}/macports/sources.conf.tmp && \
81                        mv -v ${sysconfdir}/macports/sources.conf.tmp ${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 "$${HOME}/.macports/ports.conf" -a ! -f ${UPGRADECHECK} \) ] || { \
94                mv -v "$${HOME}/.macports/ports.conf" "$${HOME}/.macports/macports.conf.mpsaved"; \
95                sed 's/etc\/ports/etc\/macports/g' "$${HOME}/.macports/macports.conf.mpsaved" > "$${HOME}/.macports/macports.conf.tmp" && \
96                        mv -v "$${HOME}/.macports/macports.conf.tmp" "$${HOME}/.macports/macports.conf"; \
97                sed 's/db\/dports/macports/g' "$${HOME}/.macports/macports.conf" > "$${HOME}/.macports/macports.conf.tmp" && \
98                        mv -v "$${HOME}/.macports/macports.conf.tmp" "$${HOME}/.macports/macports.conf"; \
99                sed 's/darwinports/macports/g' "$${HOME}/.macports/macports.conf" > "$${HOME}/.macports/macports.conf.tmp" && \
100                        mv -v "$${HOME}/.macports/macports.conf.tmp" "$${HOME}/.macports/macports.conf"; \
101                sed 's/dpupdate1\/base/release\/base/g' "$${HOME}/.macports/macports.conf" > "$${HOME}/.macports/macports.conf.tmp" && \
102                        mv -v "$${HOME}/.macports/macports.conf.tmp" "$${HOME}/.macports/macports.conf"; \
103                sed 's/dpupdate\/base\/\{0,1\}/trunk\/base\//g' "$${HOME}/.macports/macports.conf" > "$${HOME}/.macports/macports.conf.tmp" && \
104                        mv -v "$${HOME}/.macports/macports.conf.tmp" "$${HOME}/.macports/macports.conf"; \
105                sed '/^rsync_options/s/"\(.*\)"/\1/' "$${HOME}/.macports/macports.conf" > "$${HOME}/.macports/macports.conf.tmp" && \
106                        mv -v "$${HOME}/.macports/macports.conf.tmp" "$${HOME}/.macports/macports.conf"; \
107                sed 's/ --delete / /' "$${HOME}/.macports/macports.conf" > "$${HOME}/.macports/macports.conf.tmp" && \
108                        mv -v "$${HOME}/.macports/macports.conf.tmp" "$${HOME}/.macports/macports.conf"; \
109                sed 's/ ports.conf(5)/ macports.conf(5)/g' "$${HOME}/.macports/macports.conf" > "$${HOME}/.macports/macports.conf.tmp" && \
110                        mv -v "$${HOME}/.macports/macports.conf.tmp" "$${HOME}/.macports/macports.conf"; \
111        }
112
113# Remove duplicate entries from the dependency map (could occur with 1.6 and earlier):
114        $(TCLSH) src/dep_map_clean.tcl ${TCL_PACKAGE_DIR}
115
116# Upgrade success announcement (meaning we're done ;):
117        @[ -f ${UPGRADECHECK} ] || { echo ""; echo "MacPorts installation successfully upgraded from the old DarwinPorts namespace!"; echo ""; \
118                echo "MacPorts rename update done!" > ${UPGRADECHECK} ; }
Note: See TracBrowser for help on using the repository browser.