/* Copyright: 2012, Igor Pashev DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE Version 2, December 2004 Copyright (C) 2004 Sam Hocevar Everyone is permitted to copy and distribute verbatim or modified copies of this license document, and changing it is allowed as long as the name is changed. DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. You just DO WHAT THE FUCK YOU WANT TO. */ /* * Wrapper for real crle(1). * * Runtime linker uses binary config file, and * 32- and 64-bit versions of the linker use different * config files. To make changes to those files one must use * crle(1) of corresponding bitness. * * Since we cannot have two or more files named '/usr/bin/crle', * we create this wrapper, which will dispatch to corresponding * real program residing under /usr/lib// and under * /usr/lib32 (on 64-bit systems). * * For example, let's assume we are on amd64 system: * /usr/bin/crle without -64 or -32 options will execute "native" crle * (/usr/lib/x86_64-illumos/crle); with -32 option - /usr/lib32/crle; * option -64 is noop. */ #include #include #include #include const char crle64[] = DEB_USRLIBDIR_64 "/crle"; const char crle32[] = DEB_USRLIBDIR_32 "/crle"; char *help[] = { "crle", "-h" }; #if DEB_HOST_ARCH_BITS == 64 #define crle crle64 #elif DEB_HOST_ARCH_BITS == 32 #define crle crle32 #else #error DEB_HOST_ARCH_BITS is not set or has a wrong value #endif static void myexec (const char *path, char **argv) { int rc; rc = execv (path, argv); perror (path); exit (rc); } int main (int argc, char **argv) { int i; int use_help = 0; int use_64 = 0; int use_32 = 0; for (i = 1; i < argc; i++) { if (argv[i][0] == '-' && argv[i][1] == 'h') use_help++; else if (strcmp ("-64", argv[i]) == 0) use_64++; else if (strcmp ("-32", argv[i]) == 0) use_32++; } if (use_help) myexec (crle, help); if (!use_64 && !use_32) myexec (crle, argv); if (use_64 && !use_32) myexec (crle64, argv); if (use_32 && !use_64) myexec (crle32, argv); fprintf (stderr, "Options -32 and -64 cannot be used together\n"); return EXIT_FAILURE; }