static int emitrules(FILE *fp) { struct files *fi; const char *fpath; /* write suffixes */ if (fprintf(fp, ".SUFFIXES:\n" ".SUFFIXES: .s .S .c .o .ln\n\n" ".c.o:\n" "\t${NORMAL_C}\n\n" ".c.ln:\n" "\t${LINT_C}\n\n" ".s.o:\n" "\t${NORMAL_S}\n\n" ".s.ln:\n" "\t${LINT_S}\n\n" ".S.o:\n" "\t${NORMAL_S}\n\n" ".S.ln:\n" "\t${LINT_S}\n\n") < 0) return (1); for (fi = allfiles; fi != NULL; fi = fi->fi_next) { if ((fi->fi_flags & FI_SEL) == 0) continue; if ((fpath = srcpath(fi)) == NULL) return (1); /* special rule: need to emit them independently */ if (fi->fi_mkrule[0] || fi->fi_mkrule[1]) { if (emit_1rule(fp, fi, fpath, ".o", 0) || emit_1rule(fp, fi, fpath, ".ln", 1)) return (1); /* simple default rule */ } else { if (fprintf(fp, "%s.o %s.ln: %s%s\n", fi->fi_base, fi->fi_base, *fpath != '/' ? "$S/" : "", fpath) < 0) return (1); } } return (0); }
static int emitobjs(FILE *fp) { struct files *fi; struct objects *oi; int lpos, len, sp; const char *fpath; if (fputs("OBJS=", fp) < 0) return (1); sp = '\t'; lpos = 7; for (fi = allfiles; fi != NULL; fi = fi->fi_next) { if ((fi->fi_flags & FI_SEL) == 0) continue; if ((fpath = srcpath(fi)) == NULL) return (1); len = strlen(fi->fi_base) + 3; if (lpos + len > 72) { if (fputs(" \\\n", fp) < 0) return (1); sp = '\t'; lpos = 7; } if (fprintf(fp, "%c%s.o", sp, fi->fi_base) < 0) return (1); lpos += len + 1; sp = ' '; } for (oi = allobjects; oi != NULL; oi = oi->oi_next) { if ((oi->oi_flags & OI_SEL) == 0) continue; len = strlen(oi->oi_path) + 3; if (lpos + len > 72) { if (fputs(" \\\n", fp) < 0) return (1); sp = '\t'; lpos = 7; } if (fprintf(fp, "%c$S/%s", sp, oi->oi_path) < 0) return (1); lpos += len + 1; sp = ' '; } if (putc('\n', fp) < 0) return (1); return (0); }
static int emitfiles(FILE *fp, int suffix) { struct files *fi; int lpos, len, sp; const char *fpath; int uppersuffix = toupper(suffix); if (fprintf(fp, "%cFILES=", uppersuffix) < 0) return (1); sp = '\t'; lpos = 7; for (fi = allfiles; fi != NULL; fi = fi->fi_next) { if ((fi->fi_flags & FI_SEL) == 0) continue; if ((fpath = srcpath(fi)) == NULL) return (1); len = strlen(fpath); if (fpath[len - 1] != suffix && fpath[len - 1] != uppersuffix) continue; if (*fpath != '/') len += 3; /* "$S/" */ if (lpos + len > 72) { if (fputs(" \\\n", fp) < 0) return (1); sp = '\t'; lpos = 7; } if (fprintf(fp, "%c%s%s", sp, *fpath != '/' ? "$S/" : "", fpath) < 0) return (1); lpos += len + 1; sp = ' '; } if (putc('\n', fp) < 0) return (1); return (0); }
void addTestFunctionsAndPaths(lua_State* L) { lua_atpanic(L, atPanicThrow); lua_pushcfunction(L, ts_fail); lua_setglobal(L, "TS_FAIL"); lua_pushcfunction(L, ts_trace); lua_setglobal(L, "TS_TRACE"); lua_pushcfunction(L, ts_warn); lua_setglobal(L, "TS_WARN"); lua_getglobal(L, "package"); luaL_checktype(L, 1, LUA_TTABLE); // for cxxtest.lua lua_getfield(L, 1, "path"); lua_pushstring(L, ";"); lua_pushstring(L, srcpath().c_str()); lua_pushstring(L, "/?.lua"); lua_concat(L, 4); lua_setfield(L, 1, "path"); // for libluacppreflect lua_getfield(L, 1, "cpath"); lua_pushstring(L, ";"); lua_pushstring(L, binpath().c_str()); lua_pushstring(L, "/../lua_module/?.so"); lua_pushstring(L, ";"); lua_pushstring(L, binpath().c_str()); lua_pushstring(L, "/../lua_module/?.dll"); // don't want to mess with platform DEFINEs lua_concat(L, 7); lua_setfield(L, 1, "cpath"); // Uncomment this to prevent the unloading of the library // When the library is unloaded valgrind cannot translate function addresses to names // in the stacktrace //std::string library_path = fmt_str("%1/../lua_module/libluaselfportrait.so", binpath()); //void* handle = dlopen(library_path.c_str(), RTLD_NOW); }
void ProjectWindow::ImportFile(entry_ref ref) { BString command; DPath srcpath(ref); DPath destpath(fProject->GetPath().GetFolder()); command << "copyattr --data '" << srcpath.GetFullPath() << "' '" << destpath.GetFullPath() << "'"; system(command.String()); BString ext(srcpath.GetExtension()); if ((ext.ICompare("h") == 0) || (ext.ICompare("hxx") == 0) || (ext.ICompare("hpp") == 0) || (ext.ICompare("h++") == 0)) return; DPath destfile(destpath); destfile << ref.name; BEntry destEntry(destfile.GetFullPath()); entry_ref destref; destEntry.GetRef(&destref); AddFile(destref,NULL); }
static int domerg(struct cfextra **extlist, int part, int nparts, int myclass, char **srcp, char **dstp, char **r_updated, char **r_skipped, char **r_anyPathLocal) { boolean_t stateFlag = B_FALSE; int i; int msg_ugid; static int maxvol = 0; static int svindx = 0; static int svpart = 0; struct cfent *ept = (struct cfent *)NULL; struct mergstat *mstat = (struct mergstat *)NULL; /* reset returned path pointers */ *dstp = (char *)NULL; *srcp = (char *)NULL; /* set to start or continue based on which part being processed */ if (part != 0) { maxvol = 0; svindx = 0; svpart = part; } else { i = svindx; part = svpart; } /* * This goes through the pkgmap entries one by one testing them * for inclusion in the package database as well as for validity * against existing files. */ for (i = svindx; extlist[i]; i++) { ept = &(extlist[i]->cf_ent); mstat = &(extlist[i]->mstat); /* * as paths are processed, if the "anyPathLocal" flag has not * been set, if the object is not of type 'i' (package script), * check to see if the object is in an area inherited from the * global zone - if not, set "anyPathLocal" to the path found, * indicating that at least one path is in an area that is not * inherited from the global zone. */ if ((r_anyPathLocal != (char **)NULL) && (*r_anyPathLocal == (char *)NULL) && (ept->ftype != 'i') && (z_path_is_inherited(ept->path, ept->ftype, get_inst_root()) == B_FALSE)) { echoDebug(DBG_INSTVOL_OBJ_LOCAL, ept->path); *r_anyPathLocal = ept->path; } /* if this isn't the class of current interest, skip it */ if (myclass != ept->pkg_class_idx) { continue; } /* if the class is invalid, announce it & exit */ if (ept->pkg_class_idx == -1) { progerr(ERR_CLIDX, ept->pkg_class_idx, (ept->path && *ept->path) ? ept->path : "unknown"); logerr(gettext("pathname=%s\n"), (ept->path && *ept->path) ? ept->path : "unknown"); logerr(gettext("class=<%s>\n"), (ept->pkg_class && *ept->pkg_class) ? ept->pkg_class : "Unknown"); logerr(gettext("CLASSES=<%s>\n"), getenv("CLASSES") ? getenv("CLASSES") : "Not Set"); quit(99); } /* * Next check to see if we are going to try to delete a * populated directory in some distressing way. */ if (mstat->dir2nondir) if (dir_is_populated(ept->path)) { logerr(WRN_INSTVOL_NOTDIR, ept->path); warnflag++; mstat->denied = 1; /* install denied! */ continue; } else { /* Replace is OK. */ /* * Remove this directory, so it won't * interfere with creation of the new object. */ if (rmdir(ept->path)) { /* * If it didn't work, there's nothing * we can do. To continue would * likely corrupt the filesystem * which is unacceptable. */ progerr(ERR_RMDIR, ept->path); quit(99); } repl_permitted = 1; /* flag it */ } /* adjust the max volume number appropriately */ if (ept->volno > maxvol) { maxvol = ept->volno; } /* if this part goes into another volume, skip it */ if (part != ept->volno) { continue; } /* * If it's a conflicting file and it's not supposed to be * installed, note it and skip. */ if (nocnflct && mstat->shared && ept->ftype != 'e') { if (mstat->contchg || mstat->attrchg) { echo(MSG_SHIGN, ept->path); } continue; } /* * If we want to set uid or gid but user says no, note it. * Remember that the actual mode bits in the structure have * already been adjusted and the mstat flag is telling us * about the original mode. */ if (nosetuid && (mstat->setuid || mstat->setgid)) { msg_ugid = 1; /* don't repeat attribute message. */ if (is_fs_writeable(ept->path, &(extlist[i]->fsys_value))) { if (!(mstat->contchg) && mstat->attrchg) { echo(MSG_UGMOD, ept->path); } else { echo(MSG_UGID, ept->path); } } } else { msg_ugid = 0; } switch (ept->ftype) { case 'l': /* hard link */ /* links treated as object "update/skip" */ stateFlag = B_TRUE; continue; /* defer to final proc */ case 's': /* for symlink, verify without fix first */ /* links treated as object "update/skip" */ stateFlag = B_TRUE; /* Do this only for default verify */ if (cl_dvfy(myclass) == DEFAULT) { if (averify(0, &ept->ftype, ept->path, &ept->ainfo)) echo(MSG_SLINK, ept->path); } /*FALLTHRU*/ case 'd': /* directory */ case 'x': /* exclusive directory */ case 'c': /* character special device */ case 'b': /* block special device */ case 'p': /* named pipe */ /* these NOT treated as object "update/skip" */ stateFlag = B_FALSE; /* * If we can't get to it for legitimate reasons, * don't try to verify it. */ if ((z_path_is_inherited(ept->path, ept->ftype, get_inst_root())) || is_remote_fs(ept->path, &(extlist[i]->fsys_value)) && !is_fs_writeable(ept->path, &(extlist[i]->fsys_value))) { mstat->attrchg = 0; mstat->contchg = 0; break; } if (averify(1, &ept->ftype, ept->path, &ept->ainfo) == 0) { mstat->contchg = mstat->attrchg = 0; } else { progerr(ERR_CREATE_PKGOBJ, ept->path); logerr(getErrbufAddr()); warnflag++; } break; case 'i': /* information file */ /* not treated as object "update/skip" */ stateFlag = B_FALSE; break; default: /* all files treated as object "update/skip" */ stateFlag = B_TRUE; break; } /* * Both contchg and shared flags have to be taken into * account. contchg is set if the file is already present * in the package database, if it does not exist or if it * exists and is modified. * The shared flag is set when 'e' or 'v' file is not * present in the package database, exists and is not * modified. It also has to be checked here. * Shared flag is also set when file is present in package * database and owned by more than one package, but for * this case contchg has already been set. */ if (mstat->contchg || (mstat->shared && ((ept->ftype == 'e') || (ept->ftype == 'v')))) { *dstp = ept->path; if ((ept->ftype == 'f') || (ept->ftype == 'e') || (ept->ftype == 'v')) { *srcp = ept->ainfo.local; if (is_partial_inst() != 0) { if (*srcp[0] == '~') { /* translate source pathname */ *srcp = srcpath(instdir, extlist[i]->map_path, part, nparts); } else { *srcp = extlist[i]->map_path; } } else { if (*srcp[0] == '~') { /* translate source pathname */ *srcp = srcpath(instdir, &(ept->ainfo.local[1]), part, nparts); } } echoDebug(DBG_DOMERG_NO_SUCH_FILE, ept->ftype, cl_nam(ept->pkg_class_idx), ept->path); } else { /* * At this point, we're returning a non-file * that couldn't be created in the standard * way. If it refers to a filesystem that is * not writeable by us, don't waste the * calling process's time. */ if (!is_fs_writeable(ept->path, &(extlist[i]->fsys_value))) { echoDebug(DBG_DOMERG_NOT_WRITABLE, ept->ftype, cl_nam(ept->pkg_class_idx), ept->path); continue; } *srcp = NULL; echoDebug(DBG_DOMERG_NOT_THERE, ept->ftype, cl_nam(ept->pkg_class_idx), ept->path); } svindx = i+1; backup(*dstp, 1); return (i); } if (mstat->attrchg) { backup(ept->path, 0); if (!msg_ugid) echo(MSG_ATTRIB, ept->path); /* fix the attributes now for robustness sake */ if (averify(1, &ept->ftype, ept->path, &ept->ainfo) == 0) { mstat->attrchg = 0; } } /* * package object exists, or does not need updating: if the path * is in an area inherited from the global zone, then treat * the object as if it were "skipped" - if the path is not in an * area inherited from the global zone, then treat the object as * if it were "updated" */ /* LINTED warning: statement has no consequent: if */ if ((stateFlag == B_FALSE) || (ept == (struct cfent *)NULL)) { /* * the object in question is a directory or special * file - the fact that this type of object already * exists or does not need updating must not trigger * the object updated/object skipped indication - * that would cause class action scripts to be run * when installing a new non-global zone - that action * must only be done when a file object that is in * an area inherited from the global zone is present. */ } else if (z_path_is_inherited(ept->path, ept->ftype, get_inst_root()) == B_TRUE) { if (r_skipped != (char **)NULL) { if (*r_skipped == (char *)NULL) { echoDebug(DBG_INSTVOL_OBJ_SKIPPED, ept->path); *r_skipped = ept->path; } } } else { if (r_updated != (char **)NULL) { if (*r_updated == (char *)NULL) { echoDebug(DBG_INSTVOL_OBJ_UPDATED, ept->path); } *r_updated = ept->path; } } } if (maxvol == part) { eocflag++; /* endofclass */ } return (DMRG_DONE); /* no remaining entries on this volume */ }
static void outvol(struct cfent **eptlist, int eptnum, int part, int nparts) { FILE *fp; char *svpt, *path, temp[PATH_MAX]; int i; if (nparts > 1) (void) fprintf(stderr, gettext(" -- part %2d:\n"), part); if (part == 1) { /* re-write pkgmap, but exclude local pathnames */ (void) snprintf(temp, sizeof (temp), "%s/pkgmap", pkgloc); if ((fp = fopen(temp, "w")) == NULL) { progerr(gettext(ERR_TEMP), errno); quit(99); } (void) fprintf(fp, ": %d %ld\n", nparts, limit); for (i = 0; eptlist[i]; i++) { svpt = eptlist[i]->ainfo.local; if (!strchr("sl", eptlist[i]->ftype)) eptlist[i]->ainfo.local = NULL; if (ppkgmap(eptlist[i], fp)) { progerr(gettext(ERR_TEMP), errno); quit(99); } eptlist[i]->ainfo.local = svpt; } (void) fclose(fp); (void) fprintf(stderr, "%s\n", temp); } (void) snprintf(temp, sizeof (temp), "%s/pkginfo", pkgloc); if (copyf(svept->ainfo.local, temp, svept->cinfo.modtime)) quit(1); (void) fprintf(stderr, "%s\n", temp); for (i = 0; i < eptnum; i++) { if (eptlist[i]->volno != part) continue; if (strchr("dxslcbp", eptlist[i]->ftype)) continue; if (eptlist[i]->ftype == 'i') { if (eptlist[i] == svept) continue; /* don't copy pkginfo file */ (void) snprintf(temp, sizeof (temp), "%s/install/%s", pkgloc, eptlist[i]->path); path = temp; } else path = srcpath(pkgloc, eptlist[i]->path, part, nparts); if (sflag) { if (slinkf(eptlist[i]->ainfo.local, path)) quit(1); } else if (copyf(eptlist[i]->ainfo.local, path, eptlist[i]->cinfo.modtime)) { quit(1); } /* * If the package file attributes can be sync'd up with * the pkgmap, we fix the attributes here. */ if (*(eptlist[i]->ainfo.owner) != '$' && *(eptlist[i]->ainfo.group) != '$' && getuid() == 0) { /* Clear dangerous bits. */ eptlist[i]->ainfo.mode= (eptlist[i]->ainfo.mode & S_IAMB); /* * Make sure it can be read by the world and written * by root. */ eptlist[i]->ainfo.mode |= 0644; if (!strchr("in", eptlist[i]->ftype)) { /* Set the safe attributes. */ averify(1, &(eptlist[i]->ftype), path, &(eptlist[i]->ainfo)); } } (void) fprintf(stderr, "%s\n", path); } }