In order to do that, I had to modify mint-make so it would accept arguments...
man wrote:SYNOPSIS
mint-make [program [needsRepository]]
that was just for you, scorp
I changed it so that that the user no longer has to look into "aptitude show program" to find the description if the program name is passed as an argument (if no arguments are passed, mint-make defaults to the original method)
I also try a feeble attempt to find the icon, and then resize it to 48x48 (it took me FOREVER to find a working GPL'd gimp script-fu to resize the icons, and I heavily edited it to get it to do what I wanted).
Also I tried to catch any mistakes in typing y/n for the repository... this way also if you only type in "mint-make program", it will still ask if you need a repo.
I still haven't made the bash script to generate all those .mint files, but I'll let y'all know how it turns out =)
Sorry for the long description
mint-make
- Code: Select all
#!/usr/bin/env python
#mint-make
import sys
import os
import commands
#___________________________________
def getRepository():
repository = "wrong"
while repository != "y" and repository != "n":
repository = raw_input("Do you need to enter a repository? (y or n): ").lower()[0]
return repository
#____________________________________
def tryToGetIcon(name):
pixDir = "/usr/share/pixmaps/"
width = "48"
height = "48"
icon = "ThereIsNoIconHereHaha"
trying = [name + ".png", name + "-icon.png", name + "_icon.png"]
for trial in trying:
if os.path.exists(pixDir + trial): icon = pixDir + trial
if icon != "ThereIsNoIconHereHaha":
print "-------Ignore the output from GIMP -------"
os.system("gimp -i -b '(let* ((image (car (file-png-load 1 "" + \
icon + "" "" + icon +"")))(drawable (car (gimp-image-active-drawable image))))" + \
"(gimp-image-scale image " + width + " " + height + ")(file-png-save 1 image drawable " + \
""./icon.png" "./icon.png" 1 0 0 0 0 0 0 ))' '(gimp-quit 0)'")
print "------------------------------------------"
os.system("mv icon.png icon")
#____________________________________
args = sys.argv[1:]
home = os.environ["HOME"]
if args:
name = args[0]
raw_name = str.replace(name, " ", "")
raw_name = name.lower()
description = ""
pipe = os.popen("aptitude show " + name + " | grep Description")
description = pipe.readline()[13:-1] # Get rid of the lead phrase "Description: "
pipe.close()
# If the user sent a second option (whether or not there needs a repository),
# then we set repository to the first character, lower-cased. If not, or incorrect
# input was given, it will be caught in the line following this if/else statement.
repository = ""
if len(args) > 1: repository = args[1].lower()[0]
else:
name = raw_input("name: ")
raw_name = str.replace(name, " ", "")
raw_name = raw_name.lower()
description = raw_input("description: ")
repository = raw_input("need repository? (y or n): ").lower()[0]
if repository != "y" and repository != "n": repository = getRepository()
directory = raw_name
os.mkdir(directory)
os.chdir(directory)
os.system("echo " + name + " > name")
os.system("echo " + description + " > description")
os.system("cp /usr/lib/linuxmint/mintInstall/icon .")
pipe = os.popen("which gimp")
hasGimp = pipe.readline()
pipe.close()
if hasGimp: tryToGetIcon(raw_name)
os.mkdir("steps")
os.chdir("steps")
if (repository == "y"):
os.system("echo "TITLE Adding 3rd Party Repository" > 1")
os.system("echo "SOURCE deb specify_repository_here" >> 1")
os.system("echo "TITLE Installing " + name + "" > 2")
os.system("echo "INSTALL " + raw_name + "" >> 2")
else:
os.system("echo "TITLE Installing " + name + "" > 1")
os.system("echo "INSTALL " + raw_name + "" >> 1")




