My Modifications to mint-make

Questions about mintInstall and the Software Portal
Forum rules
Before you post please read this

My Modifications to mint-make

Postby facade47 on Tue Jul 10, 2007 7:02 am

I had an idea to try to make a bash program which would automatically create .mint files from a list of programs I provided. This would mean that I could feed the script a list of all the programs in gnome-app-install (or whatever that program was), and have it generate all those mint files for the portal. :D

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 ;) :lol:

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 ;) ... here's the code:

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")
User avatar
facade47
Level 3
Level 3
 
Posts: 152
Joined: Fri Feb 16, 2007 4:46 am

Linux Mint is funded by ads and donations.
 

Postby facade47 on Tue Jul 10, 2007 7:36 am

Ack, apparently I can't modify that post.. :(

I just realized that a lot of the icons are also stored in /usr/share/icons/hicolor/48x48/apps, so here is an updated tryToGetIcon() method:

Code: Select all
def tryToGetIcon(name):
   pixDir = ["/usr/share/pixmaps/", "/usr/share/icons/hicolor/48x48/apps/"]
   width = "48"
   height = "48"

   icon = "ThereIsNoIconHereHaha"
   trying = [name + ".png", name + "-icon.png", name + "_icon.png"]
   for folder in pixDir:
      for trial in trying:
         if os.path.exists(folder + trial): icon = folder + 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")
User avatar
facade47
Level 3
Level 3
 
Posts: 152
Joined: Fri Feb 16, 2007 4:46 am

Postby clem on Tue Jul 10, 2007 9:25 am

Now this is really cool !!! If I was to go further in this idea (I had it before, and Eric also.. but we gave up on it) I would ask the batch file to also generate an SQL import file for the portal... :)

and...

we should have a mint-check... which checks the validity of a mint file (decompresses well...etc).

Ideally it would be the same script which would check the mint files and generate the SQL for me.

For each mint file:
- decompress it
- get the name, description, and repository
- generate SQL for inserting these in the DB.
- delete the decompressed folder

The only manual steps left would then be:
- screenshots
- application's website
- license

Clem
Image
User avatar
clem
Level 14
Level 14
 
Posts: 5387
Joined: Wed Nov 15, 2006 8:34 am

Postby facade47 on Tue Jul 10, 2007 9:50 am

Yay, I'm glad you like it :D
OK, now it's time for me to learn SQL :P .. do you know any good tutorials? That's definately a good idea.. I was just thinking it would be nice to have a list of all the apps in the portal =)
User avatar
facade47
Level 3
Level 3
 
Posts: 152
Joined: Fri Feb 16, 2007 4:46 am

Postby clem on Tue Jul 10, 2007 10:36 am

SELECT field1, field2 FROM table WHERE field1 = value1
INSERT INTO table (field1, field2..etc) VALUES (value1, value2..etc)
UPDATE table set field1 = value1 WHERE field2 = value2
DELETE from table WHERE field1 = value1

As you can see it's pretty basic :) There's a lot of documentation on the Web about SQL and you'll have it fully learnt in a few days.

I'll take care of that though. I need to go in my holidays and you don't know the structure of my database ;)

Clem
Image
User avatar
clem
Level 14
Level 14
 
Posts: 5387
Joined: Wed Nov 15, 2006 8:34 am

Postby facade47 on Tue Jul 10, 2007 10:53 am

cool :)
let me know what you want me to do :D .. I have absolutely no experience with databases, other than that I know what they're used for (storing stuff, right?? :P)

Have tons of fun on your vacation!!! :D
User avatar
facade47
Level 3
Level 3
 
Posts: 152
Joined: Fri Feb 16, 2007 4:46 am


Return to mintInstall

Who is online

Users browsing this forum: No registered users and 0 guests