OSDN Git Service

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