OSDN Git Service

Fixed a bug that some commands were broken when options are specified.
[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}/libfs.sh
36 . ${LIBDIR}/libmain.sh
37 . ${LIBDIR}/libmessage.sh
38 . ${LIBDIR}/libmisc.sh
39 . ${LIBDIR}/liboptions.sh
40 . ${LIBDIR}/libpkgsys.sh
41 . ${LIBDIR}/libprogram.sh
42 . ${LIBDIR}/libreinstall.sh
43 . ${LIBDIR}/libstr.sh
44 . ${LIBDIR}/libtemp.sh
45 . ${LIBDIR}/libusage.sh
46
47 . ${LIBDIR}/main/libcommand.sh
48 . ${LIBDIR}/main/liboptions.sh
49 . ${LIBDIR}/main/libtemp.sh
50 . ${LIBDIR}/main/libusage.sh
51
52 DBDIR=/var/tmp/${APPNAME}.db
53 CONFFILE=${ETCDIR}/${PROGRAM}.conf
54 PKGTOOLSCONF=${ETCDIR}/pkgtools.conf
55
56 main_set_version
57 misc_init_vardefs
58 temp_trap_init
59 database_maintain_reset_execflag
60
61 # ==================================================
62 # ========= PARSING OPTIONS AND ARGUMENTS ==========
63 # ==================================================
64
65 main_parse_options_arguments "$@"
66 shift "${OPTIONS_SHIFT}"
67
68 # ========================================================
69 # ================== SET UP OF PARAMETERS ==================
70 # ========================================================
71
72 main_setup_parameters "$@"
73
74 # =================================================================================
75 # ================== OPERATION WITHOUT PACKAGES MANAGEMENT TOOLS ==================
76 # =================================================================================
77
78 main_operation_without_pkg_management_tools "$@"
79
80 # ===================================================
81 # ================== SET UP OF TOOLS ==================
82 # ===================================================
83
84 # ============= Upgrade of tools =============
85
86 # Get the flavored port origin for this utility if installed by port
87 MYPORTORIGIN=`pkgsys_get_my_origin 2> /dev/null` || :
88
89 # Collect all installed packages
90 main_collect_all_installed_packages
91
92 # Preliminary inspection of tools which have to be up-to-date
93 main_preliminary_inspection_of_tools
94
95 # Upgrade of pkg(8) if new
96 main_upgrade_pkg8_if_new
97
98 # Upgrade of dialog4ports(1) if new
99 main_upgrade_dialog4ports1_if_new
100
101 # Upgrade of this utility if new
102 main_self_upgrade
103
104
105 # ==================================================
106 # ================== PREPARATION ===================
107 # ==================================================
108
109 # ============= Correspondence to configuration changes =============
110
111 # Overlay onto the temporary database by reflecting changes in configuration
112 main_reflect_conf_changes
113
114 # ============= Database construction =============
115
116 # Execute command operations which must be done before the database construction
117 command_all_exec_before_build_database "$@"
118
119 # Execute command operations of database construction
120 command_all_exec_build_database "$@"
121
122 # ==================================================
123 # ====================== MAIN ======================
124 # ==================================================
125
126 # Execute command operations which must be done before the main process
127 command_all_exec_before_main "$@"
128
129 # Execute command operations as the main process
130 command_all_exec_main "$@"