# HG changeset patch # User Robert McIntyre # Date 1357649339 0 # Node ID a75581c89ddea1b4962eb592dcbe03ebff195ecf # Parent d6bef198ae71788e613d067c8364dec2dfb12846 validation and help message. diff -r d6bef198ae71 -r a75581c89dde org/pkg.org --- a/org/pkg.org Tue Jan 08 11:45:01 2013 +0000 +++ b/org/pkg.org Tue Jan 08 12:48:59 2013 +0000 @@ -36,7 +36,7 @@ (this commits as the emacs user) 3. can examine provenance of information -$ pkg-examine emacs +$ pkg-report emacs > package emacs owns the following files: > emacs > man/emacs diff -r d6bef198ae71 -r a75581c89dde src/pkg.pl --- a/src/pkg.pl Tue Jan 08 11:45:01 2013 +0000 +++ b/src/pkg.pl Tue Jan 08 12:48:59 2013 +0000 @@ -0,0 +1,52 @@ +#!/usr/bin/env perl + +if ($ARGV[0] eq "--help"){ + print <<"HERE"; + +pkg -- create a package user. + +syntax: + pkg package-name description + pkg --help + +Create a package user for the purpose of compiling +a particular package. + +The user will be created with user and group both +equal to the name you specify. + +You will then be put into the user's home +directory where you may proceed with +compiling/installation of the package. + +If the user already exists, this is equivalent to + su package-name; cd ~; + +Written by Robert McIntyre. This software is free +software and is released to the public domain. + +HERE +exit 0; +} + + +$pkg_name = $ARGV[0]; + +$pkg_desc = $ARGV[1]; + +# Validate pkg_user as a user name. +if (!($pkg_name =~ m/^[A-Za-z][A-Za-z0-9_-]*$/)){ + print "$pkg_name is not a valid user name!\n"; + exit 0; +} + +# Validate description. +if ($pkg_desc =~ m/:/){ + print "Package Description cannot contain \":\"\n"; + exit 0 +} + + +print "name: $pkg_name\ndesc: $pkg_desc\n"; + +