tasks/rpm.js
function copyFilesToPack(grunt, buildPath, filesToPack) {
	return function(callback) {
		grunt.util.async.forEach(filesToPack, function(fileConfig, callback) {
			try {
				var filepathDest;
				if (detectDestType(grunt, fileConfig.dest) === 'directory') {
					var dest = (fileConfig.orig.expand) ? fileConfig.dest : path.join(fileConfig.dest, fileConfig.src);
					filepathDest = path.join(buildPath, dest);
				} else {
					filepathDest = path.join(buildPath, fileConfig.dest);
				}

				if (grunt.file.isDir(fileConfig.src)) {
					if (fileConfig.directory) {
						// Copy a whole folder to the destination directory.
						grunt.verbose.writeln('Copying folder "' + fileConfig.src + '" to "' + filepathDest + '"');
						fs.copyRecursive(fileConfig.src, filepathDest, callback);
					} else {
						// Create a folder inside the destination directory.
						grunt.verbose.writeln('Creating folder "' + filepathDest + '"');
						fs.mkdirs(filepathDest, callback);
					}
				} else {
					// Copy a file to the destination directory inside the tmp folder.
					if (fileConfig.link) {
						grunt.verbose.writeln('Copying symlink "' + fileConfig.src + '->' + fileConfig.link + '" to "' + filepathDest + '"');
						//ensure the parent directory exists when making symlinks
						fs.mkdirs(getDirName(filepathDest), function(err) {
							if (err) throw err;
							_fs.symlink(fileConfig.link, filepathDest, 'file', callback);
						});
						
					}
					else {
						grunt.verbose.writeln('Copying file "' + fileConfig.src + '" to "' + filepathDest + '"');
						grunt.file.copy(fileConfig.src, filepathDest);
						fs.lstat(fileConfig.src, function(err, stat) {
							if (err) throw err;
							_fs.chmod(filepathDest, stat.mode, callback);
						});
					}
				}
				
			} catch(e) {
				callback(e);
			}
		}, callback);
	};
}
function copyFilesToPack(grunt, buildPath, filesToPack) {
	return function(callback) {
		grunt.util.async.forEach(filesToPack, function(fileConfig, callback) {
			try {
				var filepathDest;
				if (detectDestType(grunt, fileConfig.dest) === 'directory') {
					var dest = (fileConfig.orig.expand) ? fileConfig.dest : path.join(fileConfig.dest, fileConfig.src);
					filepathDest = path.join(buildPath, dest);
				} else {
					filepathDest = path.join(buildPath, fileConfig.dest);
				}

				if (grunt.file.isDir(fileConfig.src)) {
					if (fileConfig.directory) {
						// Copy a whole folder to the destination directory.
						grunt.verbose.writeln('Copying folder "' + fileConfig.src + '" to "' + filepathDest + '"');
						fs.copyRecursive(fileConfig.src, filepathDest, callback);
					} else {
						// Create a folder inside the destination directory.
						grunt.verbose.writeln('Creating folder "' + filepathDest + '"');
						fs.mkdirs(filepathDest, callback);
					}
				} else {
					// Copy a file to the destination directory inside the tmp folder.
					if (fileConfig.link) {
						grunt.verbose.writeln('Copying symlink "' + fileConfig.src + '->' + fileConfig.link + '" to "' + filepathDest + '"');
						//ensure the parent directory exists when making symlinks
						fs.mkdirs(getDirName(filepathDest), function(err) {
							if (err) throw err;
							_fs.symlink(fileConfig.link, filepathDest, 'file', callback);
						});
						
					}
					else {
						grunt.verbose.writeln('Copying file "' + fileConfig.src + '" to "' + filepathDest + '"');
						grunt.file.copy(fileConfig.src, filepathDest);
						fs.lstat(fileConfig.src, function(err, stat) {
							if (err) throw err;
							_fs.chmod(filepathDest, stat.mode, callback);
						});
					}
				}
				
			} catch(e) {
				callback(e);
			}
		}, callback);
	};
}
function copyFilesToPack ( grunt , buildPath , filesToPack ) { return function ( callback ) { grunt . util . async . forEach ( filesToPack , function ( fileConfig , callback ) { try { var filepathDest ; if ( detectDestType ( grunt , fileConfig . dest ) === 'directory' ) { var dest = ( fileConfig . orig . expand ) ? fileConfig . dest : path . join ( fileConfig . dest , fileConfig . src ) ; filepathDest = path . join ( buildPath , dest ) ; } else { filepathDest = path . join ( buildPath , fileConfig . dest ) ; } if ( grunt . file . isDir ( fileConfig . src ) ) { if ( fileConfig . directory ) { // Copy a whole folder to the destination directory. grunt . verbose . writeln ( 'Copying folder "' + fileConfig . src + '" to "' + filepathDest + '"' ) ; fs . copyRecursive ( fileConfig . src , filepathDest , callback ) ; } else { // Create a folder inside the destination directory. grunt . verbose . writeln ( 'Creating folder "' + filepathDest + '"' ) ; fs . mkdirs ( filepathDest , callback ) ; } } else { // Copy a file to the destination directory inside the tmp folder. if ( fileConfig . link ) { grunt . verbose . writeln ( 'Copying symlink "' + fileConfig . src + '->' + fileConfig . link + '" to "' + filepathDest + '"' ) ; //ensure the parent directory exists when making symlinks fs . mkdirs ( getDirName ( filepathDest ) , function ( err ) { if ( err ) throw err ; _fs . symlink ( fileConfig . link , filepathDest , 'file' , callback ) ; } ) ; } else { grunt . verbose . writeln ( 'Copying file "' + fileConfig . src + '" to "' + filepathDest + '"' ) ; grunt . file . copy ( fileConfig . src , filepathDest ) ; fs . lstat ( fileConfig . src , function ( err , stat ) { if ( err ) throw err ; _fs . chmod ( filepathDest , stat . mode , callback ) ; } ) ; } } } catch ( e ) { callback ( e ) ; } } , callback ) ; } ; }
Copy all the selected files to the tmp folder which wikll be the buildroot directory for rpmbuild
Copy all the selected files to the tmp folder which wikll be the buildroot directory for rpmbuild