OSDN Git Service

Version 3.3.2+toward_4.0.0_20180629133501
[portsreinstall/current.git] / bin / portsreinstall
1 #!/bin/sh -e
2 # ==================================================================================
3 # portsreinstall main script
4 # Copyright (C) 2010-2018 Mamoru Sakaue, MwGhennndo, All Rights Reserved.
5 # This software is distributed under the 2-Clause BSD License.
6 # ==================================================================================
7
8 # ==================================================
9 # ================== ENVIRONMENT ===================
10 # ==================================================
11
12 # ============ Set up of environment =============
13 PROGRAM=portsreinstall
14 APPNAME=`basename "$0"`
15
16 MYPREFIX=`realpath "\`dirname \"$0\"\`"/..`
17 LIBDIR=${MYPREFIX}/lib/${PROGRAM}
18 LIBEXECDIR=${MYPREFIX}/libexec/${PROGRAM}
19 SHAREDIR=${MYPREFIX}/share/${PROGRAM}
20 ETCDIR=${MYPREFIX}/etc
21
22 . ${LIBDIR}/libcommand.sh
23 . ${LIBDIR}/libcommand_do.sh
24 . ${LIBDIR}/libcommand_flexconf.sh
25 . ${LIBDIR}/libcommand_forget.sh
26 . ${LIBDIR}/libcommand_pkgs.sh
27 . ${LIBDIR}/libcommand_show.sh
28 . ${LIBDIR}/libconf.sh
29 . ${LIBDIR}/libdatabase_build.sh
30 . ${LIBDIR}/libdatabase_maintain.sh
31 . ${LIBDIR}/libdatabase_query.sh
32 . ${LIBDIR}/libdatabase_record.sh
33 . ${LIBDIR}/libdeinstall.sh
34 . ${LIBDIR}/libfileedit.sh
35 . ${LIBDIR}/libmain.sh
36 . ${LIBDIR}/libmessage.sh
37 . ${LIBDIR}/libmisc.sh
38 . ${LIBDIR}/liboptions.sh
39 . ${LIBDIR}/libpkgsys.sh
40 . ${LIBDIR}/libprogram.sh
41 . ${LIBDIR}/libreinstall.sh
42 . ${LIBDIR}/libstr.sh
43 . ${LIBDIR}/libtemp.sh
44 . ${LIBDIR}/libusage.sh
45
46 . ${LIBDIR}/main/libcommand.sh
47 . ${LIBDIR}/main/liboptions.sh
48 . ${LIBDIR}/main/libtemp.sh
49 . ${LIBDIR}/main/libusage.sh
50
51 DBDIR=/var/tmp/${APPNAME}.db
52 CONFFILE=${ETCDIR}/${PROGRAM}.conf
53 PKGTOOLSCONF=${ETCDIR}/pkgtools.conf
54
55 main_set_version
56 misc_init_vardefs
57 temp_trap_init
58
59 # ==================================================
60 # ========= PARSING OPTIONS AND ARGUMENTS ==========
61 # ==================================================
62
63 main_parse_options_arguments "$@"
64
65 # ========================================================
66 # ================== SET UP OF PARAMETERS ==================
67 # ========================================================
68
69 main_setup_parameters "$@"
70
71 # =================================================================================
72 # ================== OPERATION WITHOUT PACKAGES MANAGEMENT TOOLS ==================
73 # =================================================================================
74
75 main_operation_without_pkg_management_tools "$@"
76
77 # ===================================================
78 # ================== SET UP OF TOOLS ==================
79 # ===================================================
80
81 # ============= Upgrade of tools =============
82
83 # Get the flavored port origin for this utility if installed by port
84 MYPORTORIGIN=`pkgsys_get_my_origin 2> /dev/null` || :
85
86 # Collect all installed packages
87 main_collect_all_installed_packages
88
89 # Preliminary inspection of tools which have to be up-to-date
90 main_preliminary_inspection_of_tools
91
92 # Upgrade of pkg(8) if new
93 main_upgrade_pkg8_if_new
94
95 # Upgrade of dialog4ports(1) if new
96 main_upgrade_dialog4ports1_if_new
97
98 # Upgrade of this utility if new
99 main_self_upgrade
100
101
102 # ==================================================
103 # ================== PREPARATION ===================
104 # ==================================================
105
106 # ============= Correspondence to configuration changes =============
107
108 # Overlay onto the temporary database by reflecting changes in configuration
109 main_reflect_conf_changes
110
111 # ============= Database construction =============
112
113 # Execute command operations which must be done before the database construction
114 command_all_exec_before_build_database "$@"
115
116 # Execute command operations of database construction
117 command_all_exec_build_database "$@"
118
119 # ==================================================
120 # ====================== MAIN ======================
121 # ==================================================
122
123 # Execute command operations which must be done before the main process
124 command_all_exec_before_main "$@"
125
126 # Execute command operations as the main process
127 command_all_exec_main "$@"