]> code.delx.au - refind/commitdiff
Improvements to refind-mkdefault, including packaging files.
authorsrs5694 <srs5694@users.sourceforge.net>
Fri, 29 Jan 2016 13:47:54 +0000 (08:47 -0500)
committersrs5694 <srs5694@users.sourceforge.net>
Fri, 29 Jan 2016 13:47:54 +0000 (08:47 -0500)
debian/copyright
debian/refind.install
mkdistrib
refind-mkdefault
refind.spec

index e274f2ef2e303c50650192775cdc35e587afb8d2..d1f0300bb223948664fca5933749f9f44dbf0419 100644 (file)
@@ -31,6 +31,10 @@ Files: mkrlconf
 Copyright: 2012-2015 Roderick W. Smith
 License: GPL-3+
 
+Files: refind-mkdefault
+Copyright: 2016 Roderick W. Smith
+License: GPL-3+
+
 Files: mountesp
 Copyright: 2015 Roderick W. Smith
 License: GPL-3+
index a036f04e35db325fa95c81f819cd639827920cf3..0d898edc1d6c8dbb8c3adb761a4781354940d10a 100644 (file)
@@ -7,6 +7,7 @@ icons/README usr/share/refind/refind/icons
 keys etc/refind.d
 mkrlconf usr/sbin
 mvrefind usr/sbin
+refind-mkdefault usr/sbin
 refind-install usr/share/refind
 refind.conf-sample usr/share/refind/refind
 refind/refind*.efi usr/share/refind/refind
index bb7fbd029d1d73abb7f629ee6dad60a5142d35df..6e46866b5e14305f807fae54ce35d01255ce2f66 100755 (executable)
--- a/mkdistrib
+++ b/mkdistrib
@@ -70,8 +70,8 @@ MakeTarball() {
     cp --preserve=timestamps -r icons/licenses/* $TargetDir/refind-$Version/icons/licenses/
     cp --preserve=timestamps -r icons/svg/* $TargetDir/refind-$Version/icons/svg/
     cp -a debian docs images keys fonts banners include EfiLib libeg mok net refind filesystems \
-        gptsync refind.spec refind-install mkrlconf mvrefind mountesp CREDITS.txt NEWS.txt BUILDING.txt \
-        COPYING.txt LICENSE.txt README.txt refind.inf Make.common Makefile \
+        gptsync refind.spec refind-install refind-mkdefault mkrlconf mvrefind mountesp CREDITS.txt \
+        NEWS.txt BUILDING.txt COPYING.txt LICENSE.txt README.txt refind.inf Make.common Makefile \
         refind.conf-sample $TargetDir/refind-$Version
 
     # Go there and prepare a souce code tarball....
@@ -143,7 +143,7 @@ MakeZipBinary() {
         cp --preserve=timestamps gptsync/gptsync_x64.efi refind-bin-$Version/refind/tools_x64/
     fi
     cp refind-bin-$Version/refind/refind_x64.efi $StartDir
-    cp -a docs keys banners fonts COPYING.txt LICENSE.txt README.txt CREDITS.txt NEWS.txt refind-install mkrlconf mvrefind mountesp refind-bin-$Version
+    cp -a docs keys banners fonts COPYING.txt LICENSE.txt README.txt CREDITS.txt NEWS.txt refind-install refind-mkdefault mkrlconf mvrefind mountesp refind-bin-$Version
 
     # Prepare the final .zip file
     zip -9r ../refind-bin-$Version.zip refind-bin-$Version
@@ -223,6 +223,7 @@ rm -rf debian/refind debian/*.log
 # Convert man pages to HTML form
 man2html docs/man/mkrlconf.8 > docs/refind/mkrlconf.html
 man2html docs/man/mvrefind.8 > docs/refind/mvrefind.html
+man2html docs/man/refind-mkdefault.8 > docs/refind/refind-mkdefault.html
 man2html docs/man/refind-install.8 > docs/refind/refind-install.html
 
 mkdir -p ../snapshots/$Version
index 325d38239f0eac4f4e6b00e61586a7091fcc317a..7f673db46edf25f8a275441935514908bb6117c4 100755 (executable)
@@ -23,6 +23,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 """
 
 import os
+import shlex
 import shutil
 import sys
 
@@ -37,7 +38,7 @@ def discover_data():
         boot_entries, boot_order
     """
     command = "efibootmgr -v"
-    bootinfo_bytes = (Popen(command, stdout=PIPE, shell=True)
+    bootinfo_bytes = (Popen(shlex.split(command), stdout=PIPE)
                       .communicate()[0])
     bootinfo = (bootinfo_bytes.decode(encoding="utf-8", errors="ignore")
                 .splitlines())
@@ -142,6 +143,8 @@ def set_refind_first(boot_entries, boot_order, label):
 def save_changes(boot_order):
     """Save an altered boot_order.
 
+    :param boot_order:
+        List of boot numbers as strings, in boot order
     :returns:
         True if there were no problems, False otherwise
     """
@@ -149,7 +152,7 @@ def save_changes(boot_order):
     command = "efibootmgr -o {}".format(order_string)
     print("Setting a boot order of {}".format(order_string))
     try:
-        Popen(command, stdout=PIPE, shell=True).communicate()[0]
+        Popen(shlex.split(command), stdout=PIPE).communicate()[0]
     except:
         print("An error occurred setting the new boot order!")
 
@@ -160,7 +163,7 @@ def main():
     parser = ArgumentParser(description=description)
     parser.add_argument("-L", "--label",
                         default="rEFInd",
-                        help=("The label used to identify rEFInd"))
+                        help=("The label used to identify rEFInd (default=rEFInd)"))
     args = parser.parse_args()
 
     if sys.platform != "linux":
@@ -170,7 +173,7 @@ def main():
         print("The efibootmgr utility is not installed; exiting!")
         return(1)
     if not os.geteuid() == 0:
-        print("You must be root to run this program")
+        print("This program must be run as root (or via sudo); exiting!")
         return(1)
 
     problems = False
@@ -178,12 +181,12 @@ def main():
     boot_entries, boot_order = discover_data()
     if boot_entries == {}:
         problems = True
-        print("No EFI boot entries available. This may indicate a firmware problem.")
+        print("No EFI boot entries are available. This may indicate a firmware problem.")
     if boot_order == []:
         problems = True
         print("The EFI BootOrder variable is not available. This may indicate a firmware")
         print("problem.")
-    if (boot_entries != {} and boot_order != [] and
+    if (not problems and
             set_refind_first(boot_entries, boot_order, args.label)):
         save_changes(boot_order)
     else:
index 18b8b6e4d26e77be733e5df28e0a2647f32babcb..29bbd8440c1e87c4370a23c55b30a3c5b21240e4 100644 (file)
@@ -99,6 +99,7 @@ mkdir -p $RPM_BUILD_ROOT/usr/share/man/man8
 install -Dp -m0644 docs/man/mvrefind.8 $RPM_BUILD_ROOT/usr/share/man/man8
 install -Dp -m0644 docs/man/mkrlconf.8 $RPM_BUILD_ROOT/usr/share/man/man8
 install -Dp -m0644 docs/man/refind-install.8 $RPM_BUILD_ROOT/usr/share/man/man8
+install -Dp -m0644 docs/man/refind-mkdefault.8 $RPM_BUILD_ROOT/usr/share/man/man8
 
 # Copy keys to /etc/refind.d/keys
 mkdir -p $RPM_BUILD_ROOT/etc/refind.d/keys
@@ -108,6 +109,7 @@ install -Dp -m0644 keys/* $RPM_BUILD_ROOT/etc/refind.d/keys
 mkdir -p $RPM_BUILD_ROOT/usr/sbin
 install -Dp -m0755 mkrlconf $RPM_BUILD_ROOT/usr/sbin/
 install -Dp -m0755 mvrefind $RPM_BUILD_ROOT/usr/sbin/
+install -Dp -m0755 refind-mkdefault $RPM_BUILD_ROOT/usr/sbin/
 ln -sr $RPM_BUILD_ROOT/usr/share/refind-%{version}/refind-install $RPM_BUILD_ROOT/usr/sbin
 
 # Copy banners and fonts to /usr/share/refind-%{version}
@@ -124,6 +126,7 @@ cp -a fonts $RPM_BUILD_ROOT/usr/share/refind-%{version}/
 /usr/sbin/mkrlconf
 /usr/sbin/mvrefind
 /usr/sbin/refind-install
+/usr/sbin/refind-mkdefault
 /usr/share/refind-%{version}
 /etc/refind.d/