enhancement: expose srpmproc library

This commit is contained in:
Mustafa Gezen 2021-08-19 12:09:53 +02:00
parent f71605a7d5
commit 7d84156a4b
Signed by: mustafa
GPG Key ID: DCDF010D946438C1
23 changed files with 31 additions and 32 deletions

5
.gitignore vendored
View File

@ -14,7 +14,6 @@
# Dependency directories (remove the comment below to include it)
# vendor/
testdata
srpmproc
/srpmproc
.idea
dist/
dist/
/dist/

View File

@ -23,7 +23,7 @@ package main
import (
"errors"
"fmt"
"github.com/rocky-linux/srpmproc/internal/data"
"github.com/rocky-linux/srpmproc/pkg/data"
"github.com/spf13/cobra"
"io/ioutil"
"log"

View File

@ -22,6 +22,7 @@ package main
import (
"fmt"
"github.com/rocky-linux/srpmproc/pkg/srpmproc"
"log"
"os"
"os/user"
@ -32,13 +33,12 @@ import (
"github.com/go-git/go-billy/v5/memfs"
"github.com/go-git/go-billy/v5/osfs"
"github.com/go-git/go-git/v5/plumbing/transport/ssh"
"github.com/rocky-linux/srpmproc/internal/blob"
"github.com/rocky-linux/srpmproc/internal/blob/file"
"github.com/rocky-linux/srpmproc/internal/blob/gcs"
"github.com/rocky-linux/srpmproc/internal/blob/s3"
"github.com/rocky-linux/srpmproc/internal/data"
"github.com/rocky-linux/srpmproc/pkg/blob"
"github.com/rocky-linux/srpmproc/pkg/blob/file"
"github.com/rocky-linux/srpmproc/pkg/blob/gcs"
"github.com/rocky-linux/srpmproc/pkg/blob/s3"
"github.com/rocky-linux/srpmproc/pkg/data"
"github.com/rocky-linux/srpmproc/internal"
"github.com/spf13/cobra"
)
@ -96,14 +96,14 @@ func mn(_ *cobra.Command, _ []string) {
sourceRpmLocation := ""
if strings.HasPrefix(sourceRpm, "file://") {
sourceRpmLocation = strings.TrimPrefix(sourceRpm, "file://")
importer = &internal.SrpmMode{}
importer = &srpmproc.SrpmMode{}
} else {
if moduleMode {
sourceRpmLocation = fmt.Sprintf("%s/%s", modulePrefix, sourceRpm)
} else {
sourceRpmLocation = fmt.Sprintf("%s/%s", rpmPrefix, sourceRpm)
}
importer = &internal.GitMode{}
importer = &srpmproc.GitMode{}
}
lastKeyLocation := sshKeyLocation
@ -145,7 +145,7 @@ func mn(_ *cobra.Command, _ []string) {
manualCs = strings.Split(manualCommits, ",")
}
internal.ProcessRPM(&data.ProcessData{
srpmproc.ProcessRPM(&data.ProcessData{
Importer: importer,
RpmLocation: sourceRpmLocation,
UpstreamPrefix: upstreamPrefix,

View File

@ -23,7 +23,7 @@ package data
import (
"github.com/go-git/go-billy/v5"
"github.com/go-git/go-git/v5/plumbing/transport/ssh"
"github.com/rocky-linux/srpmproc/internal/blob"
"github.com/rocky-linux/srpmproc/pkg/blob"
)
type ProcessData struct {

View File

@ -28,8 +28,8 @@ import (
"path/filepath"
"github.com/go-git/go-git/v5"
"github.com/rocky-linux/srpmproc/internal/data"
srpmprocpb "github.com/rocky-linux/srpmproc/pb"
"github.com/rocky-linux/srpmproc/pkg/data"
)
// returns right if not empty, else left

View File

@ -25,8 +25,8 @@ import (
"fmt"
"github.com/go-git/go-git/v5"
"github.com/rocky-linux/srpmproc/internal/data"
srpmprocpb "github.com/rocky-linux/srpmproc/pb"
"github.com/rocky-linux/srpmproc/pkg/data"
)
func del(cfg *srpmprocpb.Cfg, _ *data.ProcessData, _ *data.ModeData, _ *git.Worktree, pushTree *git.Worktree) error {

View File

@ -28,8 +28,8 @@ import (
"strings"
"github.com/go-git/go-git/v5"
"github.com/rocky-linux/srpmproc/internal/data"
srpmprocpb "github.com/rocky-linux/srpmproc/pb"
"github.com/rocky-linux/srpmproc/pkg/data"
)
func checkAddPrefix(file string) string {

View File

@ -33,8 +33,8 @@ import (
"time"
"github.com/go-git/go-git/v5"
"github.com/rocky-linux/srpmproc/internal/data"
srpmprocpb "github.com/rocky-linux/srpmproc/pb"
"github.com/rocky-linux/srpmproc/pkg/data"
)
func lookaside(cfg *srpmprocpb.Cfg, _ *data.ProcessData, md *data.ModeData, patchTree *git.Worktree, pushTree *git.Worktree) error {

View File

@ -28,8 +28,8 @@ import (
"github.com/bluekeyes/go-gitdiff/gitdiff"
"github.com/go-git/go-git/v5"
"github.com/rocky-linux/srpmproc/internal/data"
srpmprocpb "github.com/rocky-linux/srpmproc/pb"
"github.com/rocky-linux/srpmproc/pkg/data"
)
func patch(cfg *srpmprocpb.Cfg, _ *data.ProcessData, _ *data.ModeData, patchTree *git.Worktree, pushTree *git.Worktree) error {

View File

@ -27,8 +27,8 @@ import (
"os"
"github.com/go-git/go-git/v5"
"github.com/rocky-linux/srpmproc/internal/data"
srpmprocpb "github.com/rocky-linux/srpmproc/pb"
"github.com/rocky-linux/srpmproc/pkg/data"
)
func replace(cfg *srpmprocpb.Cfg, pd *data.ProcessData, _ *data.ModeData, patchTree *git.Worktree, pushTree *git.Worktree) error {

View File

@ -33,8 +33,8 @@ import (
"time"
"github.com/go-git/go-git/v5"
"github.com/rocky-linux/srpmproc/internal/data"
srpmprocpb "github.com/rocky-linux/srpmproc/pb"
"github.com/rocky-linux/srpmproc/pkg/data"
)
const (

View File

@ -18,7 +18,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
package internal
package srpmproc
import (
"fmt"
@ -36,7 +36,7 @@ import (
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/object"
"github.com/go-git/go-git/v5/storage/memory"
"github.com/rocky-linux/srpmproc/internal/data"
"github.com/rocky-linux/srpmproc/pkg/data"
)
type remoteTarget struct {

View File

@ -18,7 +18,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
package internal
package srpmproc
import (
"github.com/cavaliercoder/go-rpm"

View File

@ -18,4 +18,4 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
package internal
package srpmproc

View File

@ -18,7 +18,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
package internal
package srpmproc
import (
"fmt"
@ -33,10 +33,10 @@ import (
"github.com/go-git/go-git/v5/config"
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/storage/memory"
"github.com/rocky-linux/srpmproc/internal/data"
"github.com/rocky-linux/srpmproc/internal/directives"
"github.com/rocky-linux/srpmproc/modulemd"
srpmprocpb "github.com/rocky-linux/srpmproc/pb"
"github.com/rocky-linux/srpmproc/pkg/data"
"github.com/rocky-linux/srpmproc/pkg/directives"
"google.golang.org/protobuf/encoding/prototext"
)

View File

@ -18,7 +18,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
package internal
package srpmproc
import (
"encoding/hex"
@ -38,7 +38,7 @@ import (
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/object"
"github.com/go-git/go-git/v5/storage/memory"
"github.com/rocky-linux/srpmproc/internal/data"
"github.com/rocky-linux/srpmproc/pkg/data"
)
var tagImportRegex *regexp.Regexp

View File

@ -18,7 +18,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
package internal
package srpmproc
import (
"bytes"
@ -37,7 +37,7 @@ import (
"github.com/go-git/go-billy/v5/memfs"
"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/storage/memory"
"github.com/rocky-linux/srpmproc/internal/data"
"github.com/rocky-linux/srpmproc/pkg/data"
)
type SrpmMode struct{}