Mercurial > pkg
diff src/pkg.pl @ 2:a75581c89dde
validation and help message.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Tue, 08 Jan 2013 12:48:59 +0000 |
parents | 0b7a589f6e9a |
children | 9ff0fcf34920 |
line wrap: on
line diff
1.1 --- a/src/pkg.pl Tue Jan 08 11:45:01 2013 +0000 1.2 +++ b/src/pkg.pl Tue Jan 08 12:48:59 2013 +0000 1.3 @@ -0,0 +1,52 @@ 1.4 +#!/usr/bin/env perl 1.5 + 1.6 +if ($ARGV[0] eq "--help"){ 1.7 + print <<"HERE"; 1.8 + 1.9 +pkg -- create a package user. 1.10 + 1.11 +syntax: 1.12 + pkg package-name description 1.13 + pkg --help 1.14 + 1.15 +Create a package user for the purpose of compiling 1.16 +a particular package. 1.17 + 1.18 +The user will be created with user and group both 1.19 +equal to the name you specify. 1.20 + 1.21 +You will then be put into the user's home 1.22 +directory where you may proceed with 1.23 +compiling/installation of the package. 1.24 + 1.25 +If the user already exists, this is equivalent to 1.26 + su package-name; cd ~; 1.27 + 1.28 +Written by Robert McIntyre. This software is free 1.29 +software and is released to the public domain. 1.30 + 1.31 +HERE 1.32 +exit 0; 1.33 +} 1.34 + 1.35 + 1.36 +$pkg_name = $ARGV[0]; 1.37 + 1.38 +$pkg_desc = $ARGV[1]; 1.39 + 1.40 +# Validate pkg_user as a user name. 1.41 +if (!($pkg_name =~ m/^[A-Za-z][A-Za-z0-9_-]*$/)){ 1.42 + print "$pkg_name is not a valid user name!\n"; 1.43 + exit 0; 1.44 +} 1.45 + 1.46 +# Validate description. 1.47 +if ($pkg_desc =~ m/:/){ 1.48 + print "Package Description cannot contain \":\"\n"; 1.49 + exit 0 1.50 +} 1.51 + 1.52 + 1.53 +print "name: $pkg_name\ndesc: $pkg_desc\n"; 1.54 + 1.55 +