aboutsummaryrefslogtreecommitdiffstats
path: root/src/usleep.c
blob: f00b6f15010839ce82c76aa6d2a952f172a245f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/* 
 * usleep
 * 
 * Written by Donald Barnes <djb@redhat.com> for Red Hat, Inc.
 * 
 * Copyright (c) 1997-2003 Red Hat, Inc. All rights reserved.
 *
 * This software may be freely redistributed under the terms of the GNU
 * public license.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */


#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>

#include "popt.h"

int main(int argc, char **argv) {
  unsigned long count;
  poptContext optCon;
  int showVersion = 0;
  int showOot = 0;
  int rc;
  char * countStr = NULL;
  struct poptOption options[] = {
            { "version", 'v', POPT_ARG_NONE, &showVersion, 0, 
			"Display the version of this program, and exit" },
            { "oot", 'o', POPT_ARG_NONE, &showOot, 0, 
			"oot says hey!" },
	    POPT_AUTOHELP
            { 0, 0, 0, 0, 0 }
        };

  optCon = poptGetContext("usleep", argc, argv, options,0);
  /*poptReadDefaultConfig(optCon, 1);*/
  poptSetOtherOptionHelp(optCon, "[microseconds]");

  if ((rc = poptGetNextOpt(optCon)) < -1) {
	fprintf(stderr, "usleep: bad argument %s: %s\n", 
		poptBadOption(optCon, POPT_BADOPTION_NOALIAS), 
		poptStrerror(rc));
	return 2;
  }

  if (showVersion) {
      printf("usleep version 1.2\n	usleep --help for more info\n");
      return 0;
  }

  if (showOot) {
      printf("oot says hey!\n");
      return 0;
  }

  countStr = poptGetArg(optCon);

  if (countStr == NULL) count = 1;

  else if (countStr && poptGetArg(optCon)) {
      fprintf(stderr, "%s: exactly one argument (number of microseconds) "
      		"must be used\n", argv[0]);
      return 2;
  }

  else count = strtoul(countStr, NULL, 0); 

  usleep(count);
  return 0;
} 
class="hl opt">/mke2fs -q -m 0 -F -s 1 SO_FILES = c/blib/arch/auto/c/c.so PMS = *.pm c/stuff.pm resize_fat/*.pm pci_probing/*.pm commands install2 diskdrake XFdrake g_auto_install REP4PMS = /usr/bin/perl-install ROOTDEST = /export DEST = $(ROOTDEST)/Mandrake/mdkinst STAGE2 = $(ROOTDEST)/Mandrake/base/mdkinst_stage2 BASE = $(ROOTDEST)/Mandrake/base DESTREP4PMS = $(DEST)$(REP4PMS) STAGE2TMP = /tmp/stage2_tmp PERL = perl LOCALFILES = pnp_serial mouseconfig ddcxinfos LOCALFILES2 = extract_archive DIRS = c po pci_probing resize_fat EXCLUDE = $(LOCALFILES) boot.img keymaps consolefonts install RPMS = $(wildcard $(ROOTDEST)/Mandrake/RPMS/*.rpm) CFLAGS = -Wall override CFLAGS += -pipe .PHONY: all $(DIRS) tags install clean stage2 full_stage2 verify_c all: $(DIRS) tags: etags -o - $(PMS) | ./perl2etags > TAGS clean: for i in $(DIRS); do $(MAKE) -C $$i clean; done rm -rf gendepslist auto ../diskdrake* find . -name "*~" -o -name ".#*" -o -name "TAGS" -o -name "*.old" | xargs rm -f tar: clean cd .. ; tar cfy perl-install.tar.bz2 $(EXCLUDE:%=--exclude %) perl-install tar-diskdrake: clean pci_probing cd .. ; rm -rf diskdrake ; cp -af perl-install diskdrake l=`./perl2fcalls -uses -excludec -excluderesize_fat::c_rewritten diskdrake | sort | uniq | grep -v "^resize_fat::" | sed -e 's/::/\//' -e 's/^/diskdrake\//' -e 's/$$/.pm/'` ; \ cd .. ; tar cfz diskdrake.tgz --exclude CVS $(patsubst %,diskdrake/%,c c.pm resize_fat po diskdrake*) $$l tar-XFdrake: clean cd .. ; rm -rf XFdrake ; cp -af perl-install XFdrake l=`./perl2fcalls -uses -excludec -excludepci_probing::ids XFdrake | sort | uniq | sed -e 's/::/\//' -e 's/^/XFdrake\//' -e 's/$$/.pm/'` ; \ cd .. ; tar cfz XFdrake.tgz --exclude CVS $(patsubst %,XFdrake/%,c MonitorsDB po pci_probing XFdrake*) $$l $(DIRS): install -d auto $(MAKE) -C $@ test_pms: verify_c ./perl2fcalls -excludec -excluderesize_fat::c_rewritten install2 perl -cw -I. -Ic -Ic/blib/arch install2 perl -cw -I. -Ic -Ic/blib/arch install_steps_graphical.pm verify_c: ./verify_c $(PMS) gendepslist: %: %.cc $(CXX) -I/usr/include/rpm $(CFLAGS) $< -lrpm -ldb1 -lz -o $@ $(BASE)/depslist: $(BASE)/hdlist gendepslist ./gendepslist -h $@ $< $(BASE)/hdlist: $(RPMS) $(ROOTDEST)/misc/genhdlist $(ROOTDEST) install_pms: $(DIRS) for i in `perl -ne 's/sub (\w+?)_? {.*/$$1/ and print' commands.pm`; do ln -sf commands $(DEST)/usr/bin/$$i; done install -d $(DESTREP4PMS) for i in $(PMS); do \ dest=$(DESTREP4PMS)/`dirname $$i`; \ install -d $$dest; \ perl -ne 'print' $$i > $(DESTREP4PMS)/$$i; \ perl -pe 's/#-.*//; $$_ = "\n" if (/^=head/ .. /^=cut/) || /use (diagnostics)/' $$i > $(DESTREP4PMS)/$$i; \ done # perl -pe 's/#-.*//; $$_ = "\n" if (/^=head/ .. /^=cut/) || /use (diagnostics|vars|strict)/' $$i > $(DESTREP4PMS)/$$i; \ cp *.rc $(DESTREP4PMS) install -d $(DESTREP4PMS)/po cp -f po/*.po* $(DESTREP4PMS)/po || true ln -sf perl-install/install2 $(DEST)/usr/bin ln -sf perl-install/commands $(DEST)/usr/bin chmod a+x $(DESTREP4PMS)/install2 chmod a+x $(DESTREP4PMS)/commands chmod a+x $(DESTREP4PMS)/XFdrake chmod a+x $(DESTREP4PMS)/g_auto_install get_needed_files: $(DIRS) # export PERL_INSTALL_TEST=1 ; strace -f -e trace=file -o '| grep -v "(No such file or directory)" | sed -e "s/[^\"]*\"//" -e "s/\".*//" | grep "^/" | grep -v -e "^/tmp" -e "^/home" -e "^/proc" -e "^/var" -e "^/dev" -e "^/etc" -e "^/usr/lib/rpm" > /tmp/list ' $(PERL) -d install2 < /dev/null cp -f list /tmp/list ls auto/*/*/*.so >> /tmp/list for i in $(LOCALFILES) `cat /tmp/list` ; do \ ldd $$i 2>/dev/null | grep -v "not a dynamic" | sed -e 's/.*=> //' -e 's/ .*//' | uniq | sort >> /tmp/list; \ done install -d $(DEST)/etc install -d $(DEST)/lib install -d $(DEST)/bin install -d $(DEST)/usr/bin install -d $(DEST)/usr/lib install -d $(DEST)/usr/share install -d $(DEST)/usr/share/gtk install -d $(DEST)/usr/share/xmodmap install -d $(ROOTDEST)/Mandrake/base install -s $(LOCALFILES) $(DEST)/usr/bin cp -f $(LOCALFILES2) $(DEST)/usr/bin for i in `cat /tmp/list`; do \ if (echo $$i | grep -q "lib/[^/]*\.so"); then \ install -s $$i $(DEST)/lib; \ else \ d=$$i; \ (echo $$d | grep -q "^[^/]") && d="$(REP4PMS)/$$d"; \ d=`echo $(DEST)/$$d | sed 's/\/usr\/local\//\/usr\//'`; \ install -d `dirname $$d` && \ if (echo $$i | grep -q "\.pm"); then \ perl -pe '$$_ =~ /^__END__/ and exit(0);' $$i > $$d; \ elif (echo $$i | grep -q "\.so"); then \ install -s $$i $$d; \ else \ cp -f $$i $$d; \ fi; \ fi; \ done mv -f $(DEST)/lib/libimlib-png.so $(DEST)/usr/lib mv -f $(DEST)/bin/* $(DEST)/sbin/* $(DEST)/usr/bin cd $(DEST)/usr/bin ; mv insmod insmod_ rmdir $(DEST)/bin $(DEST)/sbin ln -sf zsh $(DEST)/usr/bin/sh tar xfy locales.tar.bz2 -C $(DEST) # DEST=$(DEST) perl -I. -MForMakefile -e 'locale()' # DEST=$(DEST) perl -I. -MForMakefile -e 'xmodmap()' cp -a keymaps $(DEST)/usr/share cp -a consolefonts $(DEST)/usr/share cp kppprc.in modparm.lst MonitorsDB $(DEST)/usr/share cp logo-mandrake.xpm $(DEST)/usr/share cp -a themes $(DEST)/usr/share/gtk cp compss compssUsers compssList $(ROOTDEST)/Mandrake/base if [ -f "../modules/modules.cz2" ]; then \ cp -f ../modules/modules.cz2 $(DEST)/lib/; \ cp -f ../modules/modules.cz2.pl $(DEST)/lib/; \ else \ cp -f ../modules/modules.cpio.bz2 $(DEST)/lib/; \ install -d $(DEST)/lib/modules; \ cp -f ../modules/pristine/* $(DEST)/lib/modules || true; \ fi ln -s install2 $(DEST)/usr/bin/runinstall2 # echo -e "#!/bin/sh\n\nexec '/usr/bin/sh'" > $(DEST)/usr/bin/runinstall2 # chmod a+x $(DEST)/usr/bin/runinstall2 tar xyC $(DEST) -f ../install/install1_pcmcia.tar.bz2 ./etc/pcmcia as_root: /bin/dd if=/dev/zero of=/tmp/initrd bs=1k count=4000 $(MKE2FS) /tmp/initrd losetup /dev/loop0 /tmp/initrd mount /dev/loop0 /mnt/initrd chmod a+w /mnt/initrd full_stage2: $(BASE)/depslist $(BASE)/hdlist sudo rm -rf $(DEST) mkdir -p $(DEST) $(MAKE) get_needed_files $(MAKE) stage2 stage2: $(MAKE) install_pms $(SUDO) rm -rf $(STAGE2TMP) install -d $(STAGE2TMP) $(SUDO) cp -a $(DEST)/* $(STAGE2TMP) $(SUDO) umount /mnt/stage2 ; true dd if=/dev/zero of=$(STAGE2) bs=1M count=15 $(MKE2FS) -N 1000 $(STAGE2) $(SUDO) mount -t ext2 $(STAGE2) /mnt/stage2 -o loop # hack to reduce the STAGE2 image rm $(STAGE2TMP)/usr/X11R6/bin/XF86_VGA16 for i in /usr/share/locale /usr/share/keymaps /usr/share/xmodmap $(REP4PMS)/po; do \ name=`basename $$i` ; \ (cd $(STAGE2TMP)/$$i ; find * | cpio -o 2>/dev/null | bzip2 > ../$$name.cpio.bz2 ; cd .. ; rm -rf $$name) \ done $(SUDO) cp -a $(STAGE2TMP)/* /mnt/stage2 $(SUDO) rm -rf $(STAGE2TMP) $(SUDO) umount $(STAGE2) gzip -f -3 $(STAGE2) @#rm -rf /mnt/initrd/* @#cp -a $(DEST)/* /mnt/initrd @#sync @#dd if=/dev/loop0 | gzip -9 > /tmp/t/Mandrake/base/stage2.img # function f() { grep "$*" /usr/include/*.h /usr/include/*/*.h; } # # install -s install/install install1/bin/install ; install -s installinit/init install1/bin/init # mount /tmp/initrd /mnt/disk/ -o loop ; ; umount /mnt/disk ; gzip -c /tmp/initrd > /tmp/initrd.img ; mcopy -o /tmp/initrd.img a: