' Gambas module file PUBLIC sLockFile AS String = "/tmp/rpminstall." & System.User.Id ' lock file path PUBLIC hLockFile AS File ' handler for lock file PUBLIC sArch AS String ' hold arch string PUBLIC SUB Main() DIM i AS Integer DIM sOutput AS String ' if lock file already exist and other instance are running, ' then add arguments to lock file and exit. SHELL "pgrep -f -U " & User.ID & " " & Application.Args[0] TO sOutput IF Exist(sLockFile) = TRUE AND IF Split(Trim$(sOutput), "\n").Count > 1 THEN hLockFile = OPEN sLockFile FOR APPEND FOR i = 1 TO Application.Args.Count - 1 PRINT #hLockFile, Application.Args[i] NEXT hLockFile.Close() PRINT ("Lock file exists. Seems other rpminstall is running.") ELSE ' create lock file (size = 0) hLockFile = OPEN sLockFile FOR CREATE hLockFile.Close() ' get current system arch type using rpm command. EXEC ["rpm", "--eval", "%{_arch}"] TO sArch sArch = Split(sArch, "\n")[0] IF sArch = "i386" THEN sArch = "i?86" ELSE IF sArch = "x86_64" THEN ' i?86.rpm should be installable on x86_64 sArch = "*86*" ENDIF ' store arguments to listview IF Application.Args.Count > 1 THEN FOR i = 1 TO Application.Args.Count - 1 AddRPMtolvwMain(Application.Args[i]) NEXT ENDIF FMain.Show() ENDIF END PUBLIC SUB AddRPMtolvwMain(sFile AS String) DIM s2ndExt AS String ' ignore not suitable files and store them to listview (use filename as key) ' check extention is "rpm" IF File.Ext(sFile) = "rpm" THEN ' check sArch or "noarch" or "src" for 2nd(?) extention s2ndExt = File.Ext(File.BaseName(sFile)) IF s2ndExt LIKE sArch OR IF s2ndExt = "noarch" OR IF s2ndExt = "src" THEN ' check duplicate IF FMain.lvwMain.Exist(File.Name(sFile)) = FALSE THEN FMain.lvwMain.Add(File.Name(sFile), sFile, Picture.Load("rpm.png")) ENDIF ENDIF ENDIF END