code: func chaincodePackage(cmd *cobra.Command, args []string, cdsFact ccDepSpecFactory, cf *ChaincodeCmdFactory) error {
  	if cdsFact == nil {
  		return fmt.Errorf("Error chaincode deployment spec factory not specified")
  	}
  	// Parsing of the command line is done so silence cmd usage
  	cmd.SilenceUsage = true
  
  	var err error
  	if cf == nil {
  		cf, err = InitCmdFactory(cmd.Name(), false, false)
  		if err != nil {
  			return err
  		}
  	}
  	spec, err := getChaincodeSpec(cmd)
  	if err != nil {
  		return err
  	}
  
  	cds, err := cdsFact(spec)
  	if err != nil {
  		return fmt.Errorf("error getting chaincode code %s: %s", chaincodeName, err)
  	}
  
  	var bytesToWrite []byte
  	if createSignedCCDepSpec {
  		bytesToWrite, err = getChaincodeInstallPackage(cds, cf)
  		if err != nil {
  			return err
  		}
  	} else {
  		bytesToWrite = utils.MarshalOrPanic(cds)
  	}
  
  	logger.Debugf("Packaged chaincode into deployment spec of size <%d>, with args = %v", len(bytesToWrite), args)
  	fileToWrite := args[0]
  	err = ioutil.WriteFile(fileToWrite, bytesToWrite, 0700)
  	if err != nil {
  		logger.Errorf("failed writing deployment spec to file [%s]: [%s]", fileToWrite, err)
  		return err
  	}
  
  	return err
  }
docs: // chaincodePackage creates the chaincode package. On success, the chaincode name
  // (hash) is printed to STDOUT for use by subsequent chaincode-related CLI
  // commands.