Commit 2feb4b61 authored by Lisa's avatar Lisa now also generates the mirrorlist (with args for source... now also generates the mirrorlist (with args for source and dest paths), and it supports running with python3 too.
parent 1aa5da5e
# A script to convert a Pacman config file into an Akabei config file
# A script to convert a Pacman config file and mirrorlist into an
# Akabei config file and mirrorlist.
# Copyright (C) 2011 Lisa Vitolo <>
# Copyright (C) 2011 Lisa Vitolo <>
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public
......@@ -51,25 +52,45 @@ def parseOptionLine(line, akabeiConf):
# There is no format conversion to do here, we just copy the
# whole content.
def CopyMirrorlist(pacmanMirrorFile, akabeiMirrorFile):
pacmanMirrors = ''
with open(pacmanMirrorFile, 'r') as pm:
pacmanMirrors =
with open(akabeiMirrorFile, 'w') as am:
# Prints an help message
def usage():
print "usage: " + sys.argv[0] + " [--help] [--pacman=<path to pacman.conf>] [--akabei=<path to akabei.conf>]"
print("usage: " + sys.argv[0] + " [--help] [--pacman=<path to pacman.conf>] [--akabei=<path to akabei.conf>]")
print "Options:"
print " -h, --help Prints this help message"
print " -p, --pacman <file> Reads pacman configuration from <file> (default: /etc/pacman.conf)"
print " -a, --akabei <file> Writes akabei configuration in <file> (default: /etc/akabei.conf)"
print(" -h, --help Prints this help message")
print(" -p, --pacman <file> Reads pacman configuration from <file> (default: /etc/pacman.conf)")
print(" -a, --akabei <file> Writes akabei configuration in <file> (default: /etc/akabei.conf)")
print(" -m, --pacman-mirrors <file> Reads pacman mirrorlist from <file> (default: /etc/pacman.d/mirrorlist)")
print(" -n --akabei-mirrors <file> Writes akabei mirrorlist to <file> (default: /etc/akabei.d/mirrorlist))")
print("Note: if your destination paths already exists, they will be overwritten.")
# Start point
if __name__ == "__main__":
# Default values for the commandline arguments.
pacmanFile = "/etc/pacman.conf"
akabeiFile = "/etc/akabei.conf"
pacmanMirrorFile = "/etc/pacman.d/mirrorlist"
akabeiMirrorFile = "/etc/akabei.d/mirrorlist"
opts = None
opts = getopt.getopt(sys.argv[1:], "hp:a:", ["help", "pacman=", "akabei="])
except getopt.GetoptError, error:
print str(error)
opts = getopt.getopt(
sys.argv[1:], "hp:a:m:n:",
["help", "pacman=", "akabei=", "pacman-mirrors=", "akabei-mirrors="])
except getopt.GetoptError as error:
......@@ -81,6 +102,10 @@ if __name__ == "__main__":
pacmanFile = arg
elif opt in ("-a", "--akabei"):
akabeiFile = arg
elif opt in ("-m", "--pacman-mirrors"):
pacmanMirrorFile = arg
elif opt in ("-n", "--akabei-mirrors"):
akabeiMirrorFile = arg
pacmanConf = None
akabeiConf = None
......@@ -88,11 +113,12 @@ if __name__ == "__main__":
pacmanConf = open(pacmanFile, "r")
akabeiConf = open(akabeiFile, "w")
except IOError, error:
print str(error)
except IOError as error:
for pacmanLine in pacmanConf.readlines():
if pacmanLine == "\n" or "[options]" in pacmanLine:
......@@ -117,6 +143,9 @@ if __name__ == "__main__":
# they are be deleted/modified to avoid confusion for the reader
parseOptionLine(separatedLine[2], akabeiConf)
print "[**] Your akabei configuration was created successfully. Exiting..."
print("[**] Your akabei configuration was created successfully.")
\ No newline at end of file
CopyMirrorlist(pacmanMirrorFile, akabeiMirrorFile)
print("[**] Your akabei mirrorlist was created successfully.")
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment