Archive for the ‘Tips’ Category

Git tips from Jaka Kranjc

Sunday, June 29th, 2008

Jaka “lynx” Kranjc sent us this helpful bit of information on working with Git and our grimoires, mostly for developers.

I noticed a long drought on magepower, so here are some git tips (mostly) for developers:

You can see the contents of files in other branches or tags without checkout-ing them first:

navaden@lynxlynx main-grim 0 $ git show :VERSION
0.19-test
navaden@lynxlynx main-grim 0 $ git show my-stable-rc:VERSION
0.18-rc

All git commands are accessible directly. So by using dashes instead of spaces, you can reap the benefits of tab completition. It shines for longer commands like git-update-index or git-cherry-pick. Also all the man pages need to be called this way.

Through long time use, the git repository gains some dead weight. You can remove it and reoptimise the repo by running git-gc.

Here’s a handy git-commit wrapper. It will shorten the writting of the commit message by adding the basename of the first argument and a colon as the initial commit message:

git-commit(){
  command git-commit -e -m "$(basename -- $1):" "$@";
}

git-commit smgl/guru-tools/ ChangeLog would result in “guru-tools:”.

Not many people do cherry-picking, but for those who do, we have an informal policy that the -x option needs to be passed to git (adds the originating commit to the commit message). In older git 1.4 versions it was on by default, but this has changed since.

alias git-cherry-pick="git-cherry-pick -x"

If you want to reset only a part of the repository, you’ll have to use a trick (git-reset --hard can’t work on single files):

git diff some/path | patch -p1 -R

Which should do it in most cases, but will likely fail for binaries. Here is an alternative approach which doesn’t have that problem:

git-dir-reset(){
  rm -r $1/*
  git-archive --format=tar ${2:-HEAD}:$1 | tar -x -C $1
}

You could also do it via git-checkout, which can do single files too.

A few tips from Jaka Kranjc

Sunday, September 23rd, 2007

Jaka “lynx” Kranjc was nice enough to send in some helpful quick tips for readers.

Use cleanse --sweep to delete unnecessary sources and binary caches. Files are kept if any spell/version in any grimoire could use them.

You have no idea why you have package X installed. You don’t need it, but perhaps some other installed package does? Check with gaze depends X 2

When dispelling, you can also automatically dispel any orphans. Orphans? Orphans are packages that nobody needs, so if X depends on Y and you dispel X, Y is an orphan and probably just takes up space. In this example, to dispel X and any spells who are orphaned by dispelling it you would use: dispel --orphan ask-yes X (see the dispel man page for further info, there is a lot more to this!)

You can quickly downgrade a spell (eg. X at 2.1.1) if you have the cache tarball of a previous version with: dispel -d X 2.0.1

Writing Spells

Friday, June 22nd, 2007

If you are interested in becoming a Source Mage developer you should learn how to write spells. If not an apprentice, you may want to learn how to write your own spells because you couldn’t find a program you need in Source Mage. Here are a couple of ways to get started.
There is a wiki page on sourcemage.org called Spell Writing For Dummies. This is a good way to start to learn the intricacies of spell writing. The good part is you can do this on your local machine without affecting anyone else. So you can make all the mistakes you want while you learn.

Another way to start writing spells is to use a tool that has been created just for that purpose. The tool is called Quill. It has been created and updated by the Source Mage developers to make it easier to write spells. If you want to know when and what things have been added to Quill, here is the location of the changelog. To obtain a better explanation of Quill and all of it’s features, I did a “gaze what quill” in my shell. Here is the result.

quill:
An interactive spell generator and updater script. It’s meant to eventually become the be-all for spell manipulation. It has support for moving the working copy of the spell around, so any lacking features can easily be circumvented manually (the old way).

Current set of features:

  • spell creation with different levels of complexity (see quill -h)
  • full fledged update mode that checks new urls and downloads the sources
  • freshmeat metadata fetching for quicker work
  • perl cpan metadata fetching for quicker work
  • ruby-raa metadata fetching for quicker work
  • copying the spell from and back to the grimoire
  • copying the spell from and back to a local git grimoire (any scm actually)
  • casting of the spell
  • creating a tarball out of it for easy submission
  • SOURCE and SOURCE_URL unexpansion, so later updates will be easy
  • substitution of source urls with known mirror and spell variables
  • dumping of default_build and similar functions for custom spell files
  • sudo support for the copying cases where root privileges are required

Update mode highlights:

  • url checking that also tries substituting the suffixes on failure (bz2<->gz)
  • some multiversion support
  • automatic HISTORY updates
  • simple and automatically style-conformant adding of arbitrary HISTORY entries
  • automatic removal of deprecated variables like UPDATED and MD5
  • automatic removal of old signature files and PATCHLEVEL
  • hash and gpg verification support on spell udpates
  • patchlevel handling

If you want to use Quill, just cast it like you would any other program and your ready to go. Hopefully this will at least point you in the right direction to begin writing your own spells for Source Mage. As always, you can get answers to any questions you might have in the #SourceMage IRC channel on Freenode or on the SM-Discuss mailing list. Now go forth young mage and conjure spells!

Five Quick Tips

Sunday, June 10th, 2007

Here are five brief answers to random questions that are asked often when someone is new to Source Mage GNU Linux.

Question: Does Source Mage use Gnome or KDE?
Answer: Source Mage doesn’t use either one by default. It gives you the choice to use whatever you like. When the installation is finished, you are left with a base system. You will need to install and configure Xorg yourself. Then you can install a desktop system or window manager of your choice.

Question: How do I install a program?
Answer: To install a program use the cast command. For example: cast programname
There are several options to the cast command. You can find these options in the cast man page. Cast takes care of dependicies automatically. You can read more about cast here.

Question: How do I uninstall a program?
Answer: To uninstall use the command dispel. There is a man page available for this command too. Read more information here.

Question: How do I compile my kernel?
Answer: As the root user, use this command: cast -r linux
More information is available here. If you do not want a custom kernel, there is a pre-compiled kernel available when installing Source Mage.

Question: How do I update software on my computer?
Answer: Use this command: sorcery system-update